opends/src/server/org/opends/server/backends/jeb/AttributeIndex.java
@@ -316,23 +316,6 @@ } /** * Makes a byte array representing an equality index key from * a byte array containing the normalized value. * The key is '=' followed by the normalized value. * * @param normalizedBytes The normalized value. * @return A byte array containing the equality key. */ byte[] makeEqualityKey(byte[] normalizedBytes) { byte[] keyBytes = new byte[1 + normalizedBytes.length]; keyBytes[0] = '='; System.arraycopy(normalizedBytes, 0, keyBytes, 1, normalizedBytes.length); return keyBytes; } /** * Makes a byte array representing a substring index key for * one substring of a value. * @@ -343,9 +326,8 @@ */ private byte[] makeSubstringKey(byte[] bytes, int pos, int len) { byte[] keyBytes = new byte[len + 1]; keyBytes[0] = '*'; System.arraycopy(bytes, pos, keyBytes, 1, len); byte[] keyBytes = new byte[len]; System.arraycopy(bytes, pos, keyBytes, 0, len); return keyBytes; } @@ -478,12 +460,12 @@ // Iterate through all the keys that have this value as the prefix. // Set the lower bound for a range search. byte[] lower = makeEqualityKey(bytes); byte[] lower = bytes; // Set the upper bound for a range search. // We need a key for the upper bound that is of equal length // but slightly greater than the lower bound. byte[] upper = makeEqualityKey(bytes); byte[] upper = bytes; for (int i = upper.length-1; i >= 0; i--) { if (upper[i] == 0xFF) @@ -520,9 +502,8 @@ try { // Make a key from the normalized assertion value. byte[] normBytes = byte[] keyBytes = equalityFilter.getAssertionValue().getNormalizedValue().value(); byte[] keyBytes = makeEqualityKey(normBytes); DatabaseEntry key = new DatabaseEntry(keyBytes); // Read the key. @@ -573,15 +554,12 @@ // Use the ordering matching rule to normalize the value. OrderingMatchingRule orderingRule = filter.getAttributeType().getOrderingMatchingRule(); byte[] normBytes = orderingRule.normalizeValue( byte[] lower = orderingRule.normalizeValue( filter.getAssertionValue().getValue()).value(); byte[] lower = makeEqualityKey(normBytes); // Set the upper bound for a range search. // We need a key for the upper bound that is slightly greater than // the equality key prefix. byte[] upper = makeEqualityKey(new byte[0]); upper[0] = (byte) (upper[0] + 1); // Set the upper bound to 0 to search all keys greater then the lower // bound. byte[] upper = new byte[0]; // Read the range: lower <= keys < upper. return orderingIndex.readRange(lower, upper, true, false); @@ -609,16 +587,16 @@ try { // Set the lower bound for a range search. byte[] lower = makeEqualityKey(new byte[0]); // Set the lower bound to 0 to start the range search from the smallest // key. byte[] lower = new byte[0]; // Set the upper bound for a range search. // Use the ordering matching rule to normalize the value. OrderingMatchingRule orderingRule = filter.getAttributeType().getOrderingMatchingRule(); byte[] normBytes = orderingRule.normalizeValue( byte[] upper = orderingRule.normalizeValue( filter.getAssertionValue().getValue()).value(); byte[] upper = makeEqualityKey(normBytes); // Read the range: lower < keys <= upper. return orderingIndex.readRange(lower, upper, false, true); @@ -742,12 +720,10 @@ byte[] normBytes; // Set the lower bound for a range search. normBytes = orderingRule.normalizeValue(lowerValue.getValue()).value(); byte[] lower = makeEqualityKey(normBytes); byte[] lower = orderingRule.normalizeValue(lowerValue.getValue()).value(); // Set the upper bound for a range search. normBytes = orderingRule.normalizeValue(upperValue.getValue()).value(); byte[] upper = makeEqualityKey(normBytes); byte[] upper = orderingRule.normalizeValue(upperValue.getValue()).value(); // Read the range: lower <= keys <= upper. return orderingIndex.readRange(lower, upper, true, true); opends/src/server/org/opends/server/backends/jeb/EqualityIndexer.java
@@ -273,9 +273,8 @@ { try { byte[] normalizedBytes = value.getNormalizedValue().value(); byte[] keyBytes = value.getNormalizedValue().value(); byte[] keyBytes = makeEqualityKey(normalizedBytes); keys.add(new ASN1OctetString(keyBytes)); } catch (DirectoryException e) @@ -301,25 +300,4 @@ } } /** * Makes a byte array representing an equality index key from * a byte array containing the normalized value. * The key is '=' followed by the normalized value. * FIXME: The '=' prefix is no longer necessary since different index * FIXME: types are no longer stored in the same database, but uses of * FIXME: the Index.readRange method would have to be revisited if the * FIXME: prefix is removed. * * @param normalizedBytes The normalized value. * @return A byte array containing the equality key. */ byte[] makeEqualityKey(byte[] normalizedBytes) { byte[] keyBytes = new byte[1 + normalizedBytes.length]; keyBytes[0] = '='; System.arraycopy(normalizedBytes, 0, keyBytes, 1, normalizedBytes.length); return keyBytes; } } opends/src/server/org/opends/server/backends/jeb/Index.java
@@ -368,14 +368,22 @@ * Reads a range of keys and collects all their entry IDs into a * single set. * * @param lower The lower bound of the range. * @param upper The upper bound of the range. * @param lower The lower bound of the range. A 0 length byte array indicates * no lower bound and the range will start from the * smallest key. * @param upper The upper bound of the range. A 0 length byte array indicates * no upper bound and the range will end at the largest * key. * @param lowerIncluded true if a key exactly matching the lower bound * is included in the range, false if only keys * strictly greater than the lower bound are included. * This value is ignored if the lower bound is not * specified. * @param upperIncluded true if a key exactly matching the upper bound * is included in the range, false if only keys * strictly less than the upper bound are included. * This value is ignored if the upper bound is not * specified. * @return The set of entry IDs. */ public EntryIDSet readRange(byte[] lower, byte[] upper, @@ -389,7 +397,7 @@ int totalIDCount = 0; DatabaseEntry data = new DatabaseEntry(); DatabaseEntry key = new DatabaseEntry(lower); DatabaseEntry key; ArrayList<EntryIDSet> lists = new ArrayList<EntryIDSet>(); @@ -400,6 +408,11 @@ try { // Set the lower bound if necessary. if(lower.length > 0) { key = new DatabaseEntry(lower); // Initialize the cursor to the lower bound. status = cursor.getSearchKeyRange(key, data, lockMode); @@ -410,6 +423,12 @@ // Do not include the lower value. status = cursor.getNext(key, data, lockMode); } } else { key = new DatabaseEntry(); status = cursor.getNext(key, data, lockMode); } if (status != OperationStatus.SUCCESS) { @@ -417,14 +436,18 @@ return new EntryIDSet(key.getData(), null); } // Step through the keys until we hit the upper bound. // Step through the keys until we hit the upper bound or the last key. while (status == OperationStatus.SUCCESS) { // Check against the upper bound if necessary if(upper.length > 0) { int cmp = comparator.compare(key.getData(), upper); if ((cmp > 0) || (cmp == 0 && !upperIncluded)) { break; } } EntryIDSet list = new EntryIDSet(key.getData(), data.getData()); if (!list.isDefined()) { opends/src/server/org/opends/server/backends/jeb/OrderingIndexer.java
@@ -263,10 +263,9 @@ { try { byte[] normalizedBytes = byte[] keyBytes = orderingRule.normalizeValue(value.getValue()).value(); byte[] keyBytes = makeOrderingKey(normalizedBytes); keys.add(new ASN1OctetString(keyBytes)); } catch (DirectoryException e) @@ -292,25 +291,4 @@ } } /** * Makes a byte array representing an ordering index key from * a byte array containing the normalized value. * The key is '=' followed by the normalized value * FIXME: The '=' prefix is no longer necessary since different index * FIXME: types are no longer stored in the same database, but uses of * FIXME: the Index.readRange method would have to be revisited if the * FIXME: prefix is removed. * * @param normalizedBytes The normalized value. * @return A byte array containing the ordering key. */ byte[] makeOrderingKey(byte[] normalizedBytes) { byte[] keyBytes = new byte[1 + normalizedBytes.length]; keyBytes[0] = '='; System.arraycopy(normalizedBytes, 0, keyBytes, 1, normalizedBytes.length); return keyBytes; } } opends/src/server/org/opends/server/backends/jeb/SubstringIndexer.java
@@ -247,9 +247,8 @@ */ private byte[] makeSubstringKey(byte[] bytes, int pos, int len) { byte[] keyBytes = new byte[len + 1]; keyBytes[0] = '*'; System.arraycopy(bytes, pos, keyBytes, 1, len); byte[] keyBytes = new byte[len]; System.arraycopy(bytes, pos, keyBytes, 0, len); return keyBytes; } opends/src/server/org/opends/server/backends/jeb/VerifyJob.java
@@ -1412,8 +1412,7 @@ // Equality index. if (indexConfig.isEqualityIndex()) { byte[] keyBytes = attrIndex.makeEqualityKey(normalizedBytes); DatabaseEntry key = new DatabaseEntry(keyBytes); DatabaseEntry key = new DatabaseEntry(normalizedBytes); try { ConditionResult cr; @@ -1422,12 +1421,12 @@ { System.err.printf("Missing ID %d%n%s", entryID.longValue(), keyDump(equalityIndex, keyBytes)); keyDump(equalityIndex, normalizedBytes)); errorCount++; } else if (cr == ConditionResult.UNDEFINED) { incrEntryLimitStats(equalityIndex, keyBytes); incrEntryLimitStats(equalityIndex, normalizedBytes); } } catch (DatabaseException e) @@ -1435,7 +1434,7 @@ assert debugException(CLASS_NAME, "verifyAttribute", e); System.err.printf("Error reading database: %s%n%s", e.getMessage(), keyDump(equalityIndex, keyBytes)); keyDump(equalityIndex, normalizedBytes)); errorCount++; } } @@ -1486,8 +1485,7 @@ normalizedBytes = orderingRule.normalizeValue(value.getValue()).value(); byte[] keyBytes = attrIndex.makeEqualityKey(normalizedBytes); DatabaseEntry key = new DatabaseEntry(keyBytes); DatabaseEntry key = new DatabaseEntry(normalizedBytes); try { ConditionResult cr; @@ -1496,12 +1494,12 @@ { System.err.printf("Missing ID %d%n%s", entryID.longValue(), keyDump(orderingIndex, keyBytes)); keyDump(orderingIndex, normalizedBytes)); errorCount++; } else if (cr == ConditionResult.UNDEFINED) { incrEntryLimitStats(orderingIndex, keyBytes); incrEntryLimitStats(orderingIndex, normalizedBytes); } } catch (DatabaseException e) @@ -1509,7 +1507,7 @@ assert debugException(CLASS_NAME, "verifyAttribute", e); System.err.printf("Error reading database: %s%n%s", e.getMessage(), keyDump(orderingIndex, keyBytes)); keyDump(orderingIndex, normalizedBytes)); errorCount++; } }