From 4cd06b3633e335f68d6cad0ad2483246076775b4 Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Tue, 07 Apr 2015 15:43:34 +0000
Subject: [PATCH] Code simplification in AttributeIndex
---
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/Importer.java | 51 ++++++++++++++++++++++++++++++++++++---------------
1 files changed, 36 insertions(+), 15 deletions(-)
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/Importer.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/Importer.java
index 820e074..a4f5796 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/Importer.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/Importer.java
@@ -657,11 +657,7 @@
{
for (AttributeIndex attributeIndex : suffix.getAttrIndexMap().values())
{
- putInIdContainerMap(attributeIndex.getEqualityIndex());
- putInIdContainerMap(attributeIndex.getPresenceIndex());
- putInIdContainerMap(attributeIndex.getSubstringIndex());
- putInIdContainerMap(attributeIndex.getOrderingIndex());
- putInIdContainerMap(attributeIndex.getApproximateIndex());
+ putInIdContainerMap(attributeIndex.getDefaultNameToIndexes().values());
Map<String, Collection<MatchingRuleIndex>> extensibleMap = attributeIndex.getExtensibleIndexes();
if (!extensibleMap.isEmpty())
{
@@ -1680,11 +1676,11 @@
{
final IndexingOptions options = attrIndex.getIndexingOptions();
- processAttribute(attrIndex.getEqualityIndex(), ImportIndexType.EQUALITY, entry, attrType, entryID, options);
- processAttribute(attrIndex.getPresenceIndex(), ImportIndexType.PRESENCE, entry, attrType, entryID, options);
- processAttribute(attrIndex.getSubstringIndex(), ImportIndexType.SUBSTRING, entry, attrType, entryID, options);
- processAttribute(attrIndex.getOrderingIndex(), ImportIndexType.ORDERING, entry, attrType, entryID, options);
- processAttribute(attrIndex.getApproximateIndex(), ImportIndexType.APPROXIMATE, entry, attrType, entryID, options);
+ for (Map.Entry<String, MatchingRuleIndex> mapEntry : attrIndex.getDefaultNameToIndexes().entrySet())
+ {
+ ImportIndexType indexType = toImportIndexType(mapEntry.getKey());
+ processAttribute(mapEntry.getValue(), indexType, entry, attrType, entryID, options);
+ }
Map<String, Collection<MatchingRuleIndex>> extensibleMap = attrIndex.getExtensibleIndexes();
if (!extensibleMap.isEmpty())
@@ -3090,11 +3086,11 @@
private void rebuildAttributeIndexes(WriteableTransaction txn, AttributeIndex attrIndex, AttributeType attrType,
boolean onlyDegraded) throws StorageRuntimeException
{
- fillIndexMap(txn, attrType, attrIndex.getSubstringIndex(), ImportIndexType.SUBSTRING, onlyDegraded);
- fillIndexMap(txn, attrType, attrIndex.getOrderingIndex(), ImportIndexType.ORDERING, onlyDegraded);
- fillIndexMap(txn, attrType, attrIndex.getEqualityIndex(), ImportIndexType.EQUALITY, onlyDegraded);
- fillIndexMap(txn, attrType, attrIndex.getPresenceIndex(), ImportIndexType.PRESENCE, onlyDegraded);
- fillIndexMap(txn, attrType, attrIndex.getApproximateIndex(), ImportIndexType.APPROXIMATE, onlyDegraded);
+ for (Map.Entry<String, MatchingRuleIndex> mapEntry : attrIndex.getDefaultNameToIndexes().entrySet())
+ {
+ ImportIndexType indexType = toImportIndexType(mapEntry.getKey());
+ fillIndexMap(txn, attrType, mapEntry.getValue(), indexType, onlyDegraded);
+ }
final Map<String, Collection<MatchingRuleIndex>> extensibleMap = attrIndex.getExtensibleIndexes();
if (!extensibleMap.isEmpty())
@@ -3789,6 +3785,31 @@
VLV
}
+ static ImportIndexType toImportIndexType(String indexID)
+ {
+ if (IndexType.EQUALITY.toString().equals(indexID))
+ {
+ return ImportIndexType.EQUALITY;
+ }
+ else if (IndexType.PRESENCE.toString().equals(indexID))
+ {
+ return ImportIndexType.PRESENCE;
+ }
+ else if (IndexType.SUBSTRING.toString().equals(indexID))
+ {
+ return ImportIndexType.SUBSTRING;
+ }
+ else if (IndexType.ORDERING.toString().equals(indexID))
+ {
+ return ImportIndexType.ORDERING;
+ }
+ else if (IndexType.APPROXIMATE.toString().equals(indexID))
+ {
+ return ImportIndexType.APPROXIMATE;
+ }
+ throw new IllegalArgumentException("Unsupported indexID: " + indexID);
+ }
+
/**
* This class is used as an index key for hash maps that need to process
* multiple suffix index elements into a single queue and/or maps based on
--
Gitblit v1.10.0