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/schema/CollationMatchingRuleFactory.java | 116 +++++++++++++++-------------------------------------------
1 files changed, 30 insertions(+), 86 deletions(-)
diff --git a/opendj3-server-dev/src/server/org/opends/server/schema/CollationMatchingRuleFactory.java b/opendj3-server-dev/src/server/org/opends/server/schema/CollationMatchingRuleFactory.java
index a6a5b15..a778a52 100644
--- a/opendj3-server-dev/src/server/org/opends/server/schema/CollationMatchingRuleFactory.java
+++ b/opendj3-server-dev/src/server/org/opends/server/schema/CollationMatchingRuleFactory.java
@@ -1350,7 +1350,6 @@
// initialLength, initial, numberofany, anyLength1, any1,
// anyLength2, any2, ..., anyLengthn, anyn, finalLength,
// final
- CollationKey key;
List<Integer> normalizedList = new ArrayList<Integer>();
if (subInitial == null)
@@ -1359,16 +1358,7 @@
}
else
{
- key = collator.getCollationKey(subInitial);
- byte[] initialBytes = key.toByteArray();
-
- // Last 4 bytes are 0s with PRIMARY strength.
- int length = initialBytes.length - 4;
- normalizedList.add(length);
- for (int i = 0; i < length; i++)
- {
- normalizedList.add((int) initialBytes[i]);
- }
+ addLengthAndBytes(subInitial, normalizedList);
}
List<String> subAny = assertion.getAny();
@@ -1381,14 +1371,7 @@
normalizedList.add(subAny.size());
for (String any : subAny)
{
- key = collator.getCollationKey(any);
- byte[] anyBytes = key.toByteArray();
- int length = anyBytes.length - 4;
- normalizedList.add(length);
- for (int i = 0; i < length; i++)
- {
- normalizedList.add((int) anyBytes[i]);
- }
+ addLengthAndBytes(any, normalizedList);
}
}
@@ -1399,14 +1382,7 @@
}
else
{
- key = collator.getCollationKey(subFinal);
- byte[] subFinalBytes = key.toByteArray();
- int length = subFinalBytes.length - 4;
- normalizedList.add(length);
- for (int i = 0; i < length; i++)
- {
- normalizedList.add((int) subFinalBytes[i]);
- }
+ addLengthAndBytes(subFinal, normalizedList);
}
byte[] normalizedBytes = new byte[normalizedList.size()];
@@ -1420,6 +1396,23 @@
+ private void addLengthAndBytes(String substring,
+ List<Integer> normalizedList)
+ {
+ CollationKey key = collator.getCollationKey(substring);
+ byte[] substrBytes = key.toByteArray();
+
+ // Last 4 bytes are 0s with PRIMARY strength.
+ int length = substrBytes.length - 4;
+ normalizedList.add(length);
+ for (int i = 0; i < length; i++)
+ {
+ normalizedList.add((int) substrBytes[i]);
+ }
+ }
+
+
+
/**
* {@inheritDoc}
*/
@@ -1566,50 +1559,6 @@
}
-
- /**
- * Decomposes an attribute value into a set of substring index keys.
- *
- * @param attValue
- * The normalized attribute value
- * @param set
- * A set into which the keys will be inserted.
- */
- private void substringKeys(ByteString attValue, Set<byte[]> keys)
- { // TODO merge with ExtensibleIndexer.getKeys(attrValue, keys);
- // TODO and with AbstractSubstringMatchingRuleImpl.SubstringIndexer.createKeys();
- String value = attValue.toString();
- int keyLength = subIndexer.getSubstringLength();
- for (int i = 0, remain = value.length(); remain > 0; i++, remain--)
- {
- int len = Math.min(keyLength, remain);
- keys.add(makeSubstringKey(value, i, len));
- }
- }
-
-
-
- /**
- * Decomposes an attribute value into a set of substring index keys.
- *
- * @param value
- * The normalized attribute value
- * @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 substringKeys(ByteString attValue,
- Map<byte[], Boolean> modifiedKeys, Boolean insert)
- { // TODO merge with ExtensibleIndexer.getKeys(attrValue, modifiedKeys, insert);
- Set<byte[]> keys = new TreeSet<byte[]>();
- substringKeys(attValue, keys);
- ExtensibleIndexer.computeModifiedKeys(modifiedKeys, insert, keys);
- }
-
-
-
/**
* Makes a byte array representing a substring index key for one
* substring of a value.
@@ -2199,21 +2148,16 @@
* {@inheritDoc}
*/
@Override
- public void getKeys(AttributeValue value, Set<byte[]> keys)
- {
- matchingRule.substringKeys(value.getValue(), keys);
- }
-
-
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void getKeys(AttributeValue attValue,
- Map<byte[], Boolean> modifiedKeys, Boolean insert)
- {
- matchingRule.substringKeys(attValue.getValue(), modifiedKeys, insert);
+ public void getKeys(AttributeValue attValue, Set<byte[]> keys)
+ { // TODO merge with ExtensibleIndexer.getKeys(attrValue, keys);
+ // TODO and with AbstractSubstringMatchingRuleImpl.SubstringIndexer.createKeys();
+ String value = attValue.toString();
+ int keyLength = substringLen;
+ for (int i = 0, remain = value.length(); remain > 0; i++, remain--)
+ {
+ int len = Math.min(keyLength, remain);
+ keys.add(matchingRule.makeSubstringKey(value, i, len));
+ }
}
/** {@inheritDoc} */
--
Gitblit v1.10.0