diff options
author | Brian S. O'Neill <bronee@gmail.com> | 2008-12-18 20:58:00 +0000 |
---|---|---|
committer | Brian S. O'Neill <bronee@gmail.com> | 2008-12-18 20:58:00 +0000 |
commit | b66fb3db6951b2b6d3ace72ca3e197c7c2048e86 (patch) | |
tree | e5d9c0c6819f01b8917dcfb8884e07a3c8a9567b /src/main/java/com/amazon/carbonado/repo | |
parent | c8133fcabf7a28b40f6bc8e4e4df8baf156b2f0a (diff) |
Fixes for excessive class generation and memory usage when opening multiple repositories.
Diffstat (limited to 'src/main/java/com/amazon/carbonado/repo')
-rw-r--r-- | src/main/java/com/amazon/carbonado/repo/indexed/IndexEntryGenerator.java | 23 | ||||
-rw-r--r-- | src/main/java/com/amazon/carbonado/repo/sleepycat/BDBStorage.java | 11 |
2 files changed, 22 insertions, 12 deletions
diff --git a/src/main/java/com/amazon/carbonado/repo/indexed/IndexEntryGenerator.java b/src/main/java/com/amazon/carbonado/repo/indexed/IndexEntryGenerator.java index a126224..7fb80dc 100644 --- a/src/main/java/com/amazon/carbonado/repo/indexed/IndexEntryGenerator.java +++ b/src/main/java/com/amazon/carbonado/repo/indexed/IndexEntryGenerator.java @@ -28,6 +28,7 @@ import com.amazon.carbonado.Storable; import com.amazon.carbonado.SupportException;
import com.amazon.carbonado.info.StorableIndex;
import com.amazon.carbonado.info.StorableProperty;
+import com.amazon.carbonado.synthetic.SyntheticStorableReferenceAccess;
import com.amazon.carbonado.synthetic.SyntheticStorableReferenceBuilder;
/**
@@ -100,7 +101,7 @@ class IndexEntryGenerator <S extends Storable> { }
}
- private SyntheticStorableReferenceBuilder<S> mBuilder;
+ private SyntheticStorableReferenceAccess<S> mIndexAccess;
/**
* Convenience class for gluing new "builder" style synthetics to the traditional
@@ -112,13 +113,17 @@ class IndexEntryGenerator <S extends Storable> { // but we have nothing better available to us
Class<S> type = index.getProperty(0).getEnclosingType();
- mBuilder = new SyntheticStorableReferenceBuilder<S>(type, index.isUnique());
+ SyntheticStorableReferenceBuilder<S> builder =
+ new SyntheticStorableReferenceBuilder<S>(type, index.isUnique());
for (int i=0; i<index.getPropertyCount(); i++) {
StorableProperty source = index.getProperty(i);
- mBuilder.addKeyProperty(source.getName(), index.getPropertyDirection(i));
+ builder.addKeyProperty(source.getName(), index.getPropertyDirection(i));
}
- mBuilder.build();
+
+ builder.build();
+
+ mIndexAccess = builder.getReferenceAccess();
}
/**
@@ -127,7 +132,7 @@ class IndexEntryGenerator <S extends Storable> { * @return class of index entry, which is a custom Storable
*/
public Class<? extends Storable> getIndexEntryClass() {
- return mBuilder.getStorableClass();
+ return mIndexAccess.getReferenceClass();
}
/**
@@ -138,7 +143,7 @@ class IndexEntryGenerator <S extends Storable> { * @param master master whose primary key properties will be set
*/
public void copyToMasterPrimaryKey(Storable indexEntry, S master) {
- mBuilder.copyToMasterPrimaryKey(indexEntry, master);
+ mIndexAccess.copyToMasterPrimaryKey(indexEntry, master);
}
/**
@@ -149,7 +154,7 @@ class IndexEntryGenerator <S extends Storable> { * @param master source of property values
*/
public void copyFromMaster(Storable indexEntry, S master) {
- mBuilder.copyFromMaster(indexEntry, master);
+ mIndexAccess.copyFromMaster(indexEntry, master);
}
/**
@@ -161,13 +166,13 @@ class IndexEntryGenerator <S extends Storable> { * @param master source of property values
*/
public boolean isConsistent(Storable indexEntry, S master) {
- return mBuilder.isConsistent(indexEntry, master);
+ return mIndexAccess.isConsistent(indexEntry, master);
}
/**
* Returns a comparator for ordering index entries.
*/
public Comparator<? extends Storable> getComparator() {
- return mBuilder.getComparator();
+ return mIndexAccess.getComparator();
}
}
diff --git a/src/main/java/com/amazon/carbonado/repo/sleepycat/BDBStorage.java b/src/main/java/com/amazon/carbonado/repo/sleepycat/BDBStorage.java index f4a010b..1733167 100644 --- a/src/main/java/com/amazon/carbonado/repo/sleepycat/BDBStorage.java +++ b/src/main/java/com/amazon/carbonado/repo/sleepycat/BDBStorage.java @@ -24,6 +24,7 @@ import java.util.Map; import org.cojen.classfile.TypeDesc;
+import com.amazon.carbonado.CorruptEncodingException;
import com.amazon.carbonado.Cursor;
import com.amazon.carbonado.FetchDeadlockException;
import com.amazon.carbonado.FetchException;
@@ -104,7 +105,7 @@ abstract class BDBStorage<Txn, S extends Storable> implements Storage<S>, Storag private final Class<S> mType;
/** Does most of the work in generating storables, used for preparing and querying */
- private StorableCodec<S> mStorableCodec;
+ StorableCodec<S> mStorableCodec;
/**
* Reference to an instance of Proxy, defined in this class, which binds
@@ -135,7 +136,7 @@ abstract class BDBStorage<Txn, S extends Storable> implements Storage<S>, Storag {
mRepository = repository;
mType = type;
- mRawSupport = new Support<Txn, S>(repository, this);
+ mRawSupport = new Support(repository, this);
mTriggerManager = new TriggerManager<S>();
try {
// Ask if any lobs via static method first, to prevent stack
@@ -1009,7 +1010,7 @@ abstract class BDBStorage<Txn, S extends Storable> implements Storage<S>, Storag // Note: BDBStorage could just implement the RawSupport interface, but
// then these hidden methods would be public. A simple cast of Storage to
// RawSupport would expose them.
- private static class Support<Txn, S extends Storable> implements RawSupport<S> {
+ private class Support implements RawSupport<S> {
private final BDBRepository<Txn> mRepository;
private final BDBStorage<Txn, S> mStorage;
private Map<String, ? extends StorableProperty<S>> mProperties;
@@ -1128,6 +1129,10 @@ abstract class BDBStorage<Txn, S extends Storable> implements Storage<S>, Storag return mStorage.getLocator(clob);
}
+ public void decode(S dest, int generation, byte[] data) throws CorruptEncodingException {
+ mStorableCodec.decode(dest, generation, data);
+ }
+
public SequenceValueProducer getSequenceValueProducer(String name)
throws PersistException
{
|