From 87ea6a1089819313e274c7954ec1cd5513503908 Mon Sep 17 00:00:00 2001
From: boli <boli@localhost>
Date: Wed, 31 Oct 2007 22:19:14 +0000
Subject: [PATCH] This set of fixes mainly address the issues where the JE backend does not handle attributes with options and subtypes correctly when they are being indexed. With this fix: - All values of an indexed attribute type will be indexed correctly on modifies, adds, and deletes. - Updates to subordinate types will now update the superior type if its indexed. - Adding and deleting superior attribute types that are not allowed by any object classes (ie. name) will be correctly handled - Deleting all values from an attribute with no options will no longer delete the values from the same attribute but with options.
---
opendj-sdk/opends/src/server/org/opends/server/backends/jeb/SubstringIndexer.java | 75 +++++++++++++++++++++++++++++--------
1 files changed, 58 insertions(+), 17 deletions(-)
diff --git a/opendj-sdk/opends/src/server/org/opends/server/backends/jeb/SubstringIndexer.java b/opendj-sdk/opends/src/server/org/opends/server/backends/jeb/SubstringIndexer.java
index a9d04c9..9024da4 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/backends/jeb/SubstringIndexer.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/backends/jeb/SubstringIndexer.java
@@ -34,7 +34,6 @@
import java.util.Comparator;
import java.util.HashSet;
-import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
@@ -179,7 +178,37 @@
Set<ASN1OctetString> addKeys,
Set<ASN1OctetString> delKeys)
{
- replaceEntry(txn, oldEntry, newEntry, addKeys, delKeys);
+ List<Attribute> newAttributes = newEntry.getAttribute(attributeType, true);
+ List<Attribute> oldAttributes = oldEntry.getAttribute(attributeType, true);
+ HashSet<AttributeValue> newValues;
+ HashSet<AttributeValue> oldValues;
+
+ if(newAttributes == null)
+ {
+ indexAttribute(oldAttributes, delKeys);
+ }
+ else
+ {
+ if(oldAttributes == null)
+ {
+ indexAttribute(newAttributes, addKeys);
+ }
+ else
+ {
+ HashSet<ASN1OctetString> newKeys =
+ new HashSet<ASN1OctetString>();
+ HashSet<ASN1OctetString> oldKeys =
+ new HashSet<ASN1OctetString>();
+ indexAttribute(newAttributes, newKeys);
+ indexAttribute(oldAttributes, oldKeys);
+
+ addKeys.addAll(newKeys);
+ addKeys.removeAll(oldKeys);
+
+ delKeys.addAll(oldKeys);
+ delKeys.removeAll(newKeys);
+ }
+ }
}
@@ -187,30 +216,42 @@
/**
* Generate the set of substring index keys for an attribute.
* @param attrList The attribute for which substring keys are required.
- * @param addKeys The set into which the generated keys will be inserted.
+ * @param keys The set into which the generated keys will be inserted.
*/
private void indexAttribute(List<Attribute> attrList,
- Set<ASN1OctetString> addKeys)
+ Set<ASN1OctetString> keys)
{
if (attrList == null) return;
for (Attribute attr : attrList)
{
- LinkedHashSet<AttributeValue> values = attr.getValues();
- for (AttributeValue value : values)
- {
- try
- {
- byte[] normalizedBytes = value.getNormalizedValue().value();
+ indexValues(attr.getValues(), keys);
+ }
+ }
- substringKeys(normalizedBytes, addKeys);
- }
- catch (DirectoryException e)
+ /**
+ * Generate the set of index keys for a set of attribute values.
+ * @param values The set of attribute values to be indexed.
+ * @param keys The set into which the keys will be inserted.
+ */
+ private void indexValues(Set<AttributeValue> values,
+ Set<ASN1OctetString> keys)
+ {
+ if (values == null) return;
+
+ for (AttributeValue value : values)
+ {
+ try
+ {
+ byte[] normalizedBytes = value.getNormalizedValue().value();
+
+ substringKeys(normalizedBytes, keys);
+ }
+ catch (DirectoryException e)
+ {
+ if (debugEnabled())
{
- if (debugEnabled())
- {
- TRACER.debugCaught(DebugLogLevel.ERROR, e);
- }
+ TRACER.debugCaught(DebugLogLevel.ERROR, e);
}
}
}
--
Gitblit v1.10.0