summaryrefslogtreecommitdiff
path: root/src/main/java/com/amazon/carbonado/repo
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/amazon/carbonado/repo')
-rw-r--r--src/main/java/com/amazon/carbonado/repo/indexed/ManagedIndex.java16
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);