From 2f13f91c158747ca997a44d8e61830f46b77dd82 Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Fri, 14 Mar 2014 11:31:24 +0000
Subject: [PATCH] OPENDJ-1308 (CR-3156) Migrate schema support - ByteString - Indexer

---
 opendj3-server-dev/src/server/org/opends/server/backends/jeb/JEExtensibleIndexer.java |   50 ++++++++++----------------------------------------
 1 files changed, 10 insertions(+), 40 deletions(-)

diff --git a/opendj3-server-dev/src/server/org/opends/server/backends/jeb/JEExtensibleIndexer.java b/opendj3-server-dev/src/server/org/opends/server/backends/jeb/JEExtensibleIndexer.java
index a3e213f..2b49215 100644
--- a/opendj3-server-dev/src/server/org/opends/server/backends/jeb/JEExtensibleIndexer.java
+++ b/opendj3-server-dev/src/server/org/opends/server/backends/jeb/JEExtensibleIndexer.java
@@ -26,12 +26,10 @@
  */
 package org.opends.server.backends.jeb;
 
-import java.util.Comparator;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-import java.util.TreeSet;
 
 import org.forgerock.i18n.slf4j.LocalizedLogger;
 import org.forgerock.opendj.ldap.ByteString;
@@ -52,14 +50,6 @@
   private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
 
   /**
-   * The comparator for index keys generated by this class.
-   */
-  private static final Comparator<byte[]> comparator =
-       new AttributeIndex.KeyComparator();
-
-
-
-  /**
    * The attribute type for which this instance will
    * generate index keys.
    */
@@ -104,26 +94,11 @@
   }
 
 
-
-  /**
-   * Gets the comparator that must be used to compare index keys
-   * generated by this class.
-   *
-   * @return A byte array comparator.
-   */
-  @Override
-  public Comparator<byte[]> getComparator()
-  {
-    return comparator;
-  }
-
-
-
   /**
    * {@inheritDoc}
    */
   @Override
-  public void indexEntry(Entry entry, Set<byte[]> keys)
+  public void indexEntry(Entry entry, Set<ByteString> keys)
   {
     List<Attribute> attrList =
          entry.getAttribute(attributeType);
@@ -140,7 +115,7 @@
    */
   @Override
   public void replaceEntry(Entry oldEntry, Entry newEntry,
-                           Map<byte[], Boolean> modifiedKeys)
+                           Map<ByteString, Boolean> modifiedKeys)
   {
     List<Attribute> newAttributes = newEntry.getAttribute(attributeType, true);
     List<Attribute> oldAttributes = oldEntry.getAttribute(attributeType, true);
@@ -158,7 +133,7 @@
   @Override
   public void modifyEntry(Entry oldEntry, Entry newEntry,
                           List<Modification> mods,
-                          Map<byte[], Boolean> modifiedKeys)
+                          Map<ByteString, Boolean> modifiedKeys)
   {
     List<Attribute> newAttributes = newEntry.getAttribute(attributeType, true);
     List<Attribute> oldAttributes = oldEntry.getAttribute(attributeType, true);
@@ -175,11 +150,10 @@
    * @param keys The set into which the generated keys will be inserted.
    */
   private void indexAttribute(List<Attribute> attrList,
-                              Set<byte[]> keys)
+                              Set<ByteString> keys)
   {
     if (attrList == null) return;
 
-    Set<ByteString> keysBS = new TreeSet<ByteString>();
     for (Attribute attr : attrList)
     {
       if (!attr.isVirtual())
@@ -188,7 +162,7 @@
         {
           try
           {
-            extensibleIndexer.createKeys(null, value.getValue(), null, keysBS);
+            extensibleIndexer.createKeys(null, value.getValue(), null, keys);
           }
           catch (DecodeException e)
           {
@@ -197,10 +171,6 @@
         }
       }
     }
-    for (ByteString key : keysBS)
-    {
-      keys.add(key.toByteArray());
-    }
   }
 
 
@@ -214,12 +184,12 @@
    * be inserted or <code>false</code> otherwise.
    */
   private void indexAttribute(List<Attribute> attrList,
-                              Map<byte[], Boolean> modifiedKeys,
+                              Map<ByteString, Boolean> modifiedKeys,
                               Boolean insert)
   {
     if (attrList == null) return;
 
-    final Set<byte[]> keys = new HashSet<byte[]>();
+    final Set<ByteString> keys = new HashSet<ByteString>();
     indexAttribute(attrList, keys);
     computeModifiedKeys(modifiedKeys, insert, keys);
   }
@@ -238,10 +208,10 @@
    * @param keys
    *          The index keys to map.
    */
-  private static void computeModifiedKeys(Map<byte[], Boolean> modifiedKeys,
-      Boolean insert, final Set<byte[]> keys)
+  private static void computeModifiedKeys(Map<ByteString, Boolean> modifiedKeys,
+      Boolean insert, Set<ByteString> keys)
   {
-    for (byte[] key : keys)
+    for (ByteString key : keys)
     {
       Boolean cInsert = modifiedKeys.get(key);
       if (cInsert == null)

--
Gitblit v1.10.0