summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-09-06 06:08:52 (EDT)
committerEike Stepper2007-09-06 06:08:52 (EDT)
commited7c4a3c38c0e185bbf345e1d854a875f4a605a9 (patch)
treedeb37f53bdfbd5a6f1c5f9717336123efe6cc2c3
parent6c9713c15f90684532a3dbabdc1165d611c14d8b (diff)
downloadcdo-ed7c4a3c38c0e185bbf345e1d854a875f4a605a9.zip
cdo-ed7c4a3c38c0e185bbf345e1d854a875f4a605a9.tar.gz
cdo-ed7c4a3c38c0e185bbf345e1d854a875f4a605a9.tar.bz2
[201265] Handling large collections by loading CDOIDs in chunks
https://bugs.eclipse.org/bugs/show_bug.cgi?id=201265
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IDBStoreAccessor.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IDBStoreChunkReader.java21
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IReferenceMapping.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java7
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreChunkReader.java86
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/MappingStrategy.java8
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ReferenceMapping.java78
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ValueMapping.java13
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/RevisionManager.java114
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/StoreChunkReader.java70
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreChunkReader.java99
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreReader.java3
12 files changed, 502 insertions, 4 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IDBStoreAccessor.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IDBStoreAccessor.java
index 7483b8c..c849826 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IDBStoreAccessor.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IDBStoreAccessor.java
@@ -22,6 +22,8 @@ import java.sql.Statement;
*/
public interface IDBStoreAccessor extends IStoreReader, IStoreWriter
{
+ public IDBStore getStore();
+
public Connection getConnection();
public Statement getStatement();
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IDBStoreChunkReader.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IDBStoreChunkReader.java
new file mode 100644
index 0000000..873c8be
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IDBStoreChunkReader.java
@@ -0,0 +1,21 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2007 Eike Stepper, Germany.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ **************************************************************************/
+package org.eclipse.emf.cdo.server.db;
+
+import org.eclipse.emf.cdo.server.IStoreChunkReader;
+
+/**
+ * @author Eike Stepper
+ */
+public interface IDBStoreChunkReader extends IStoreChunkReader
+{
+ public IDBStoreAccessor getStoreAccessor();
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IReferenceMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IReferenceMapping.java
index 9cd08b6..2d3d95b 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IReferenceMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IReferenceMapping.java
@@ -12,9 +12,12 @@ package org.eclipse.emf.cdo.server.db;
import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl;
import org.eclipse.emf.cdo.protocol.model.CDOFeature;
+import org.eclipse.emf.cdo.server.IStoreChunkReader.Chunk;
import org.eclipse.net4j.db.IDBTable;
+import java.util.List;
+
/**
* @author Eike Stepper
*/
@@ -27,4 +30,6 @@ public interface IReferenceMapping
public void writeReference(IDBStoreAccessor storeAccessor, CDORevisionImpl revision);
public void readReference(IDBStoreAccessor storeAccessor, CDORevisionImpl revision);
+
+ public void readChunks(IDBStoreChunkReader chunkReader, List<Chunk> chunks, String string);
}
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java
index 3186e8e..c8ed97b 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java
@@ -21,6 +21,7 @@ import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl;
import org.eclipse.emf.cdo.protocol.CDOID;
import org.eclipse.emf.cdo.protocol.CDOIDRange;
import org.eclipse.emf.cdo.protocol.model.CDOClassRef;
+import org.eclipse.emf.cdo.protocol.model.CDOFeature;
import org.eclipse.emf.cdo.protocol.model.CDOPackageInfo;
import org.eclipse.emf.cdo.protocol.model.CDOType;
import org.eclipse.emf.cdo.protocol.revision.CDORevision;
@@ -28,6 +29,7 @@ import org.eclipse.emf.cdo.server.IPackageManager;
import org.eclipse.emf.cdo.server.IRepository;
import org.eclipse.emf.cdo.server.IRevisionManager;
import org.eclipse.emf.cdo.server.ISession;
+import org.eclipse.emf.cdo.server.IStoreChunkReader;
import org.eclipse.emf.cdo.server.IView;
import org.eclipse.emf.cdo.server.db.IDBStoreAccessor;
import org.eclipse.emf.cdo.server.db.IMapping;
@@ -165,6 +167,11 @@ public class DBStoreAccessor implements IDBStoreAccessor
return statement;
}
+ public IStoreChunkReader createChunkReader(CDORevision revision, CDOFeature feature)
+ {
+ return new DBStoreChunkReader(this, revision, feature);
+ }
+
public void writePackages(CDOPackageImpl... cdoPackages)
{
for (CDOPackageImpl cdoPackage : cdoPackages)
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreChunkReader.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreChunkReader.java
new file mode 100644
index 0000000..8629ef3
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreChunkReader.java
@@ -0,0 +1,86 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2007 Eike Stepper, Germany.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ **************************************************************************/
+package org.eclipse.emf.cdo.server.internal.db;
+
+import org.eclipse.emf.cdo.internal.server.StoreChunkReader;
+import org.eclipse.emf.cdo.protocol.model.CDOClass;
+import org.eclipse.emf.cdo.protocol.model.CDOFeature;
+import org.eclipse.emf.cdo.protocol.revision.CDORevision;
+import org.eclipse.emf.cdo.server.db.IDBStoreAccessor;
+import org.eclipse.emf.cdo.server.db.IDBStoreChunkReader;
+import org.eclipse.emf.cdo.server.db.IMapping;
+import org.eclipse.emf.cdo.server.db.IMappingStrategy;
+import org.eclipse.emf.cdo.server.db.IReferenceMapping;
+
+import org.eclipse.net4j.util.ImplementationError;
+
+import java.util.List;
+
+/**
+ * @author Eike Stepper
+ */
+public class DBStoreChunkReader extends StoreChunkReader implements IDBStoreChunkReader
+{
+ private IReferenceMapping referenceMapping;
+
+ private StringBuilder builder = new StringBuilder();
+
+ public DBStoreChunkReader(IDBStoreAccessor storeAccessor, CDORevision revision, CDOFeature feature)
+ {
+ super(storeAccessor, revision, feature);
+ IMappingStrategy mappingStrategy = storeAccessor.getStore().getMappingStrategy();
+ CDOClass cdoClass = revision.getCDOClass();
+ IMapping mapping = mappingStrategy.getMapping(cdoClass);
+ if (mapping instanceof ValueMapping)
+ {
+ referenceMapping = ((ValueMapping)mapping).getReferenceMapping(feature);
+ }
+ else
+ {
+ throw new ImplementationError();
+ }
+ }
+
+ @Override
+ public IDBStoreAccessor getStoreAccessor()
+ {
+ return (IDBStoreAccessor)super.getStoreAccessor();
+ }
+
+ @Override
+ public void addSimpleChunk(int index)
+ {
+ super.addSimpleChunk(index);
+ builder.append(" AND ");
+ builder.append(ReferenceMapping.FIELD_NAME_IDX);
+ builder.append("=");
+ builder.append(index);
+ }
+
+ @Override
+ public void addRangedChunk(int fromIndex, int toIndex)
+ {
+ super.addRangedChunk(fromIndex, toIndex);
+ builder.append(" AND ");
+ builder.append(ReferenceMapping.FIELD_NAME_IDX);
+ builder.append(" BETWEEN ");
+ builder.append(fromIndex);
+ builder.append(" AND ");
+ builder.append(toIndex);
+ }
+
+ public List<Chunk> executeRead()
+ {
+ List<Chunk> chunks = getChunks();
+ referenceMapping.readChunks(this, chunks, builder.toString());
+ return chunks;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/MappingStrategy.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/MappingStrategy.java
index fad44e2..778cea7 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/MappingStrategy.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/MappingStrategy.java
@@ -19,6 +19,7 @@ import org.eclipse.emf.cdo.server.db.IMapping;
import org.eclipse.emf.cdo.server.db.IMappingStrategy;
import org.eclipse.net4j.db.DBException;
+import org.eclipse.net4j.db.DBUtil;
import org.eclipse.net4j.db.IDBTable;
import org.eclipse.net4j.util.io.CloseableIterator;
@@ -199,10 +200,11 @@ public abstract class MappingStrategy implements IMappingStrategy
if (table != null)
{
String sql = prefix + table + suffix;
+ ResultSet resultSet = null;
try
{
- ResultSet resultSet = storeAccessor.getStatement().executeQuery(sql);
+ resultSet = storeAccessor.getStatement().executeQuery(sql);
if (resultSet.next())
{
int classID = resultSet.getInt(1);
@@ -213,6 +215,10 @@ public abstract class MappingStrategy implements IMappingStrategy
{
throw new DBException(ex);
}
+ finally
+ {
+ DBUtil.close(resultSet);
+ }
}
}
}
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ReferenceMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ReferenceMapping.java
index 6a91e29..bb6601f 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ReferenceMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ReferenceMapping.java
@@ -1,17 +1,25 @@
package org.eclipse.emf.cdo.server.internal.db;
+import org.eclipse.emf.cdo.internal.protocol.CDOIDImpl;
import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl;
import org.eclipse.emf.cdo.protocol.CDOID;
import org.eclipse.emf.cdo.protocol.model.CDOClass;
import org.eclipse.emf.cdo.protocol.model.CDOFeature;
import org.eclipse.emf.cdo.protocol.model.CDOPackage;
import org.eclipse.emf.cdo.server.IRepository;
+import org.eclipse.emf.cdo.server.IStoreChunkReader.Chunk;
import org.eclipse.emf.cdo.server.db.IDBStoreAccessor;
+import org.eclipse.emf.cdo.server.db.IDBStoreChunkReader;
import org.eclipse.emf.cdo.server.db.IReferenceMapping;
+import org.eclipse.net4j.db.DBException;
import org.eclipse.net4j.db.DBType;
+import org.eclipse.net4j.db.DBUtil;
import org.eclipse.net4j.db.IDBTable;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.List;
import java.util.Map;
/**
@@ -89,6 +97,76 @@ public class ReferenceMapping extends FeatureMapping implements IReferenceMappin
throw new UnsupportedOperationException("Not yet implemented");
}
+ public void readChunks(IDBStoreChunkReader chunkReader, List<Chunk> chunks, String where)
+ {
+ IDBStoreAccessor storeAccessor = chunkReader.getStoreAccessor();
+ CDOID source = chunkReader.getRevision().getID();
+ int version = chunkReader.getRevision().getVersion();
+ CDOFeature feature = chunkReader.getFeature();
+
+ StringBuilder builder = new StringBuilder();
+ builder.append("SELECT ");
+ builder.append(FIELD_NAME_TARGET);
+ builder.append(" FROM ");
+ builder.append(table);
+ builder.append(" WHERE ");
+ if (withFeature)
+ {
+ builder.append(FIELD_NAME_FEATURE);
+ builder.append("=");
+ builder.append(FeatureServerInfo.getDBID(feature));
+ }
+
+ builder.append(" AND ");
+ builder.append(FIELD_NAME_SOURCE);
+ builder.append("=");
+ builder.append(source.getValue());
+ builder.append(" AND ");
+ builder.append(FIELD_NAME_VERSION);
+ builder.append("=");
+ builder.append(version);
+ builder.append(where);
+ builder.append(" ORDER BY ");
+ builder.append(FIELD_NAME_IDX);
+
+ String sql = builder.toString();
+ ResultSet resultSet = null;
+
+ try
+ {
+ Chunk chunk = null;
+ int chunkSize = 0;
+ int chunkIndex = 0;
+ int indexInChunk = 0;
+
+ resultSet = storeAccessor.getStatement().executeQuery(sql);
+ while (resultSet.next())
+ {
+ long target = resultSet.getLong(1);
+ if (chunk == null)
+ {
+ chunk = chunks.get(chunkIndex++);
+ chunkSize = chunk.size();
+ }
+
+ chunk.addID(indexInChunk++, CDOIDImpl.create(target));
+ if (indexInChunk == chunkSize)
+ {
+ chunk = null;
+ indexInChunk = 0;
+ }
+ }
+ }
+ catch (SQLException ex)
+ {
+ throw new DBException(ex);
+ }
+ finally
+ {
+ DBUtil.close(resultSet);
+ }
+ }
+
protected void mapReference(CDOClass cdoClass, CDOFeature cdoFeature)
{
switch (toMany)
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ValueMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ValueMapping.java
index fe71a55..1db9dec 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ValueMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ValueMapping.java
@@ -55,6 +55,19 @@ public abstract class ValueMapping extends Mapping
return referenceMappings;
}
+ public IReferenceMapping getReferenceMapping(CDOFeature feature)
+ {
+ for (IReferenceMapping referenceMapping : referenceMappings)
+ {
+ if (referenceMapping.getFeature() == feature)
+ {
+ return referenceMapping;
+ }
+ }
+
+ return null;
+ }
+
public void writeRevision(IDBStoreAccessor storeAccessor, CDORevisionImpl revision)
{
if (attributeMappings != null)
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 a26811a..5077568 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
@@ -10,15 +10,21 @@
**************************************************************************/
package org.eclipse.emf.cdo.internal.server;
+import org.eclipse.emf.cdo.internal.protocol.model.CDOClassImpl;
import org.eclipse.emf.cdo.internal.protocol.model.CDOClassRefImpl;
+import org.eclipse.emf.cdo.internal.protocol.model.CDOFeatureImpl;
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.IStoreChunkReader;
import org.eclipse.emf.cdo.server.IStoreReader;
import org.eclipse.emf.cdo.server.IStoreWriter;
+import org.eclipse.emf.cdo.server.IStoreChunkReader.Chunk;
import org.eclipse.net4j.util.transaction.ITransaction;
import org.eclipse.net4j.util.transaction.ITransactionalOperation;
@@ -64,18 +70,120 @@ public class RevisionManager extends CDORevisionResolverImpl implements IRevisio
}
@Override
- protected CDORevisionImpl verifyRevision(CDORevisionImpl revision)
+ protected CDORevisionImpl verifyRevision(CDORevisionImpl revision, int referenceChunk)
{
- revision = super.verifyRevision(revision);
+ IStoreReader storeReader = null;
+ revision = super.verifyRevision(revision, referenceChunk);
if (repository.isVerifyingRevisions())
{
- IStoreReader storeReader = StoreUtil.getReader();
+ storeReader = StoreUtil.getReader();
revision = storeReader.verifyRevision(revision);
}
+ ensureChunks(revision, referenceChunk, storeReader);
return revision;
}
+ protected void ensureChunks(CDORevisionImpl revision, int referenceChunk, IStoreReader storeReader)
+ {
+ CDOClassImpl cdoClass = revision.getCDOClass();
+ CDOFeatureImpl[] features = cdoClass.getAllFeatures();
+ for (int i = 0; i < features.length; i++)
+ {
+ CDOFeatureImpl feature = features[i];
+ if (feature.isReference() && feature.isMany())
+ {
+ MoveableList list = revision.getList(feature);
+ int chunkEnd = Math.min(referenceChunk, list.size());
+ storeReader = ensureChunk(revision, feature, storeReader, list, 0, chunkEnd);
+ }
+ }
+ }
+
+ protected IStoreReader ensureChunk(CDORevisionImpl revision, CDOFeature feature, IStoreReader storeReader,
+ MoveableList list, int chunkStart, int chunkEnd)
+ {
+ IStoreChunkReader chunkReader = null;
+ int fromIndex = -1;
+ for (int j = chunkStart; j < chunkEnd; j++)
+ {
+ if (list.get(j) == CDORevisionImpl.UNINITIALIZED)
+ {
+ if (fromIndex == -1)
+ {
+ fromIndex = j;
+ }
+ }
+ else
+ {
+ if (fromIndex != -1)
+ {
+ if (chunkReader == null)
+ {
+ if (storeReader == null)
+ {
+ storeReader = StoreUtil.getReader();
+ }
+
+ chunkReader = storeReader.createChunkReader(revision, feature);
+ }
+
+ int toIndex = j - 1;
+ if (fromIndex == toIndex)
+ {
+ chunkReader.addSimpleChunk(fromIndex);
+ }
+ else
+ {
+ chunkReader.addRangedChunk(fromIndex, toIndex);
+ }
+
+ fromIndex = -1;
+ }
+ }
+ }
+
+ // Add last chunk
+ if (fromIndex != -1)
+ {
+ if (chunkReader == null)
+ {
+ if (storeReader == null)
+ {
+ storeReader = StoreUtil.getReader();
+ }
+
+ chunkReader = storeReader.createChunkReader(revision, feature);
+ }
+
+ int toIndex = chunkEnd - 1;
+ if (fromIndex == toIndex)
+ {
+ chunkReader.addSimpleChunk(fromIndex);
+ }
+ else
+ {
+ chunkReader.addRangedChunk(fromIndex, toIndex);
+ }
+ }
+
+ if (chunkReader != null)
+ {
+ List<Chunk> chunks = chunkReader.executeRead();
+ for (Chunk chunk : chunks)
+ {
+ int startIndex = chunk.getStartIndex();
+ for (int indexInChunk = 0; indexInChunk < chunk.size(); indexInChunk++)
+ {
+ CDOID id = chunk.getID(indexInChunk);
+ list.set(startIndex + indexInChunk, id);
+ }
+ }
+ }
+
+ return storeReader;
+ }
+
@Override
protected CDORevisionImpl loadRevision(CDOID id, int referenceChunk)
{
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/StoreChunkReader.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/StoreChunkReader.java
new file mode 100644
index 0000000..44aed4c
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/StoreChunkReader.java
@@ -0,0 +1,70 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2007 Eike Stepper, Germany.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ **************************************************************************/
+package org.eclipse.emf.cdo.internal.server;
+
+import org.eclipse.emf.cdo.protocol.model.CDOFeature;
+import org.eclipse.emf.cdo.protocol.revision.CDORevision;
+import org.eclipse.emf.cdo.server.IStoreAccessor;
+import org.eclipse.emf.cdo.server.IStoreChunkReader;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Eike Stepper
+ */
+public abstract class StoreChunkReader implements IStoreChunkReader
+{
+ private IStoreAccessor storeAccessor;
+
+ private CDORevision revision;
+
+ private CDOFeature feature;
+
+ private List<Chunk> chunks = new ArrayList<Chunk>(0);
+
+ public StoreChunkReader(IStoreAccessor storeAccessor, CDORevision revision, CDOFeature feature)
+ {
+ this.storeAccessor = storeAccessor;
+ this.revision = revision;
+ this.feature = feature;
+ }
+
+ public IStoreAccessor getStoreAccessor()
+ {
+ return storeAccessor;
+ }
+
+ public CDORevision getRevision()
+ {
+ return revision;
+ }
+
+ public CDOFeature getFeature()
+ {
+ return feature;
+ }
+
+ public List<Chunk> getChunks()
+ {
+ return chunks;
+ }
+
+ public void addSimpleChunk(int index)
+ {
+ chunks.add(new Chunk(index));
+ }
+
+ public void addRangedChunk(int fromIndex, int toIndex)
+ {
+ chunks.add(new Chunk(fromIndex, toIndex - fromIndex));
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreChunkReader.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreChunkReader.java
new file mode 100644
index 0000000..96c7ff8
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreChunkReader.java
@@ -0,0 +1,99 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2007 Eike Stepper, Germany.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ **************************************************************************/
+package org.eclipse.emf.cdo.server;
+
+import org.eclipse.emf.cdo.protocol.CDOID;
+import org.eclipse.emf.cdo.protocol.model.CDOFeature;
+import org.eclipse.emf.cdo.protocol.revision.CDORevision;
+
+import java.util.List;
+
+/**
+ * @author Eike Stepper
+ */
+public interface IStoreChunkReader
+{
+ public CDORevision getRevision();
+
+ public CDOFeature getFeature();
+
+ public void addSimpleChunk(int index);
+
+ public void addRangedChunk(int fromIndex, int toIndex);
+
+ public List<Chunk> executeRead();
+
+ /**
+ * @author Eike Stepper
+ */
+ public class Chunk
+ {
+ private int startIndex;
+
+ private Object ids;
+
+ public Chunk(int startIndex)
+ {
+ this.startIndex = startIndex;
+ }
+
+ public Chunk(int startIndex, int size)
+ {
+ this(startIndex);
+ ids = new CDOID[size];
+ }
+
+ public int getStartIndex()
+ {
+ return startIndex;
+ }
+
+ public int size()
+ {
+ if (ids instanceof CDOID)
+ {
+ return 1;
+ }
+
+ return ((CDOID[])ids).length;
+ }
+
+ public CDOID getID(int indexInChunk)
+ {
+ if (ids instanceof CDOID)
+ {
+ if (indexInChunk == 0)
+ {
+ return (CDOID)ids;
+ }
+
+ throw new ArrayIndexOutOfBoundsException(indexInChunk);
+ }
+
+ return ((CDOID[])ids)[indexInChunk];
+ }
+
+ public void addID(int indexInChunk, CDOID id)
+ {
+ if (ids instanceof CDOID)
+ {
+ if (indexInChunk == 0)
+ {
+ ids = id;
+ }
+
+ throw new ArrayIndexOutOfBoundsException(indexInChunk);
+ }
+
+ ((CDOID[])ids)[indexInChunk] = id;
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreReader.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreReader.java
index 392a6a8..5dea6eb 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreReader.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreReader.java
@@ -15,6 +15,7 @@ import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl;
import org.eclipse.emf.cdo.internal.server.StoreUtil;
import org.eclipse.emf.cdo.protocol.CDOID;
import org.eclipse.emf.cdo.protocol.model.CDOClassRef;
+import org.eclipse.emf.cdo.protocol.model.CDOFeature;
import org.eclipse.emf.cdo.protocol.model.CDOPackageInfo;
import org.eclipse.emf.cdo.protocol.revision.CDORevision;
@@ -30,6 +31,8 @@ public interface IStoreReader extends IStoreAccessor
{
public ISession getSession();
+ public IStoreChunkReader createChunkReader(CDORevision revision, CDOFeature feature);
+
public Collection<CDOPackageInfo> readPackageInfos();
/**