summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-09-02 07:03:35 (EDT)
committerEike Stepper2007-09-02 07:03:35 (EDT)
commit309091f31d3b97192d71bdeebaab71b31492069b (patch)
tree6789daa8f65ea1ca8aac64e2a1994f186caa3f94
parent1792eded85f2b687538dcf553418fd0dfa313771 (diff)
downloadcdo-309091f31d3b97192d71bdeebaab71b31492069b.zip
cdo-309091f31d3b97192d71bdeebaab71b31492069b.tar.gz
cdo-309091f31d3b97192d71bdeebaab71b31492069b.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.server/src/org/eclipse/emf/cdo/internal/server/RevisionManager.java18
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/LoadChunkIndication.java26
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/LoadRevisionIndication.java2
-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/CDORevisionManagerImpl.java79
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java6
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionRequest.java2
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/LoadChunkRequest.java35
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/LoadRevisionRequest.java2
9 files changed, 100 insertions, 72 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/RevisionManager.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/RevisionManager.java
index 8b68c91..5328dc3 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/RevisionManager.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/RevisionManager.java
@@ -13,9 +13,7 @@ package org.eclipse.emf.cdo.internal.server;
import org.eclipse.emf.cdo.internal.protocol.model.resource.CDOPathFeatureImpl;
import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl;
import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionResolverImpl;
-import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl.MoveableList;
import org.eclipse.emf.cdo.protocol.CDOID;
-import org.eclipse.emf.cdo.protocol.model.CDOFeature;
import org.eclipse.emf.cdo.protocol.revision.CDOReferenceProxy;
import org.eclipse.emf.cdo.server.IRevisionManager;
import org.eclipse.emf.cdo.server.IStoreReader;
@@ -117,20 +115,4 @@ public class RevisionManager extends CDORevisionResolverImpl implements IRevisio
{
}
}
-
- public CDOID[] getReferenceChunk(CDOID id, CDOFeature feature, int fromIndex, int toIndex)
- {
- int size = toIndex - fromIndex + 1;
- CDOID[] ids = new CDOID[size];
-
- CDORevisionImpl revision = getRevision(id, CDORevisionImpl.COMPLETE_REFERENCES);
- MoveableList list = revision.getList(feature);
-
- for (int i = 0; i < size; i++)
- {
- ids[i] = (CDOID)list.get(fromIndex + i);
- }
-
- return ids;
- }
}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/LoadChunkIndication.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/LoadChunkIndication.java
index 1daddb8..1db68e8 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/LoadChunkIndication.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/LoadChunkIndication.java
@@ -12,6 +12,8 @@ package org.eclipse.emf.cdo.internal.server.protocol;
import org.eclipse.emf.cdo.internal.protocol.CDOIDImpl;
import org.eclipse.emf.cdo.internal.protocol.model.CDOClassRefImpl;
+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.bundle.OM;
import org.eclipse.emf.cdo.protocol.CDOID;
import org.eclipse.emf.cdo.protocol.CDOProtocolConstants;
@@ -32,7 +34,13 @@ public class LoadChunkIndication extends CDOReadIndication
{
private static final ContextTracer PROTOCOL = new ContextTracer(OM.DEBUG_PROTOCOL, LoadChunkIndication.class);
- private CDOID[] ids;
+ private CDOID id;
+
+ private CDOFeature feature;
+
+ private int fromIndex;
+
+ private int toIndex;
public LoadChunkIndication()
{
@@ -42,30 +50,30 @@ public class LoadChunkIndication extends CDOReadIndication
@Override
protected void indicating(ExtendedDataInputStream in) throws IOException
{
- CDOID id = CDOIDImpl.read(in);
+ id = CDOIDImpl.read(in);
if (PROTOCOL.isEnabled()) PROTOCOL.format("Read ID: {0}", id);
CDOClassRef classRef = new CDOClassRefImpl(in, null);
int featureID = in.readInt();
CDOClass cdoClass = classRef.resolve(getPackageManager());
- CDOFeature feature = cdoClass.lookupFeature(featureID);
+ feature = cdoClass.lookupFeature(featureID);
if (PROTOCOL.isEnabled()) PROTOCOL.format("Read feature: {0}", feature);
- int fromIndex = in.readInt();
+ fromIndex = in.readInt();
if (PROTOCOL.isEnabled()) PROTOCOL.format("Read fromIndex: {0}", fromIndex);
- int toIndex = in.readInt();
+ toIndex = in.readInt();
if (PROTOCOL.isEnabled()) PROTOCOL.format("Read toIndex: {0}", toIndex);
-
- ids = getRevisionManager().getReferenceChunk(id, feature, fromIndex, toIndex);
}
@Override
protected void responding(ExtendedDataOutputStream out) throws IOException
{
- for (CDOID id : ids)
+ CDORevisionImpl revision = getRevisionManager().getRevision(id, CDORevisionImpl.UNCHUNKED);
+ MoveableList list = revision.getList(feature);
+ for (int i = fromIndex; i <= toIndex; i++)
{
- CDOIDImpl.write(out, id);
+ CDOIDImpl.write(out, (CDOID)list.get(i));
}
}
}
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 8b790c4..6d282e5 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
@@ -63,7 +63,7 @@ public class LoadRevisionIndication extends CDOReadIndication
PROTOCOL.format("Read ID: {0}", id);
}
- referenceChunk = CDORevisionImpl.COMPLETE_REFERENCES;
+ referenceChunk = CDORevisionImpl.UNCHUNKED;
}
boolean historical = in.readBoolean();
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 401089e..5f7051f 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 = "testWriteNative";
+ private static final String METHOD_NAME = "testReadNative";
public static void main(String[] args) throws Throwable
{
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDORevisionManagerImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDORevisionManagerImpl.java
index ddc5bbb..d972dca 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDORevisionManagerImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDORevisionManagerImpl.java
@@ -44,46 +44,73 @@ public class CDORevisionManagerImpl extends CDORevisionResolverImpl implements C
public CDOID resolveReferenceProxy(CDOReferenceProxy referenceProxy)
{
+ // Get proxy values
CDORevisionImpl revision = (CDORevisionImpl)referenceProxy.getRevision();
CDOFeature feature = referenceProxy.getFeature();
- int index = referenceProxy.getIndex();
+ int accessIndex = referenceProxy.getIndex();
+ // Get appropriate chunk size
int chunkSize = session.getReferenceChunkSize();
- MoveableList list = revision.getList(feature);
-
- int minIndex = Math.max(0, index - chunkSize / 2);
- int fromIndex = index;
- while (fromIndex > minIndex && list.get(fromIndex) instanceof CDOReferenceProxy)
+ if (chunkSize == CDORevisionImpl.UNCHUNKED)
{
- --fromIndex;
+ // Can happen if CDOSession.setReferenceChunkSize() was called meanwhile
+ chunkSize = Integer.MAX_VALUE;
}
- int maxIndex = Math.min(list.size() - 1, index + chunkSize / 2);
- int toIndex = index;
- while (toIndex < maxIndex && list.get(toIndex) instanceof CDOReferenceProxy)
+ MoveableList list = revision.getList(feature);
+ int size = list.size();
+ int fromIndex = accessIndex;
+ int toIndex = accessIndex;
+ boolean minReached = false;
+ boolean maxReached = false;
+ boolean alternation = false;
+ for (int i = 0; i < chunkSize; i++)
{
- ++toIndex;
- }
+ if (alternation)
+ {
+ if (!maxReached && toIndex < size - 1 && list.get(toIndex + 1) instanceof CDOReferenceProxy)
+ {
+ ++toIndex;
+ }
+ else
+ {
+ maxReached = true;
+ }
- try
- {
- CDOID result = null;
- IFailOverStrategy failOverStrategy = session.getFailOverStrategy();
- IChannel channel = session.getChannel();
- LoadChunkRequest request = new LoadChunkRequest(channel, revision.getID(), feature, fromIndex, toIndex);
- CDOID[] ids = failOverStrategy.send(request);
- for (int i = 0; i < ids.length; i++)
+ if (!minReached)
+ {
+ alternation = false;
+ }
+ }
+ else
{
- CDOID id = ids[i];
- int j = fromIndex + i;
- list.set(j, id);
- if (j == index)
+ if (!minReached && fromIndex > 0 && list.get(fromIndex - 1) instanceof CDOReferenceProxy)
+ {
+ --fromIndex;
+ }
+ else
+ {
+ minReached = true;
+ }
+
+ if (!maxReached)
{
- result = id;
+ alternation = true;
}
}
- return result;
+ if (minReached && maxReached)
+ {
+ break;
+ }
+ }
+
+ try
+ {
+ IFailOverStrategy failOverStrategy = session.getFailOverStrategy();
+ IChannel channel = session.getChannel();
+ LoadChunkRequest request = new LoadChunkRequest(channel, revision, feature, accessIndex, fromIndex, toIndex);
+ return failOverStrategy.send(request);
}
catch (RuntimeException ex)
{
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java
index 4fbedf9..25e30f7 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java
@@ -76,7 +76,7 @@ public class CDOSessionImpl extends Container<CDOView> implements CDOSession
private int sessionID;
- private int referenceChunkSize = CDORevisionImpl.COMPLETE_REFERENCES;
+ private int referenceChunkSize = CDORevisionImpl.UNCHUNKED;
private IFailOverStrategy failOverStrategy;
@@ -144,9 +144,9 @@ public class CDOSessionImpl extends Container<CDOView> implements CDOSession
public void setReferenceChunkSize(int referenceChunkSize)
{
- if (referenceChunkSize < 0)
+ if (referenceChunkSize <= 0)
{
- referenceChunkSize = CDORevisionImpl.COMPLETE_REFERENCES;
+ referenceChunkSize = CDORevisionImpl.UNCHUNKED;
}
this.referenceChunkSize = referenceChunkSize;
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionRequest.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionRequest.java
index ac7a3d6..bc1b7a3 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionRequest.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionRequest.java
@@ -113,7 +113,7 @@ public class CommitTransactionRequest extends CDOClientRequest<CommitTransaction
{
InternalCDOObject object = (InternalCDOObject)it.next();
CDORevisionImpl revision = (CDORevisionImpl)object.cdoRevision();
- revision.write(out, transaction, CDORevisionImpl.COMPLETE_REFERENCES);
+ revision.write(out, transaction, CDORevisionImpl.UNCHUNKED);
}
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/LoadChunkRequest.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/LoadChunkRequest.java
index b7ebccf..af66cea 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/LoadChunkRequest.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/LoadChunkRequest.java
@@ -12,6 +12,8 @@ package org.eclipse.emf.internal.cdo.protocol;
import org.eclipse.emf.cdo.internal.protocol.CDOIDImpl;
import org.eclipse.emf.cdo.internal.protocol.model.CDOClassRefImpl;
+import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl;
+import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl.MoveableList;
import org.eclipse.emf.cdo.protocol.CDOID;
import org.eclipse.emf.cdo.protocol.CDOProtocolConstants;
import org.eclipse.emf.cdo.protocol.model.CDOFeature;
@@ -28,23 +30,27 @@ import java.io.IOException;
/**
* @author Eike Stepper
*/
-public class LoadChunkRequest extends CDOClientRequest<CDOID[]>
+public class LoadChunkRequest extends CDOClientRequest<CDOID>
{
private static final ContextTracer PROTOCOL = new ContextTracer(OM.DEBUG_PROTOCOL, LoadChunkRequest.class);
- private CDOID id;
+ private CDORevisionImpl revision;
private CDOFeature feature;
+ private int accessIndex;
+
private int fromIndex;
private int toIndex;
- public LoadChunkRequest(IChannel channel, CDOID id, CDOFeature feature, int fromIndex, int toIndex)
+ public LoadChunkRequest(IChannel channel, CDORevisionImpl revision, CDOFeature feature, int accessIndex,
+ int fromIndex, int toIndex)
{
super(channel, CDOProtocolConstants.SIGNAL_LOAD_CHUNK);
- this.id = id;
+ this.revision = revision;
this.feature = feature;
+ this.accessIndex = accessIndex;
this.fromIndex = fromIndex;
this.toIndex = toIndex;
}
@@ -52,8 +58,8 @@ public class LoadChunkRequest extends CDOClientRequest<CDOID[]>
@Override
protected void requesting(ExtendedDataOutputStream out) throws IOException
{
- if (PROTOCOL.isEnabled()) PROTOCOL.format("Writing ID: {0}", id);
- CDOIDImpl.write(out, id);
+ if (PROTOCOL.isEnabled()) PROTOCOL.format("Writing revision ID: {0}", revision.getID());
+ CDOIDImpl.write(out, revision.getID());
if (PROTOCOL.isEnabled()) PROTOCOL.format("Writing feature: {0}", feature);
CDOClassRefImpl classRef = (CDOClassRefImpl)feature.getContainingClass().createClassRef();
@@ -68,15 +74,20 @@ public class LoadChunkRequest extends CDOClientRequest<CDOID[]>
}
@Override
- protected CDOID[] confirming(ExtendedDataInputStream in) throws IOException
+ protected CDOID confirming(ExtendedDataInputStream in) throws IOException
{
- int size = toIndex - fromIndex + 1;
- CDOID[] ids = new CDOID[size];
- for (int i = 0; i < ids.length; i++)
+ CDOID accessID = null;
+ MoveableList list = revision.getList(feature);
+ for (int i = fromIndex; i <= toIndex; i++)
{
- ids[i] = CDOIDImpl.read(in);
+ CDOID id = CDOIDImpl.read(in);
+ list.set(i, id);
+ if (i == accessIndex)
+ {
+ accessID = id;
+ }
}
- return ids;
+ return accessID;
}
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/LoadRevisionRequest.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/LoadRevisionRequest.java
index 0ff9d29..6ad052b 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/LoadRevisionRequest.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/LoadRevisionRequest.java
@@ -56,7 +56,7 @@ public class LoadRevisionRequest extends CDOClientRequest<CDORevisionImpl>
@Override
protected void requesting(ExtendedDataOutputStream out) throws IOException
{
- if (referenceChunk == CDORevisionImpl.COMPLETE_REFERENCES)
+ if (referenceChunk == CDORevisionImpl.UNCHUNKED)
{
if (PROTOCOL.isEnabled())
{