summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-09-01 16:32:32 (EDT)
committerEike Stepper2007-09-01 16:32:32 (EDT)
commit1792eded85f2b687538dcf553418fd0dfa313771 (patch)
tree00842c18bc77929730dd9f9c07ea90b399f17f86
parent3f7dd7d7468616808a0a5bf26995cc2763dace7f (diff)
downloadcdo-1792eded85f2b687538dcf553418fd0dfa313771.zip
cdo-1792eded85f2b687538dcf553418fd0dfa313771.tar.gz
cdo-1792eded85f2b687538dcf553418fd0dfa313771.tar.bz2
[201265] Handling large Collection by having them in chunk
https://bugs.eclipse.org/bugs/show_bug.cgi?id=201265
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.model1/model/model1.ecore4
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.model1/src/org/eclipse/emf/cdo/tests/model1/impl/Model1PackageImpl.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ChunkingTest.java57
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/TDD.java2
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStore.java13
5 files changed, 67 insertions, 11 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests.model1/model/model1.ecore b/plugins/org.eclipse.emf.cdo.tests.model1/model/model1.ecore
index 2288e23..1c90dd2 100644
--- a/plugins/org.eclipse.emf.cdo.tests.model1/model/model1.ecore
+++ b/plugins/org.eclipse.emf.cdo.tests.model1/model/model1.ecore
@@ -25,8 +25,8 @@
eType="#//PurchaseOrder" eOpposite="#//PurchaseOrder/supplier"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Customer" eSuperTypes="#//Address">
- <eStructuralFeatures xsi:type="ecore:EReference" name="salesOrders" upperBound="-1"
- eType="#//SalesOrder" eOpposite="#//SalesOrder/customer"/>
+ <eStructuralFeatures xsi:type="ecore:EReference" name="salesOrders" unique="false"
+ upperBound="-1" eType="#//SalesOrder" eOpposite="#//SalesOrder/customer"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Order">
<eStructuralFeatures xsi:type="ecore:EReference" name="orderDetails" upperBound="-1"
diff --git a/plugins/org.eclipse.emf.cdo.tests.model1/src/org/eclipse/emf/cdo/tests/model1/impl/Model1PackageImpl.java b/plugins/org.eclipse.emf.cdo.tests.model1/src/org/eclipse/emf/cdo/tests/model1/impl/Model1PackageImpl.java
index 86b17ea..4a1571e 100644
--- a/plugins/org.eclipse.emf.cdo.tests.model1/src/org/eclipse/emf/cdo/tests/model1/impl/Model1PackageImpl.java
+++ b/plugins/org.eclipse.emf.cdo.tests.model1/src/org/eclipse/emf/cdo/tests/model1/impl/Model1PackageImpl.java
@@ -647,7 +647,7 @@ public class Model1PackageImpl extends EPackageImpl implements Model1Package
initEClass(customerEClass, Customer.class, "Customer", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
initEReference(getCustomer_SalesOrders(), this.getSalesOrder(), this.getSalesOrder_Customer(), "salesOrders", null,
0, -1, Customer.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES,
- !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+ !IS_UNSETTABLE, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEClass(orderEClass, Order.class, "Order", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
initEReference(getOrder_OrderDetails(), this.getOrderDetail(), this.getOrderDetail_Order(), "orderDetails", null,
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ChunkingTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ChunkingTest.java
index 1be8eab..d08b8eb 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ChunkingTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ChunkingTest.java
@@ -27,7 +27,7 @@ import java.util.Iterator;
*/
public class ChunkingTest extends AbstractCDOTest
{
- public void testNativeObjects() throws Exception
+ public void testReadNative() throws Exception
{
{
msg("Opening session");
@@ -79,4 +79,59 @@ public class ChunkingTest extends AbstractCDOTest
System.out.println(salesOrder);
}
}
+
+ public void testWriteNative() throws Exception
+ {
+ {
+ msg("Opening session");
+ CDOSession session = openModel1Session();
+
+ msg("Attaching transaction");
+ CDOTransaction transaction = session.openTransaction(new ResourceSetImpl());
+
+ msg("Creating resource");
+ CDOResource resource = transaction.createResource("/test1");
+
+ msg("Creating customer");
+ Customer customer = Model1Factory.eINSTANCE.createCustomer();
+ customer.setName("customer");
+ resource.getContents().add(customer);
+
+ for (int i = 0; i < 100; i++)
+ {
+ msg("Creating salesOrder" + i);
+ SalesOrder salesOrder = Model1Factory.eINSTANCE.createSalesOrder();
+ salesOrder.setId(i);
+ salesOrder.setCustomer(customer);
+ resource.getContents().add(salesOrder);
+ }
+
+ msg("Committing");
+ transaction.commit();
+ }
+
+ // ************************************************************* //
+
+ msg("Opening session");
+ CDOSession session = openModel1Session();
+ session.setReferenceChunkSize(10);
+
+ msg("Attaching transaction");
+ CDOTransaction transaction = session.openTransaction(new ResourceSetImpl());
+
+ msg("Loading resource");
+ CDOResource resource = transaction.getResource("/test1");
+
+ Customer customer = (Customer)resource.getContents().get(0);
+ EList<SalesOrder> salesOrders = customer.getSalesOrders();
+ for (int i = 50; i < 70; i++)
+ {
+ SalesOrder salesOrder = Model1Factory.eINSTANCE.createSalesOrder();
+ salesOrder.setId(i + 1000);
+ resource.getContents().add(salesOrder);
+ salesOrders.set(i, salesOrder);
+ }
+
+ transaction.commit();
+ }
}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/TDD.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/TDD.java
index 83786dd..401089e 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/TDD.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/TDD.java
@@ -22,7 +22,7 @@ public class TDD
{
private static final AbstractOMTest test = new ChunkingTest();
- private static final String METHOD_NAME = "testNativeObjects";
+ private static final String METHOD_NAME = "testWriteNative";
public static void main(String[] args) throws Throwable
{
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStore.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStore.java
index f75287d..8374611 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStore.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStore.java
@@ -265,8 +265,15 @@ public final class CDOStore implements EStore
TRACER.format("set({0}, {1}, {2}, {3})", cdoObject, cdoFeature, index, value);
}
+ CDORevisionImpl revision = getRevisionForWriting(cdoObject);
if (cdoFeature.isReference())
{
+ Object oldValue = revision.get(cdoFeature, index);
+ if (oldValue instanceof CDOReferenceProxy)
+ {
+ ((CDOReferenceProxy)oldValue).resolve();
+ }
+
if (cdoFeature.isContainment())
{
handleContainmentAdd(cdoObject, cdoFeature, value);
@@ -275,15 +282,9 @@ public final class CDOStore implements EStore
value = ((CDOViewImpl)cdoObject.cdoView()).convertObjectToID(value);
}
- CDORevisionImpl revision = getRevisionForWriting(cdoObject);
Object result = revision.set(cdoFeature, index, value);
if (cdoFeature.isReference())
{
- if (result instanceof CDOReferenceProxy)
- {
- result = ((CDOReferenceProxy)result).resolve();
- }
-
result = ((CDOViewImpl)cdoObject.cdoView()).convertIDToObject(result);
}