From 9fffba665e4a785cfeaddd038c8c8a302f216a1c Mon Sep 17 00:00:00 2001 From: "Brian S. O'Neill" Date: Tue, 17 May 2011 00:19:20 +0000 Subject: Don't rebuild index if nothing to build. Make sure bogus index entries are truncated. --- .../com/amazon/carbonado/repo/indexed/ManagedIndex.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/main/java/com/amazon/carbonado/repo') 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 implements IndexEntryAccessor { .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); -- cgit v1.2.3