From 272f803e2dbe9da48152ea61814e43e387146f8b Mon Sep 17 00:00:00 2001
From: dugan <dugan@localhost>
Date: Mon, 17 Mar 2008 15:41:50 +0000
Subject: [PATCH] These changes remove the temporary file limitation from import-ldif. Several other changes were made also:

---
 opends/src/server/org/opends/server/backends/jeb/Index.java |   90 +++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 90 insertions(+), 0 deletions(-)

diff --git a/opends/src/server/org/opends/server/backends/jeb/Index.java b/opends/src/server/org/opends/server/backends/jeb/Index.java
index 0e8b3cb..748faeb 100644
--- a/opends/src/server/org/opends/server/backends/jeb/Index.java
+++ b/opends/src/server/org/opends/server/backends/jeb/Index.java
@@ -34,6 +34,8 @@
 
 import org.opends.server.types.*;
 import org.opends.server.util.StaticUtils;
+import org.opends.server.backends.jeb.importLDIF.IntegerImportIDSet;
+import org.opends.server.backends.jeb.importLDIF.ImportIDSet;
 import static org.opends.messages.JebMessages.*;
 
 import java.util.*;
@@ -112,6 +114,7 @@
    */
   private boolean rebuildRunning = false;
 
+
   /**
    * Create a new index object.
    * @param name The name of the index database within the entryContainer.
@@ -258,6 +261,65 @@
     return success;
   }
 
+
+  /**
+   * Add the specified import ID set to the provided key. Used during
+   * substring buffer flushing.
+   *
+   * @param txn A transaction.
+   * @param key The key to add the set to.
+   * @param importIdSet The set of import IDs.
+   * @throws DatabaseException If an database error occurs.
+   */
+  public void insert(Transaction txn, DatabaseEntry key,
+                     ImportIDSet importIdSet)
+  throws DatabaseException {
+
+    OperationStatus status;
+    DatabaseEntry data = new DatabaseEntry();
+      status = read(txn, key, data, LockMode.RMW);
+      if(status == OperationStatus.SUCCESS) {
+        ImportIDSet newImportIDSet = new IntegerImportIDSet();
+        if (newImportIDSet.merge(data.getData(), importIdSet, indexEntryLimit))
+        {
+          entryLimitExceededCount++;
+        }
+        data.setData(newImportIDSet.toDatabase());
+      } else if(status == OperationStatus.NOTFOUND) {
+        if(!importIdSet.isDefined()) {
+          entryLimitExceededCount++;
+        }
+        data.setData(importIdSet.toDatabase());
+      } else {
+        //Should never happen during import.
+        throw new DatabaseException();
+      }
+      put(txn,key, data);
+  }
+
+
+  /**
+   * Add the specified entry ID to the provided keys in the keyset.
+   *
+   * @param txn  A transaction.
+   * @param keySet  The set containing the keys.
+   * @param entryID The entry ID.
+   * @return <CODE>True</CODE> if the insert was successful.
+   * @throws DatabaseException If a database error occurs.
+   */
+  public synchronized
+  boolean insert(Transaction txn, Set<byte[]> keySet, EntryID entryID)
+  throws DatabaseException {
+    for(byte[] key : keySet) {
+      if(insertIDWithRMW(txn, new DatabaseEntry(key), new DatabaseEntry(),
+              entryID.getDatabaseEntry(), entryID) !=
+              OperationStatus.SUCCESS)  {
+        return false;
+      }
+    }
+    return true;
+  }
+
   private OperationStatus insertIDWithRMW(Transaction txn, DatabaseEntry key,
                                           DatabaseEntry data,
                                           DatabaseEntry entryIDData,
@@ -366,6 +428,25 @@
     }
   }
 
+  /**
+   * Delete specified entry ID from all keys in the provided key set.
+   *
+   * @param txn  A Transaction.
+   * @param keySet A set of keys.
+   * @param entryID The entry ID to delete.
+   * @throws DatabaseException If a database error occurs.
+   */
+  public synchronized
+  void delete(Transaction txn, Set<byte[]> keySet, EntryID entryID)
+  throws DatabaseException {
+    setTrusted(txn, false);
+    for(byte[] key : keySet) {
+       removeIDWithRMW(txn, new DatabaseEntry(key),
+                       new DatabaseEntry(), entryID);
+    }
+    setTrusted(txn, true);
+  }
+
   private void removeIDWithRMW(Transaction txn, DatabaseEntry key,
                                DatabaseEntry data, EntryID entryID)
       throws DatabaseException
@@ -833,6 +914,15 @@
   }
 
   /**
+   * Return entry limit.
+   *
+   * @return The entry limit.
+   */
+  public int getIndexEntryLimit() {
+    return this.indexEntryLimit;
+  }
+
+  /**
    * Set the index trust state.
    * @param txn A database transaction, or null if none is required.
    * @param trusted True if this index should be trusted or false

--
Gitblit v1.10.0