diff options
author | Brian S. O'Neill <bronee@gmail.com> | 2011-05-17 00:19:20 +0000 |
---|---|---|
committer | Brian S. O'Neill <bronee@gmail.com> | 2011-05-17 00:19:20 +0000 |
commit | 9fffba665e4a785cfeaddd038c8c8a302f216a1c (patch) | |
tree | 655c40b049dc83e43ff0d940d8bc1d2da555a150 /src/main/java | |
parent | 96f9523b4e8d45d162504f2419c80d3b770ac0dd (diff) |
Don't rebuild index if nothing to build. Make sure bogus index entries are truncated.
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/com/amazon/carbonado/repo/indexed/ManagedIndex.java | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/main/java/com/amazon/carbonado/repo/indexed/ManagedIndex.java b/src/main/java/com/amazon/carbonado/repo/indexed/ManagedIndex.java index dbc7c06..1da57aa 100644 --- a/src/main/java/com/amazon/carbonado/repo/indexed/ManagedIndex.java +++ b/src/main/java/com/amazon/carbonado/repo/indexed/ManagedIndex.java @@ -294,6 +294,22 @@ class ManagedIndex<S extends Storable> implements IndexEntryAccessor<S> { .orderBy(naturalOrdering(mMasterStorage.getStorableType()));
}
+ // Quick check to see if any records exist in master.
+ {
+ Transaction txn = mRepository.enterTopTransaction(IsolationLevel.READ_COMMITTED);
+ try {
+ if (!masterQuery.exists()) {
+ if (mIndexEntryStorage.query().exists()) {
+ txn.exit();
+ mIndexEntryStorage.truncate();
+ }
+ return;
+ }
+ } finally {
+ txn.exit();
+ }
+ }
+
// Enter top transaction with isolation level of none to make sure
// preload operation does not run in a long nested transaction.
Transaction txn = mRepository.enterTopTransaction(IsolationLevel.NONE);
|