From 3ab9614db1a1a1a30c271424c4189999bf71b87a Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Fri, 07 Mar 2014 10:58:03 +0000
Subject: [PATCH] OPENDJ-1308 Migrate schema support
---
opendj3-server-dev/src/server/org/opends/server/backends/jeb/EqualityIndexer.java | 176 +++-------------------------------------------------------
1 files changed, 11 insertions(+), 165 deletions(-)
diff --git a/opendj3-server-dev/src/server/org/opends/server/backends/jeb/EqualityIndexer.java b/opendj3-server-dev/src/server/org/opends/server/backends/jeb/EqualityIndexer.java
index 6ae0286..cc287fd 100644
--- a/opendj3-server-dev/src/server/org/opends/server/backends/jeb/EqualityIndexer.java
+++ b/opendj3-server-dev/src/server/org/opends/server/backends/jeb/EqualityIndexer.java
@@ -26,159 +26,38 @@
*/
package org.opends.server.backends.jeb;
-import java.util.*;
+import java.util.Set;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.opends.server.api.ExtensibleIndexer;
-import org.opends.server.types.Attribute;
-import org.opends.server.types.AttributeType;
import org.opends.server.types.AttributeValue;
import org.opends.server.types.DirectoryException;
-import org.opends.server.types.Entry;
-import org.opends.server.types.Modification;
/**
* An implementation of an Indexer for attribute equality.
*/
-public class EqualityIndexer extends Indexer
+public class EqualityIndexer extends ExtensibleIndexer
{
private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
-
-
- /**
- * The comparator for index keys generated by this class.
- */
- private static final Comparator<byte[]> comparator =
- new AttributeIndex.KeyComparator();
-
- /**
- * The attribute type for which this instance will
- * generate index keys.
- */
- private AttributeType attributeType;
-
-
- /**
- * Create a new attribute equality indexer for the given attribute type.
- * @param attributeType The attribute type for which an indexer is
- * required.
- */
- public EqualityIndexer(AttributeType attributeType)
- {
- this.attributeType = attributeType;
- }
-
- /**
- * Get a string representation of this object. The returned value is
- * used to name an index created using this object.
- * @return A string representation of this object.
- */
+ /** {@inheritDoc} */
@Override
- public String toString()
+ public String getIndexID()
{
- return attributeType.getNameOrOID() + ".equality";
+ // TODO Auto-generated method stub
+ throw new RuntimeException();
}
- /**
- * Get the comparator that must be used to compare index keys
- * generated by this class.
- *
- * @return A byte array comparator.
- */
+ /** {@inheritDoc} */
@Override
- public Comparator<byte[]> getComparator()
+ public String getExtensibleIndexID()
{
- return comparator;
+ return "equality";
}
-
-
- /**
- * Generate the set of index keys for an entry.
- *
- * @param entry The entry.
- * @param keys The set into which the generated keys will be inserted.
- */
+ /** {@inheritDoc} */
@Override
- public void indexEntry(Entry entry, Set<byte[]> keys)
- {
- List<Attribute> attrList =
- entry.getAttribute(attributeType);
- if (attrList != null)
- {
- indexAttribute(attrList, keys);
- }
- }
-
-
-
- /**
- * Generate the set of index keys to be added and the set of index keys
- * to be deleted for an entry that has been replaced.
- *
- * @param oldEntry The original entry contents.
- * @param newEntry The new entry contents.
- * @param modifiedKeys The map into which the modified keys will be inserted.
- */
- @Override
- public void replaceEntry(Entry oldEntry, Entry newEntry,
- Map<byte[], Boolean> modifiedKeys)
- {
- List<Attribute> newAttributes = newEntry.getAttribute(attributeType, true);
- List<Attribute> oldAttributes = oldEntry.getAttribute(attributeType, true);
-
- indexAttribute(oldAttributes, modifiedKeys, false);
- indexAttribute(newAttributes, modifiedKeys, true);
- }
-
-
-
-
- /**
- * Generate the set of index keys to be added and the set of index keys
- * to be deleted for an entry that was modified.
- *
- * @param oldEntry The original entry contents.
- * @param newEntry The new entry contents.
- * @param mods The set of modifications that were applied to the entry.
- * @param modifiedKeys The map into which the modified keys will be inserted.
- */
- @Override
- public void modifyEntry(Entry oldEntry, Entry newEntry,
- List<Modification> mods,
- Map<byte[], Boolean> modifiedKeys)
- {
- List<Attribute> newAttributes = newEntry.getAttribute(attributeType, true);
- List<Attribute> oldAttributes = oldEntry.getAttribute(attributeType, true);
-
- indexAttribute(oldAttributes, modifiedKeys, false);
- indexAttribute(newAttributes, modifiedKeys, true);
- }
-
- /**
- * Generate the set of index keys for an attribute.
- * @param attrList The attribute to be indexed.
- * @param keys The set into which the keys will be inserted.
- */
- private void indexAttribute(List<Attribute> attrList,
- Set<byte[]> keys)
- {
- if (attrList == null) return;
-
- for (Attribute attr : attrList)
- {
- if (!attr.isVirtual())
- {
- for (AttributeValue value : attr)
- {
- getKeys(value, keys);
- }
- }
- }
- }
-
- private void getKeys(AttributeValue value, Set<byte[]> keys)
+ public void getKeys(AttributeValue value, Set<byte[]> keys)
{
try
{
@@ -190,37 +69,4 @@
}
}
- /**
- * Generate the set of index keys for an attribute.
- * @param attrList The attribute to be indexed.
- * @param modifiedKeys The map into which the modified
- * keys will be inserted.
- * @param insert <code>true</code> if generated keys should
- * be inserted or <code>false</code> otherwise.
- */
- private void indexAttribute(List<Attribute> attrList,
- Map<byte[], Boolean> modifiedKeys,
- Boolean insert)
- {
- if (attrList == null) return;
-
- for (Attribute attr : attrList)
- {
- if (!attr.isVirtual())
- {
- for (AttributeValue value : attr)
- {
- getKeys(value, modifiedKeys, insert);
- }
- }
- }
- }
-
- private void getKeys(AttributeValue value, Map<byte[], Boolean> modifiedKeys,
- Boolean insert)
- {
- Set<byte[]> keys = new HashSet<byte[]>();
- getKeys(value, keys);
- ExtensibleIndexer.computeModifiedKeys(modifiedKeys, insert, keys);
- }
}
--
Gitblit v1.10.0