From 3ab9614db1a1a1a30c271424c4189999bf71b87a Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Fri, 07 Mar 2014 10:58:03 +0000
Subject: [PATCH] OPENDJ-1308 Migrate schema support

---
 opendj3-server-dev/src/server/org/opends/server/backends/jeb/OrderingIndexer.java |  157 +++-------------------------------------------------
 1 files changed, 10 insertions(+), 147 deletions(-)

diff --git a/opendj3-server-dev/src/server/org/opends/server/backends/jeb/OrderingIndexer.java b/opendj3-server-dev/src/server/org/opends/server/backends/jeb/OrderingIndexer.java
index c7b54c2..a55e82e 100644
--- a/opendj3-server-dev/src/server/org/opends/server/backends/jeb/OrderingIndexer.java
+++ b/opendj3-server-dev/src/server/org/opends/server/backends/jeb/OrderingIndexer.java
@@ -26,37 +26,22 @@
  */
 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 org.forgerock.i18n.slf4j.LocalizedLogger;
 import org.forgerock.opendj.ldap.DecodeException;
 import org.opends.server.api.ExtensibleIndexer;
 import org.opends.server.api.OrderingMatchingRule;
-import org.opends.server.types.Attribute;
 import org.opends.server.types.AttributeType;
 import org.opends.server.types.AttributeValue;
-import org.opends.server.types.Entry;
-import org.opends.server.types.Modification;
 
 /**
  * An implementation of an Indexer for attribute ordering.
  */
-public class OrderingIndexer extends Indexer
+public class OrderingIndexer extends ExtensibleIndexer
 {
   private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
 
-
-
-  /**
-   * The attribute type for which this instance will
-   * generate index keys.
-   */
-  private AttributeType attributeType;
-
   /**
    * The attribute type ordering matching rule which is also the
    * comparator for the index keys generated by this class.
@@ -71,115 +56,27 @@
    */
   public OrderingIndexer(AttributeType attributeType)
   {
-    this.attributeType = attributeType;
     this.orderingRule = attributeType.getOrderingMatchingRule();
   }
 
-  /**
-   * Get a string representation of this object.  The returned value is
-   * used to name an index created using this object.
-   * @return A string representation of this object.
-   */
+  /** {@inheritDoc} */
   @Override
-  public String toString()
+  public String getIndexID()
   {
-    return attributeType.getNameOrOID() + ".ordering";
+    // TODO Auto-generated method stub
+    throw new RuntimeException();
   }
 
-  /**
-   * Get the comparator that must be used to compare index keys
-   * generated by this class.
-   *
-   * @return A byte array comparator.
-   */
+  /** {@inheritDoc} */
   @Override
-  public Comparator<byte[]> getComparator()
+  public String getExtensibleIndexID()
   {
-    return orderingRule;
+    return "ordering";
   }
 
-  /**
-   * Generate the set of index keys for an entry.
-   *
-   * @param entry The entry.
-   * @param keys The set into which the generated keys will be inserted.
-   */
+  /** {@inheritDoc} */
   @Override
-  public void indexEntry(Entry entry, Set<byte[]> keys)
-  {
-    List<Attribute> attrList =
-         entry.getAttribute(attributeType);
-    if (attrList != null)
-    {
-      indexAttribute(attrList, keys);
-    }
-  }
-
-  /**
-   * Generate the set of index keys to be added and the set of index keys
-   * to be deleted for an entry that has been replaced.
-   *
-   * @param oldEntry The original entry contents.
-   * @param newEntry The new entry contents.
-   * @param modifiedKeys The map into which the modified keys will be inserted.
-   */
-  @Override
-  public void replaceEntry(Entry oldEntry, Entry newEntry,
-                           Map<byte[], Boolean> modifiedKeys)
-  {
-    List<Attribute> newAttributes = newEntry.getAttribute(attributeType, true);
-    List<Attribute> oldAttributes = oldEntry.getAttribute(attributeType, true);
-
-    indexAttribute(oldAttributes, modifiedKeys, false);
-    indexAttribute(newAttributes, modifiedKeys, true);
-  }
-
-  /**
-   * Generate the set of index keys to be added and the set of index keys
-   * to be deleted for an entry that was modified.
-   *
-   * @param oldEntry The original entry contents.
-   * @param newEntry The new entry contents.
-   * @param mods The set of modifications that were applied to the entry.
-   * @param modifiedKeys The map into which the modified keys will be inserted.
-   */
-  @Override
-  public void modifyEntry(Entry oldEntry, Entry newEntry,
-                          List<Modification> mods,
-                          Map<byte[], Boolean> modifiedKeys)
-  {
-    List<Attribute> newAttributes = newEntry.getAttribute(attributeType, true);
-    List<Attribute> oldAttributes = oldEntry.getAttribute(attributeType, true);
-
-    indexAttribute(oldAttributes, modifiedKeys, false);
-    indexAttribute(newAttributes, modifiedKeys, true);
-  }
-
-
-
-  /**
-   * Generate the set of index keys for an attribute.
-   * @param attrList The attribute to be indexed.
-   * @param keys The set into which the keys will be inserted.
-   */
-  private void indexAttribute(List<Attribute> attrList,
-                              Set<byte[]> keys)
-  {
-    if (attrList == null) return;
-
-    for (Attribute attr : attrList)
-    {
-      if (!attr.isVirtual())
-      {
-        for (AttributeValue value : attr)
-        {
-          getKeys(value, keys);
-        }
-      }
-    }
-  }
-
-  private void getKeys(AttributeValue value, Set<byte[]> keys)
+  public void getKeys(AttributeValue value, Set<byte[]> keys)
   {
     try
     {
@@ -191,38 +88,4 @@
     }
   }
 
-
-  /**
-   * Generate the set of index keys for an attribute.
-   * @param attrList The attribute to be indexed.
-   * @param modifiedKeys The map into which the modified
-   * keys will be inserted.
-   * @param insert <code>true</code> if generated keys should
-   * be inserted or <code>false</code> otherwise.
-   */
-  private void indexAttribute(List<Attribute> attrList,
-                              Map<byte[], Boolean> modifiedKeys,
-                              Boolean insert)
-  {
-    if (attrList == null) return;
-
-    for (Attribute attr : attrList)
-    {
-      if (!attr.isVirtual())
-      {
-        for (AttributeValue value : attr)
-        {
-          getKeys(value, modifiedKeys, insert);
-        }
-      }
-    }
-  }
-
-  private void getKeys(AttributeValue value, Map<byte[], Boolean> modifiedKeys,
-      Boolean insert)
-  {
-    Set<byte[]> keys = new HashSet<byte[]>();
-    getKeys(value, keys);
-    ExtensibleIndexer.computeModifiedKeys(modifiedKeys, insert, keys);
-  }
 }

--
Gitblit v1.10.0