From 10a58f5110dd42aae14addffcfb981adc3e08c62 Mon Sep 17 00:00:00 2001
From: Matthew Swift <matthew.swift@forgerock.com>
Date: Fri, 27 Feb 2015 22:32:52 +0000
Subject: [PATCH] OPENDJ-1855: minor code cleanup

---
 opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/DatabaseContainer.java |   17 --------
 opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/IndexBuffer.java       |    7 +++
 opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/Index.java             |    7 +++
 opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/DN2ID.java             |   30 --------------
 4 files changed, 13 insertions(+), 48 deletions(-)

diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/DN2ID.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/DN2ID.java
index 6c05c79..189e88f 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/DN2ID.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/DN2ID.java
@@ -28,7 +28,6 @@
 
 import static org.opends.server.backends.pluggable.JebFormat.*;
 
-import org.forgerock.opendj.ldap.ByteSequence;
 import org.forgerock.opendj.ldap.ByteString;
 import org.opends.server.backends.pluggable.spi.ReadableStorage;
 import org.opends.server.backends.pluggable.spi.Storage;
@@ -82,26 +81,6 @@
   }
 
   /**
-   * Write a record to the DN database, where the key and value are already
-   * formatted.
-   *
-   * @param txn
-   *          A JE database transaction to be used for the database operation,
-   *          or null if none.
-   * @param key
-   *          A ByteString containing the record key.
-   * @param value
-   *          A ByteString containing the record value.
-   * @throws StorageRuntimeException
-   *           If an error occurred while attempting to write the record.
-   */
-  @Override
-  public void put(WriteableStorage txn, ByteSequence key, ByteSequence value) throws StorageRuntimeException
-  {
-    super.put(txn, key, value);
-  }
-
-  /**
    * Remove a record from the DN database.
    * @param txn A JE database transaction to be used for the database operation,
    * or null if none.
@@ -126,7 +105,7 @@
    * @return The entry ID, or null if the given DN is not in the DN database.
    * @throws StorageRuntimeException If an error occurs in the JE database.
    */
-  public EntryID get(ReadableStorage txn, DN dn, boolean isRMW) throws StorageRuntimeException
+  EntryID get(ReadableStorage txn, DN dn, boolean isRMW) throws StorageRuntimeException
   {
     ByteString key = dnToDNKey(dn, prefixRDNComponents);
     ByteString value = read(txn, key, isRMW);
@@ -136,11 +115,4 @@
     }
     return null;
   }
-
-  /** {@inheritDoc} */
-  @Override
-  public ByteString read(ReadableStorage txn, ByteSequence key, boolean isRMW)
-  {
-    return super.read(txn, key, isRMW);
-  }
 }
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/DatabaseContainer.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/DatabaseContainer.java
index 5a35d0d..2d4a796 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/DatabaseContainer.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/DatabaseContainer.java
@@ -114,14 +114,6 @@
     }
   }
 
-  /**
-   * Replace or insert a record into a JE database, with optional debug logging.
-   * This is a simple wrapper around the JE Database.put method.
-   * @param txn The JE transaction handle, or null if none.
-   * @param key The record key.
-   * @param value The record value.
-   * @throws StorageRuntimeException If an error occurs in the JE operation.
-   */
   void put(WriteableStorage txn, ByteSequence key, ByteSequence value) throws StorageRuntimeException
   {
     txn.create(treeName, key, value);
@@ -131,15 +123,6 @@
     }
   }
 
-  /**
-   * Read a record from a JE database, with optional debug logging. This is a
-   * simple wrapper around the JE Database.get method.
-   * @param txn The JE transaction handle, or null if none.
-   * @param key The key of the record to be read.
-   * @param isRMW whether the read operation is part of a larger read-modify-write operation
-   * @return The operation status.
-   * @throws StorageRuntimeException If an error occurs in the JE operation.
-   */
   ByteString read(ReadableStorage txn, ByteSequence key, boolean isRMW) throws StorageRuntimeException
   {
     ByteString value = isRMW ? txn.getRMW(treeName, key) : txn.read(treeName, key);
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/Index.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/Index.java
index 95166c1..fd6cc3c 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/Index.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/Index.java
@@ -210,7 +210,12 @@
   void updateKey(WriteableStorage txn, ByteString key, EntryIDSet deletedIDs, EntryIDSet addedIDs)
       throws StorageRuntimeException
   {
-    if(deletedIDs == null && addedIDs == null)
+    /*
+     * Check the special condition where both deletedIDs and addedIDs are null. This is used when
+     * deleting entries and corresponding id2children and id2subtree records must be completely
+     * removed.
+     */
+    if (deletedIDs == null && addedIDs == null)
     {
       boolean success = delete(txn, key);
       if (success && logger.isTraceEnabled())
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/IndexBuffer.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/IndexBuffer.java
index 8bd98fc..c8fd193 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/IndexBuffer.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/IndexBuffer.java
@@ -59,7 +59,12 @@
   private final LinkedHashMap<VLVIndex, BufferedVLVIndexValues> bufferedVLVIndexes =
       new LinkedHashMap<VLVIndex, BufferedVLVIndexValues>();
 
-  /** A simple class representing a pair of added and deleted indexed IDs. */
+  /**
+   * A simple class representing a pair of added and deleted indexed IDs. Initially both addedIDs
+   * and deletedIDs are {@code null} indicating that that the whole record should be deleted. This
+   * state is only ever used when updating the id2children and id2subtree indexes when deleting an
+   * entry.
+   */
   static class BufferedIndexValues
   {
     private EntryIDSet addedIDs;

--
Gitblit v1.10.0