summaryrefslogtreecommitdiff
path: root/src/main/java/com/amazon/carbonado/repo
diff options
context:
space:
mode:
authorBrian S. O'Neill <bronee@gmail.com>2007-02-13 22:24:35 +0000
committerBrian S. O'Neill <bronee@gmail.com>2007-02-13 22:24:35 +0000
commitbbe142577feebb644751d6fe515e79f9a31aeb34 (patch)
tree4745ad9ae3c7ef3eec76119bee358699cc3d882a /src/main/java/com/amazon/carbonado/repo
parent6f7dcb971893d8afdc48bda7ed5663383c896e59 (diff)
Added progress logging during index build.
Diffstat (limited to 'src/main/java/com/amazon/carbonado/repo')
-rw-r--r--src/main/java/com/amazon/carbonado/repo/indexed/ManagedIndex.java18
1 files changed, 16 insertions, 2 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 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<S extends Storable> implements IndexEntryAccessor<S> {
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<S extends Storable> implements IndexEntryAccessor<S> {
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<S extends Storable> implements IndexEntryAccessor<S> {
}
}
+ 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<S extends Storable> implements IndexEntryAccessor<S> {
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<S extends Storable> implements IndexEntryAccessor<S> {
txn.exit();
buffer.close();
}
+
+ if (log.isInfoEnabled()) {
+ log.info("Finished inserting " + totalInserted + " new index entries");
+ }
}
private Storable makeIndexEntry(S userStorable) {