diff options
author | Tom Keller <keller_tl@users.sourceforge.net> | 2007-01-26 19:36:20 +0000 |
---|---|---|
committer | Tom Keller <keller_tl@users.sourceforge.net> | 2007-01-26 19:36:20 +0000 |
commit | 975fd9fec74313f52007ebb264a03ec68d33448d (patch) | |
tree | def181c16d07d96aacf6686d37394d5847ba03b5 | |
parent | bd61d20688ba374941bae16bae990c89645a4e06 (diff) |
Index removal is now batched - reducing memory requirements when removing
large indexes
-rw-r--r-- | RELEASE-NOTES.txt | 2 | ||||
-rw-r--r-- | pom.xml | 8 | ||||
-rw-r--r-- | src/main/java/com/amazon/carbonado/repo/indexed/IndexedStorage.java | 32 |
3 files changed, 40 insertions, 2 deletions
diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt index fdfb0cc..c09c49f 100644 --- a/RELEASE-NOTES.txt +++ b/RELEASE-NOTES.txt @@ -8,6 +8,8 @@ Carbonado change history - Added additional index selection tie-breaker if index is most likely defined
to support desired ordering.
- Support mapping JDBC numeric column to short or byte.
+- Index removal is now batched - reducing memory requirements when removing
+ large indexes
1.1-BETA8 to 1.1-BETA9
-------------------------------
@@ -85,6 +85,12 @@ <name>Doug Treder</name>
<organization>Amazon Technologies, Inc.</organization>
</developer>
+ <developer>
+ <name>Tom Keller</name>
+ <organization>Amazon Technologies, Inc.</organization>
+ <id>keller_tl</id>
+ <email>keller_tl@users.sourceforge.net</email>
+ </developer>
</developers>
<contributors>
@@ -206,4 +212,4 @@ </plugin>
</plugins>
</reporting>
-</project>
\ No newline at end of file +</project>
diff --git a/src/main/java/com/amazon/carbonado/repo/indexed/IndexedStorage.java b/src/main/java/com/amazon/carbonado/repo/indexed/IndexedStorage.java index 9b7f408..5fb94eb 100644 --- a/src/main/java/com/amazon/carbonado/repo/indexed/IndexedStorage.java +++ b/src/main/java/com/amazon/carbonado/repo/indexed/IndexedStorage.java @@ -446,7 +446,37 @@ class IndexedStorage<S extends Storable> implements Storage<S>, StorageAccess<S> // Doesn't completely remove the index, but it should free up space.
// TODO: when truncate method exists, call that instead
- indexEntryStorage.query().deleteAll();
+ // TODO: set batchsize based on repository locktable size
+ int batchSize = 10;
+ while (true) {
+ Transaction txn = mRepository.getWrappedRepository()
+ .enterTopTransaction(IsolationLevel.READ_COMMITTED);
+ txn.setForUpdate(true);
+
+ try {
+ Cursor<? extends Storable> cursor = indexEntryStorage.query().fetch();
+ if (!cursor.hasNext()) {
+ break;
+ }
+ int count = 0;
+ try {
+ while (count++ < batchSize && cursor.hasNext()) {
+ cursor.next().tryDelete();
+ }
+ } finally {
+ cursor.close();
+ }
+ if (txn != null) {
+ txn.commit();
+ }
+ } catch (FetchException e) {
+ throw e.toPersistException();
+ } finally {
+ if (txn != null) {
+ txn.exit();
+ }
+ }
+ }
unregisterIndex(index);
}
}
|