From 975fd9fec74313f52007ebb264a03ec68d33448d Mon Sep 17 00:00:00 2001 From: Tom Keller Date: Fri, 26 Jan 2007 19:36:20 +0000 Subject: Index removal is now batched - reducing memory requirements when removing large indexes --- RELEASE-NOTES.txt | 2 ++ pom.xml | 8 +++++- .../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 ------------------------------- diff --git a/pom.xml b/pom.xml index ec4ae4e..6af176f 100644 --- a/pom.xml +++ b/pom.xml @@ -85,6 +85,12 @@ Doug Treder Amazon Technologies, Inc. + + Tom Keller + Amazon Technologies, Inc. + keller_tl + keller_tl@users.sourceforge.net + @@ -206,4 +212,4 @@ - \ No newline at end of file + 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 implements Storage, StorageAccess // 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 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); } } -- cgit v1.2.3