From 84f11578841b626e181116f41772d6166e2dde9a Mon Sep 17 00:00:00 2001
From: Ludovic Poitou <ludovic.poitou@forgerock.com>
Date: Thu, 08 Dec 2011 11:29:01 +0000
Subject: [PATCH] Fix for OPENDJ-372: Enhance rebuild-index and verify-index tools to use JE 5.x disk ordered cursoring The performances gain will vary depending on the DB size and state, but I got consistent faster index rebuilding with 1M entry DB with the new cursoring API. Changes also include some tidy up around use of the database container, using getters rather than public fields directly.

---
 opends/src/server/org/opends/server/backends/jeb/importLDIF/Importer.java |   13 ++++++-------
 1 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/opends/src/server/org/opends/server/backends/jeb/importLDIF/Importer.java b/opends/src/server/org/opends/server/backends/jeb/importLDIF/Importer.java
index 52dacaa..5c8be4a 100644
--- a/opends/src/server/org/opends/server/backends/jeb/importLDIF/Importer.java
+++ b/opends/src/server/org/opends/server/backends/jeb/importLDIF/Importer.java
@@ -23,6 +23,7 @@
  *
  *
  *      Copyright 2008-2010 Sun Microsystems, Inc.
+ *      Portions Copyright 2011 ForgeRock AS
  */
 
 package org.opends.server.backends.jeb.importLDIF;
@@ -422,7 +423,8 @@
     final long usableMemory = availableMemory
         - (indexCount * READER_WRITER_BUFFER_SIZE);
 
-    if (!skipDNValidation)
+    // We need caching when doing DN validation or rebuilding indexes.
+    if (!skipDNValidation || (rebuildManager != null))
     {
       // No DN validation: calculate memory for DB cache, DN2ID temporary cache,
       // and buffers.
@@ -3306,15 +3308,12 @@
     public Void call() throws Exception
     {
       ID2Entry id2entry = entryContainer.getID2Entry();
-      Cursor cursor = id2entry.openCursor(null, CursorConfig.READ_COMMITTED);
+      DiskOrderedCursor cursor =
+          id2entry.openCursor(DiskOrderedCursorConfig.DEFAULT);
       DatabaseEntry key = new DatabaseEntry();
       DatabaseEntry data = new DatabaseEntry();
-      LockMode lockMode = LockMode.DEFAULT;
-      OperationStatus status;
       try {
-        for (status = cursor.getFirst(key, data, lockMode);
-             status == OperationStatus.SUCCESS;
-             status = cursor.getNext(key, data, lockMode))
+        while (cursor.getNext(key, data, null) == OperationStatus.SUCCESS)
         {
           if(isCanceled)
           {

--
Gitblit v1.10.0