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

Jean-Noel Rouvignac
07.19.2014 c7a06e53f0b6d640ae9dd6f9e76d46e12167410b
opendj3-server-dev/src/server/org/opends/server/backends/jeb/EqualityIndexer.java
@@ -26,19 +26,38 @@
 */
package org.opends.server.backends.jeb;
import java.util.Set;
import java.util.Collection;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.ldap.ByteSequence;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.DecodeException;
import org.forgerock.opendj.ldap.schema.Schema;
import org.forgerock.opendj.ldap.spi.IndexingOptions;
import org.opends.server.api.EqualityMatchingRule;
import org.opends.server.api.ExtensibleIndexer;
import org.opends.server.types.AttributeValue;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.AttributeType;
/**
 * An implementation of an Indexer for attribute equality.
 */
public class EqualityIndexer extends ExtensibleIndexer
{
  private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
  /**
   * The attribute type equality matching rule which is also the
   * comparator for the index keys generated by this class.
   */
  private EqualityMatchingRule equalityRule;
  /**
   * Create a new attribute equality indexer for the given index configuration.
   * @param attributeType The attribute type for which an indexer is
   * required.
   */
  public EqualityIndexer(AttributeType attributeType)
  {
    this.equalityRule = attributeType.getEqualityMatchingRule();
  }
  /** {@inheritDoc} */
  @Override
@@ -57,16 +76,11 @@
  /** {@inheritDoc} */
  @Override
  public void getKeys(AttributeValue value, Set<byte[]> keys)
  public void createKeys(Schema schema, ByteSequence value,
      IndexingOptions options, Collection<ByteString> keys)
      throws DecodeException
  {
    try
    {
      keys.add(value.getNormalizedValue().toByteArray());
    }
    catch (DirectoryException e)
    {
      logger.traceException(e);
    }
    keys.add(equalityRule.normalizeAttributeValue(value));
  }
}