mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Jean-Noel Rouvignac
07.58.2014 3ab9614db1a1a1a30c271424c4189999bf71b87a
opendj3-server-dev/src/server/org/opends/server/api/ExtensibleIndexer.java
@@ -27,8 +27,6 @@
package org.opends.server.api;
import java.util.Collection;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import org.forgerock.opendj.ldap.ByteSequence;
@@ -86,56 +84,4 @@
    throw new RuntimeException("Not implemented yet");
  }
  /**
   * Generates a map of index keys and a boolean flag indicating
   * whether the corresponding key will be inserted or deleted.
   *
   * @param attrValue
   *          The attribute for which keys are required.
   * @param modifiedKeys
   *          A map containing the keys and a boolean. Keys
   *          corresponding to the boolean value <code>true</code>
   *          should be inserted and <code>false</code> should be
   *          deleted.
   * @param insert
   *          <code>true</code> if generated keys should be inserted
   *          or <code>false</code> otherwise.
   */
  public void getKeys(AttributeValue attrValue, Map<byte[], Boolean> modifiedKeys, Boolean insert)
  {
    final Set<byte[]> keys = new HashSet<byte[]>();
    getKeys(attrValue, keys);
    computeModifiedKeys(modifiedKeys, insert, keys);
  }
  /**
   * Computes the modified keys by an indexer.
   *
   * @param modifiedKeys
   *          A map containing the keys and a boolean. Keys
   *          corresponding to the boolean value <code>true</code>
   *          should be inserted and <code>false</code> should be
   *          deleted.
   * @param insert
   *          <code>true</code> if generated keys should be inserted
   *          or <code>false</code> otherwise.
   * @param keys
   *          the newly generated keys that will be added or removed from the Map
   */
  public static void computeModifiedKeys(Map<byte[], Boolean> modifiedKeys,
      Boolean insert, final Set<byte[]> keys)
  {
    for (byte[] key : keys)
    {
      Boolean cInsert = modifiedKeys.get(key);
      if (cInsert == null)
      {
        modifiedKeys.put(key, insert);
      }
      else if (!cInsert.equals(insert))
      {
        modifiedKeys.remove(key);
      }
    }
  }
}