From 96cec6349e08df6630bae1932cca8d831d0fb123 Mon Sep 17 00:00:00 2001
From: Matthew Swift <matthew.swift@forgerock.com>
Date: Thu, 09 Apr 2015 22:45:43 +0000
Subject: [PATCH] Minor code cleanup:

---
 opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/AttributeIndex.java |   77 +++++++++++++++-----------------------
 1 files changed, 31 insertions(+), 46 deletions(-)

diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/AttributeIndex.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/AttributeIndex.java
index 4cec4dc..66fce6e 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/AttributeIndex.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/AttributeIndex.java
@@ -390,12 +390,39 @@
   }
 
   /**
-   * Get the JE index configuration used by this index.
-   * @return The configuration in effect.
+   * Returns {@code true} if this attribute index supports the provided index type.
+   *
+   * @param indexType
+   *          The index type.
+   * @return {@code true} if this attribute index supports the provided index type.
    */
-  BackendIndexCfg getConfiguration()
+  boolean isIndexed(org.opends.server.types.IndexType indexType)
   {
-    return config;
+    Set<IndexType> indexTypes = config.getIndexType();
+    switch (indexType)
+    {
+    case PRESENCE:
+      return indexTypes.contains(IndexType.PRESENCE);
+
+    case EQUALITY:
+      return indexTypes.contains(IndexType.EQUALITY);
+
+    case SUBSTRING:
+    case SUBINITIAL:
+    case SUBANY:
+    case SUBFINAL:
+      return indexTypes.contains(IndexType.SUBSTRING);
+
+    case GREATER_OR_EQUAL:
+    case LESS_OR_EQUAL:
+      return indexTypes.contains(IndexType.ORDERING);
+
+    case APPROXIMATE:
+      return indexTypes.contains(IndexType.APPROXIMATE);
+
+    default:
+      return false;
+    }
   }
 
   /**
@@ -482,39 +509,6 @@
   }
 
   /**
-   * Decompose an attribute value into a set of substring index keys.
-   * The ID of the entry containing this value should be inserted
-   * into the list of each of these keys.
-   *
-   * @param normValue A byte array containing the normalized attribute value.
-   * @return A set of index keys.
-   */
-  Set<ByteString> substringKeys(ByteString normValue)
-  { // FIXME replace this code with SDK's
-    // AbstractSubstringMatchingRuleImpl.SubstringIndexer.createKeys()
-
-    // Eliminate duplicates by putting the keys into a set.
-    // Sorting the keys will ensure database record locks are acquired
-    // in a consistent order and help prevent transaction deadlocks between
-    // concurrent writers.
-    Set<ByteString> set = new HashSet<ByteString>();
-
-    int substrLength = config.getSubstringLength();
-
-    // Example: The value is ABCDE and the substring length is 3.
-    // We produce the keys ABC BCD CDE DE E
-    // To find values containing a short substring such as DE,
-    // iterate through keys with prefix DE. To find values
-    // containing a longer substring such as BCDE, read keys BCD and CDE.
-    for (int i = 0, remain = normValue.length(); remain > 0; i++, remain--)
-    {
-      int len = Math.min(substrLength, remain);
-      set.add(normValue.subSequence(i, i + len));
-    }
-    return set;
-  }
-
-  /**
    * Retrieve the entry IDs that might match the provided assertion.
    *
    * @param indexQuery
@@ -674,15 +668,6 @@
   }
 
   /**
-   * Get a list of the databases opened by this attribute index.
-   * @param dbList A list of database containers.
-   */
-  void listDatabases(List<DatabaseContainer> dbList)
-  {
-    dbList.addAll(nameToIndexes.values());
-  }
-
-  /**
    * Get a string representation of this object.
    * @return return A string representation of this object.
    */

--
Gitblit v1.10.0