| | |
| | | */ |
| | | 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 |
| | |
| | | |
| | | /** {@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)); |
| | | } |
| | | |
| | | } |