summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-09-13 04:06:34 (EDT)
committerEike Stepper2007-09-13 04:06:34 (EDT)
commit34cc0fca811b47cf602855eabd4f43058bf90a89 (patch)
tree0f766dfd3c5fe8bd8e888c6ac7c627aea1410898
parenta1ccc628f0bc6354dce0a47dcc0d545992ac597c (diff)
downloadcdo-34cc0fca811b47cf602855eabd4f43058bf90a89.zip
cdo-34cc0fca811b47cf602855eabd4f43058bf90a89.tar.gz
cdo-34cc0fca811b47cf602855eabd4f43058bf90a89.tar.bz2
[202064] More client-side intelligence (SmartReadAhead Thread)
https://bugs.eclipse.org/bugs/show_bug.cgi?id=202064
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/LoadRevisionIndication.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/FetchRuleAnalyzerTest.java52
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/analyzer/CDOAbstractFeatureRuleAnalyzer.java3
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/analyzer/CDOClusterOfFetchRule.java3
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/analyzer/CDOFeatureAnalyzerModelBased.java3
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/analyzer/CDOFetchFeatureInfo.java3
6 files changed, 49 insertions, 20 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/LoadRevisionIndication.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/LoadRevisionIndication.java
index 44a27a1..6a3b7a9 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/LoadRevisionIndication.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/LoadRevisionIndication.java
@@ -11,6 +11,7 @@
package org.eclipse.emf.cdo.internal.server.protocol;
import org.eclipse.emf.cdo.internal.protocol.CDOIDImpl;
+import org.eclipse.emf.cdo.internal.protocol.CDOIDNull;
import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl;
import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl.MoveableList;
import org.eclipse.emf.cdo.internal.server.RevisionManager;
@@ -47,9 +48,9 @@ public class LoadRevisionIndication extends CDOReadIndication
protected Map<CDOClass, CDOFetchRule> fetchRules = new HashMap<CDOClass, CDOFetchRule>();
- protected CDOID contextID;
+ protected CDOID contextID = CDOIDNull.NULL;
- protected int loadRevisionCollectionChunkSize;
+ protected int loadRevisionCollectionChunkSize = 1;
public LoadRevisionIndication()
{
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/FetchRuleAnalyzerTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/FetchRuleAnalyzerTest.java
index feb8524..c92d712 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/FetchRuleAnalyzerTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/FetchRuleAnalyzerTest.java
@@ -7,25 +7,33 @@
*
* Contributors:
* Simon McDuff - initial API and implementation
+ * Eike Stepper - maintenance
**************************************************************************/
package org.eclipse.emf.cdo.tests;
+import org.eclipse.emf.cdo.CDOObject;
import org.eclipse.emf.cdo.CDOSession;
import org.eclipse.emf.cdo.CDOTransaction;
import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.internal.protocol.model.CDOClassImpl;
+import org.eclipse.emf.cdo.protocol.analyzer.CDOFetchRule;
import org.eclipse.emf.cdo.tests.model1.Company;
import org.eclipse.emf.cdo.tests.model1.Model1Factory;
+import org.eclipse.emf.cdo.tests.model1.Model1Package;
import org.eclipse.emf.cdo.tests.model1.PurchaseOrder;
import org.eclipse.emf.cdo.tests.model1.SalesOrder;
import org.eclipse.emf.cdo.tests.model1.Supplier;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.internal.cdo.CDOSessionImpl;
import org.eclipse.emf.internal.cdo.CDOTransactionImpl;
import org.eclipse.emf.internal.cdo.analyzer.CDOFeatureAnalyzerModelBased;
import org.eclipse.emf.internal.cdo.analyzer.CDOFetchRuleManagerThreadLocal;
+import org.eclipse.emf.internal.cdo.util.ModelUtil;
+
+import java.util.ArrayList;
+import java.util.List;
/**
* @author Eike Stepper
@@ -34,6 +42,8 @@ public class FetchRuleAnalyzerTest extends AbstractCDOTest
{
public void testLoadObject() throws Exception
{
+ ArrayList<CDOObject> listOfCompany = new ArrayList<CDOObject>();
+
{
// disableConsole();
msg("Opening session");
@@ -59,7 +69,8 @@ public class FetchRuleAnalyzerTest extends AbstractCDOTest
Supplier supplier = Model1Factory.eINSTANCE.createSupplier();
// Should it detect supplier to make it persistent...
- // I don't want to do resource.getContents().add(supplier)
+
+ resource.getContents().add(supplier);
purchaseOrder.setSupplier(supplier);
SalesOrder salesOrder = Model1Factory.eINSTANCE.createSalesOrder();
@@ -67,10 +78,11 @@ public class FetchRuleAnalyzerTest extends AbstractCDOTest
}
resource.getContents().add(company);
+ listOfCompany.add(company);
}
transaction.commit();
- // XXX session.close();
+ // session.close();
enableConsole();
}
@@ -87,19 +99,39 @@ public class FetchRuleAnalyzerTest extends AbstractCDOTest
transaction.setLoadRevisionCollectionChunkSize(10);
msg("Getting resource");
- CDOResource resource = transaction.getResource("/test2");
- msg("Getting contents");
- EList<EObject> contents = resource.getContents();
- for (EObject eObject : contents)
+ for (CDOObject companyObject : listOfCompany)
{
- Company company = (Company)eObject;
+ Company company = (Company)transaction.getObject(companyObject.cdoID(), true);
for (PurchaseOrder purchaseOrder : company.getPurchaseOrders())
{
purchaseOrder.getSupplier();
}
+
}
- assertEquals(featureanalyzerModelBased.getFetchCount(), 12);
+ // Number of fetch should be 20.
+ assertEquals(20, featureanalyzerModelBased.getFetchCount());
+
+ List<CDOFetchRule> fetchRules = featureanalyzerModelBased.getFetchRules(null);
+
+ assertEquals(2, fetchRules.size());
+
+ CDOFetchRule fetchRule1 = fetchRules.get(0);
+ EClass eClass = ModelUtil.getEClass((CDOClassImpl)fetchRule1.getCDOClass(), session.getPackageRegistry());
+ assertEquals(Model1Package.eINSTANCE.getCompany(), eClass);
+ assertEquals(1, fetchRule1.getFeatures().size());
+ assertEquals(Model1Package.eINSTANCE.getCompany_PurchaseOrders().getName(), fetchRule1.getFeatures().get(0)
+ .getName());
+
+ CDOFetchRule fetchRule2 = fetchRules.get(1);
+ EClass ePurchaseOrder = ModelUtil.getEClass((CDOClassImpl)fetchRule2.getCDOClass(), session.getPackageRegistry());
+ assertEquals(Model1Package.eINSTANCE.getPurchaseOrder(), ePurchaseOrder);
+ assertEquals(1, fetchRule2.getFeatures().size());
+ assertEquals(Model1Package.eINSTANCE.getPurchaseOrder_Supplier().getName(), fetchRule2.getFeatures().get(0)
+ .getName());
+
+ transaction.close();
+ // TODO session.close();
}
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/analyzer/CDOAbstractFeatureRuleAnalyzer.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/analyzer/CDOAbstractFeatureRuleAnalyzer.java
index 523ebae..46a7af4 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/analyzer/CDOAbstractFeatureRuleAnalyzer.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/analyzer/CDOAbstractFeatureRuleAnalyzer.java
@@ -39,9 +39,6 @@ public abstract class CDOAbstractFeatureRuleAnalyzer implements CDOFeatureAnalyz
protected int loadRevisionCollectionChunkSize;
- /**
- * TODO Can didFetch be derived from fetchCount?
- */
private boolean didFetch;
private int fetchCount = 0;
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/analyzer/CDOClusterOfFetchRule.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/analyzer/CDOClusterOfFetchRule.java
index b044e30..1a83e04 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/analyzer/CDOClusterOfFetchRule.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/analyzer/CDOClusterOfFetchRule.java
@@ -52,8 +52,7 @@ public class CDOClusterOfFetchRule
@Override
public int hashCode()
{
- // TODO Missing "rootClass.hashCode() ^ " or intention?
- return rootFeature.hashCode();
+ return rootClass.hashCode() ^ rootFeature.hashCode();
}
@Override
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/analyzer/CDOFeatureAnalyzerModelBased.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/analyzer/CDOFeatureAnalyzerModelBased.java
index 2cdfd89..331bbd7 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/analyzer/CDOFeatureAnalyzerModelBased.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/analyzer/CDOFeatureAnalyzerModelBased.java
@@ -11,6 +11,7 @@
**************************************************************************/
package org.eclipse.emf.internal.cdo.analyzer;
+import org.eclipse.emf.cdo.internal.protocol.CDOIDNull;
import org.eclipse.emf.cdo.protocol.CDOID;
import org.eclipse.emf.cdo.protocol.analyzer.CDOFetchRule;
import org.eclipse.emf.cdo.protocol.model.CDOFeature;
@@ -48,7 +49,7 @@ public class CDOFeatureAnalyzerModelBased extends CDOAbstractFeatureRuleAnalyzer
public CDOID getContext()
{
- return null;
+ return CDOIDNull.NULL;
}
public List<CDOFetchRule> getFetchRules(Collection<CDOID> ids)
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/analyzer/CDOFetchFeatureInfo.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/analyzer/CDOFetchFeatureInfo.java
index 69f4c92..ef730c0 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/analyzer/CDOFetchFeatureInfo.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/analyzer/CDOFetchFeatureInfo.java
@@ -104,8 +104,7 @@ public class CDOFetchFeatureInfo
@Override
public int hashCode()
{
- // TODO Missing "cdoClass.hashCode() ^ " or intention?
- return cdoFeature.hashCode();
+ return cdoClass.hashCode() ^ cdoFeature.hashCode();
}
@Override