OPENDJ-1591 (CR-5206) Switch to SDK matching rules
After r11260 some code cleanup can be performed.
JEExtensibleIndexer.java: Renamed to AttributeIndexer
AttributeIndex.java, TestBackendImpl.java:
Renamed all ext*Index local variables to index.
Renamed all other *ext*Indexer identifiers to *attributeIndexer.
1 files renamed
2 files modified
| | |
| | | if (!nameToIndexes.containsKey(indexId)) |
| | | { |
| | | //There is no index available for this index id. Create a new index. |
| | | final Index extIndex = newExtensibleIndex(attrType, name, indexEntryLimit, indexer); |
| | | nameToIndexes.put(indexId, extIndex); |
| | | final Index index = newAttributeIndex(attrType, name, indexEntryLimit, indexer); |
| | | nameToIndexes.put(indexId, index); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | for (org.forgerock.opendj.ldap.spi.Indexer indexer : rule.getIndexers()) |
| | | { |
| | | final Index index = newExtensibleIndex(attrType, name, cfg.getIndexEntryLimit(), indexer); |
| | | final Index index = newAttributeIndex(attrType, name, cfg.getIndexEntryLimit(), indexer); |
| | | nameToIndexes.put(indexID, index); |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | private Index newExtensibleIndex(AttributeType attrType, String name, final int indexEntryLimit, |
| | | private Index newAttributeIndex(AttributeType attrType, String name, final int indexEntryLimit, |
| | | org.forgerock.opendj.ldap.spi.Indexer indexer) |
| | | { |
| | | final String indexName = name + "." + indexer.getIndexID(); |
| | | final JEExtensibleIndexer extIndexer = new JEExtensibleIndexer(attrType, indexer); |
| | | return newIndex(indexName, indexEntryLimit, extIndexer); |
| | | final AttributeIndexer attrIndexer = new AttributeIndexer(attrType, indexer); |
| | | return newIndex(indexName, indexEntryLimit, attrIndexer); |
| | | } |
| | | |
| | | /** |
| | |
| | | validIndexIds.add(indexId); |
| | | if (!nameToIndexes.containsKey(indexId)) |
| | | { |
| | | Index extIndex = newExtensibleIndex(attrType, name, indexEntryLimit, indexer); |
| | | openIndex(extIndex, adminActionRequired, messages); |
| | | nameToIndexes.put(indexId, extIndex); |
| | | Index index = newAttributeIndex(attrType, name, indexEntryLimit, indexer); |
| | | openIndex(index, adminActionRequired, messages); |
| | | nameToIndexes.put(indexId, index); |
| | | } |
| | | else |
| | | { |
| | | Index extensibleIndex = nameToIndexes.get(indexId); |
| | | if (extensibleIndex.setIndexEntryLimit(indexEntryLimit)) |
| | | Index index = nameToIndexes.get(indexId); |
| | | if (index.setIndexEntryLimit(indexEntryLimit)) |
| | | { |
| | | adminActionRequired.set(true); |
| | | messages.add(NOTE_JEB_CONFIG_INDEX_ENTRY_LIMIT_REQUIRES_REBUILD.get(extensibleIndex.getName())); |
| | | messages.add(NOTE_JEB_CONFIG_INDEX_ENTRY_LIMIT_REQUIRES_REBUILD.get(index.getName())); |
| | | } |
| | | if (indexConfig.getSubstringLength() != cfg.getSubstringLength()) |
| | | { |
| | | extensibleIndex.setIndexer(new JEExtensibleIndexer(attrType, indexer)); |
| | | index.setIndexer(new AttributeIndexer(attrType, indexer)); |
| | | } |
| | | } |
| | | } |
| | |
| | | final MatchingRule matchingRule = getMatchingRule(indexType, attrType); |
| | | for (org.forgerock.opendj.ldap.spi.Indexer indexer : matchingRule.getIndexers()) |
| | | { |
| | | index = newExtensibleIndex(attrType, name, indexEntryLimit, indexer); |
| | | index = newAttributeIndex(attrType, name, indexEntryLimit, indexer); |
| | | openIndex(index, adminActionRequired, messages); |
| | | nameToIndexes.put(indexId, index); |
| | | } |
| File was renamed from opendj3-server-dev/src/server/org/opends/server/backends/jeb/JEExtensibleIndexer.java |
| | |
| | | import org.opends.server.types.Modification; |
| | | |
| | | /** |
| | | * This class implements an Indexer for extensible matching rules in JE Backend. |
| | | * This class implements an attribute indexer for matching rules in JE Backend. |
| | | */ |
| | | public final class JEExtensibleIndexer extends Indexer |
| | | public final class AttributeIndexer extends Indexer |
| | | { |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | /** |
| | | * The attribute type for which this instance will |
| | | * generate index keys. |
| | | */ |
| | | /** The attribute type for which this instance will generate index keys. */ |
| | | private final AttributeType attributeType; |
| | | |
| | | /** |
| | |
| | | * required. |
| | | * @param extensibleIndexer The extensible indexer to be used. |
| | | */ |
| | | public JEExtensibleIndexer(AttributeType attributeType, org.forgerock.opendj.ldap.spi.Indexer extensibleIndexer) |
| | | public AttributeIndexer(AttributeType attributeType, org.forgerock.opendj.ldap.spi.Indexer extensibleIndexer) |
| | | { |
| | | this.attributeType = attributeType; |
| | | this.indexer = extensibleIndexer; |
| | |
| | | private void indexAttribute(List<Attribute> attrList, Set<ByteString> keys, |
| | | IndexingOptions options) |
| | | { |
| | | if (attrList == null) return; |
| | | if (attrList == null) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | for (Attribute attr : attrList) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Generates the set of index keys for an attribute. |
| | | * @param attrList The attribute to be indexed. |
| | |
| | | Map<ByteString, Boolean> modifiedKeys, Boolean insert, |
| | | IndexingOptions options) |
| | | { |
| | | if (attrList == null) return; |
| | | if (attrList != null) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | final Set<ByteString> keys = new HashSet<ByteString>(); |
| | | indexAttribute(attrList, keys, options); |
| | |
| | | indexers = singletonList(new PresenceIndexer(index.getAttributeType())); |
| | | assertIndexContainsID(indexers, entry, index.getPresenceIndex(), entryID, FALSE); |
| | | |
| | | indexers = newJEExtensibleIndexers(attrType, attrType.getEqualityMatchingRule()); |
| | | indexers = newAttributeIndexers(attrType, attrType.getEqualityMatchingRule()); |
| | | assertIndexContainsID(indexers, entry, index.getEqualityIndex(), entryID, FALSE); |
| | | |
| | | indexers = newJEExtensibleIndexers(attrType, attrType.getSubstringMatchingRule()); |
| | | indexers = newAttributeIndexers(attrType, attrType.getSubstringMatchingRule()); |
| | | assertIndexContainsID(indexers, entry, index.getSubstringIndex(), entryID, FALSE); |
| | | |
| | | indexers = newJEExtensibleIndexers(attrType, attrType.getOrderingMatchingRule()); |
| | | indexers = newAttributeIndexers(attrType, attrType.getOrderingMatchingRule()); |
| | | assertIndexContainsID(indexers, entry, index.getOrderingIndex(), entryID, FALSE); |
| | | } |
| | | finally |
| | |
| | | } |
| | | } |
| | | |
| | | private List<JEExtensibleIndexer> newJEExtensibleIndexers(AttributeType attrType, MatchingRule matchingRule) |
| | | private List<AttributeIndexer> newAttributeIndexers(AttributeType attrType, MatchingRule matchingRule) |
| | | { |
| | | List<JEExtensibleIndexer> extIndexers = new ArrayList<JEExtensibleIndexer>(); |
| | | List<AttributeIndexer> indexers = new ArrayList<AttributeIndexer>(); |
| | | for (org.forgerock.opendj.ldap.spi.Indexer indexer : matchingRule.getIndexers()) |
| | | { |
| | | extIndexers.add(new JEExtensibleIndexer(attrType, indexer)); |
| | | indexers.add(new AttributeIndexer(attrType, indexer)); |
| | | } |
| | | return extIndexers; |
| | | return indexers; |
| | | } |
| | | |
| | | private IndexingOptions getOptions() |
| | |
| | | AttributeType attrType = index.getAttributeType(); |
| | | |
| | | List<? extends Indexer> indexers; |
| | | indexers = newJEExtensibleIndexers(attrType, attrType.getOrderingMatchingRule()); |
| | | indexers = newAttributeIndexers(attrType, attrType.getOrderingMatchingRule()); |
| | | assertIndexContainsID(indexers, entry, index.getOrderingIndex(), entryID, TRUE); |
| | | assertIndexContainsID(indexers, oldEntry, index.getOrderingIndex(), entryID, FALSE); |
| | | |
| | | indexers = newJEExtensibleIndexers(attrType, attrType.getSubstringMatchingRule()); |
| | | indexers = newAttributeIndexers(attrType, attrType.getSubstringMatchingRule()); |
| | | assertIndexContainsID(indexers, entry, index.getSubstringIndex(), entryID, TRUE); |
| | | assertIndexContainsID(indexers, oldEntry, index.getSubstringIndex(), entryID, FALSE); |
| | | |
| | | indexers = newJEExtensibleIndexers(attrType, attrType.getEqualityMatchingRule()); |
| | | indexers = newAttributeIndexers(attrType, attrType.getEqualityMatchingRule()); |
| | | assertIndexContainsID(indexers, entry, index.getEqualityIndex(), entryID, TRUE); |
| | | assertIndexContainsID(indexers, oldEntry, index.getEqualityIndex(), entryID, FALSE); |
| | | } |
| | |
| | | indexers = singletonList(new PresenceIndexer(nameIndexAttrType)); |
| | | assertIndexContainsID(indexers, entry, nameIndex.getPresenceIndex(), entryID); |
| | | |
| | | indexers = newJEExtensibleIndexers(titleIndexAttrType, titleIndexAttrType.getOrderingMatchingRule()); |
| | | indexers = newAttributeIndexers(titleIndexAttrType, titleIndexAttrType.getOrderingMatchingRule()); |
| | | assertIndexContainsID(indexers, entry, titleIndex.getOrderingIndex(), entryID); |
| | | indexers = newJEExtensibleIndexers(nameIndexAttrType, nameIndexAttrType.getOrderingMatchingRule()); |
| | | indexers = newAttributeIndexers(nameIndexAttrType, nameIndexAttrType.getOrderingMatchingRule()); |
| | | assertIndexContainsID(indexers, entry, nameIndex.getOrderingIndex(), entryID); |
| | | |
| | | indexers = newJEExtensibleIndexers(titleIndexAttrType, titleIndexAttrType.getEqualityMatchingRule()); |
| | | indexers = newAttributeIndexers(titleIndexAttrType, titleIndexAttrType.getEqualityMatchingRule()); |
| | | assertIndexContainsID(indexers, entry, titleIndex.getEqualityIndex(), entryID); |
| | | indexers = newJEExtensibleIndexers(nameIndexAttrType, nameIndexAttrType.getEqualityMatchingRule()); |
| | | indexers = newAttributeIndexers(nameIndexAttrType, nameIndexAttrType.getEqualityMatchingRule()); |
| | | assertIndexContainsID(indexers, entry, nameIndex.getEqualityIndex(), entryID); |
| | | |
| | | indexers = newJEExtensibleIndexers(titleIndexAttrType, titleIndexAttrType.getSubstringMatchingRule()); |
| | | indexers = newAttributeIndexers(titleIndexAttrType, titleIndexAttrType.getSubstringMatchingRule()); |
| | | assertIndexContainsID(indexers, entry, titleIndex.getSubstringIndex(), entryID); |
| | | indexers = newJEExtensibleIndexers(nameIndexAttrType, nameIndexAttrType.getSubstringMatchingRule()); |
| | | indexers = newAttributeIndexers(nameIndexAttrType, nameIndexAttrType.getSubstringMatchingRule()); |
| | | assertIndexContainsID(indexers, entry, nameIndex.getSubstringIndex(), entryID); |
| | | } |
| | | finally |