From bbe142577feebb644751d6fe515e79f9a31aeb34 Mon Sep 17 00:00:00 2001 From: "Brian S. O'Neill" Date: Tue, 13 Feb 2007 22:24:35 +0000 Subject: Added progress logging during index build. --- .../amazon/carbonado/repo/indexed/ManagedIndex.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (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 1a4ba95..274c452 100644 --- a/src/main/java/com/amazon/carbonado/repo/indexed/ManagedIndex.java +++ b/src/main/java/com/amazon/carbonado/repo/indexed/ManagedIndex.java @@ -297,6 +297,8 @@ class ManagedIndex implements IndexEntryAccessor { MergeSortBuffer buffer; Comparator c; + Log log = LogFactory.getLog(IndexedStorage.class); + // Enter top transaction with isolation level of none to make sure // preload operation does not run in a long nested transaction. Transaction txn = repo.enterTopTransaction(IsolationLevel.NONE); @@ -308,7 +310,6 @@ class ManagedIndex implements IndexEntryAccessor { return; } - Log log = LogFactory.getLog(IndexedStorage.class); if (log.isInfoEnabled()) { StringBuilder b = new StringBuilder(); b.append("Populating index on "); @@ -361,9 +362,11 @@ class ManagedIndex implements IndexEntryAccessor { } } + final int bufferSize = buffer.size(); + int totalInserted = 0; + txn = repo.enterTopTransaction(IsolationLevel.READ_COMMITTED); try { - int totalInserted = 0; for (Object obj : buffer) { Storable indexEntry = (Storable) obj; if (!indexEntry.tryInsert()) { @@ -375,6 +378,13 @@ class ManagedIndex implements IndexEntryAccessor { if (totalInserted % POPULATE_BATCH_SIZE == 0) { txn.commit(); txn.exit(); + + if (log.isInfoEnabled()) { + String format = "Committed %d new index entries (%.3f%%)"; + double percent = 100.0 * totalInserted / bufferSize; + log.info(String.format(format, totalInserted, percent)); + } + txn = repo.enterTopTransaction(IsolationLevel.READ_COMMITTED); } } @@ -383,6 +393,10 @@ class ManagedIndex implements IndexEntryAccessor { txn.exit(); buffer.close(); } + + if (log.isInfoEnabled()) { + log.info("Finished inserting " + totalInserted + " new index entries"); + } } private Storable makeIndexEntry(S userStorable) { -- cgit v1.2.3