opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/DN2ID.java
@@ -12,7 +12,7 @@ * information: "Portions Copyright [year] [name of copyright owner]". * * Copyright 2006-2010 Sun Microsystems, Inc. * Portions Copyright 2014-2015 ForgeRock AS. * Portions Copyright 2014-2016 ForgeRock AS. */ package org.opends.server.backends.pluggable; @@ -257,23 +257,23 @@ { private final ByteStringBuilder builder; private final ByteSequence limit; private boolean cursorOnParent; private boolean cursorCurrentlyOnParent; ChildrenCursor(Cursor<ByteString, ByteString> delegate) { super(delegate); builder = new ByteStringBuilder(128); limit = delegate.isDefined() ? afterKey(delegate.getKey()) : ByteString.empty(); cursorOnParent = true; limit = delegate.isDefined() ? afterLastChildOf(delegate.getKey()) : ByteString.empty(); cursorCurrentlyOnParent = true; } @Override public boolean next() { if (cursorOnParent) { if (cursorCurrentlyOnParent) { // Go to the first children delegate.next(); cursorOnParent = false; cursorCurrentlyOnParent = false; } else { // Go to the next sibling delegate.positionToKeyOrNext(nextSibling()); @@ -299,7 +299,7 @@ SubtreeCursor(Cursor<ByteString, ByteString> delegate) { super(delegate); limit = delegate.isDefined() ? afterKey(delegate.getKey()) : ByteString.empty(); limit = delegate.isDefined() ? afterLastChildOf(delegate.getKey()) : ByteString.empty(); } @Override opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/DN2URI.java
@@ -608,15 +608,15 @@ * find subordinates of the base entry from the top of the tree downwards. */ ByteString baseDN = toKey(searchOp.getBaseDN()); ByteStringBuilder suffix = beforeKey(baseDN); ByteStringBuilder end = afterKey(baseDN); ByteStringBuilder beforeFirstChild = beforeFirstChildOf(baseDN); ByteStringBuilder afterLastChild = afterLastChildOf(baseDN); try (Cursor<ByteString, ByteString> cursor = txn.openCursor(getName())) { // Initialize the cursor very close to the starting value then // step forward until we pass the ending value. boolean success = cursor.positionToKeyOrNext(suffix); while (success && cursor.getKey().compareTo(end) < 0) boolean success = cursor.positionToKeyOrNext(beforeFirstChild); while (success && cursor.getKey().compareTo(afterLastChild) < 0) { // We have found a subordinate referral. // Make sure the referral is within scope. opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/DnKeyFormat.java
@@ -12,7 +12,7 @@ * information: "Portions Copyright [year] [name of copyright owner]". * * Copyright 2006-2010 Sun Microsystems, Inc. * Portions Copyright 2014-2015 ForgeRock AS. * Portions Copyright 2014-2016 ForgeRock AS. */ package org.opends.server.backends.pluggable; @@ -92,19 +92,19 @@ && key.byteAt(index) == DN.NORMALIZED_RDN_SEPARATOR && key.byteAt(index - 1) != DN.NORMALIZED_ESC_BYTE; } static ByteStringBuilder beforeKey(final ByteSequence key) static ByteStringBuilder beforeFirstChildOf(final ByteSequence key) { final ByteStringBuilder beforeKey = new ByteStringBuilder(key.length() + 1); beforeKey.appendBytes(key); beforeKey.appendByte(0x00); beforeKey.appendByte(DN.NORMALIZED_RDN_SEPARATOR); return beforeKey; } static ByteStringBuilder afterKey(final ByteSequence key) static ByteStringBuilder afterLastChildOf(final ByteSequence key) { final ByteStringBuilder afterKey = new ByteStringBuilder(key.length() + 1); afterKey.appendBytes(key); afterKey.appendByte(0x01); afterKey.appendByte(DN.NORMALIZED_AVA_SEPARATOR); return afterKey; } } opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/EntryContainer.java
@@ -1084,14 +1084,14 @@ /* * We will iterate forwards through a range of the dn2id keys to * find subordinates of the target entry from the top of the tree * downwards. For example, any subordinates of "dc=example,dc=com" appear * in dn2id with a key ending in ",dc=example,dc=com". The entry * "cn=joe,ou=people,dc=example,dc=com" will appear after the entry * downwards. For example, any subordinates of dn "dc=example,dc=com" appear * in dn2id with a dn ending in ",dc=example,dc=com". The dn * "cn=joe,ou=people,dc=example,dc=com" will appear after the dn * "ou=people,dc=example,dc=com". */ ByteString baseDNKey = dnToDNKey(aBaseDN, this.baseDN.size()); ByteStringBuilder suffix = beforeKey(baseDNKey); ByteStringBuilder end = afterKey(baseDNKey); ByteStringBuilder beforeFirstChild = beforeFirstChildOf(baseDNKey); ByteStringBuilder afterLastChild = afterLastChildOf(baseDNKey); // Set the starting value. ByteSequence begin; @@ -1112,7 +1112,7 @@ else { // Set the starting value to the suffix. begin = suffix; begin = beforeFirstChild; } int lookthroughCount = 0; @@ -1124,7 +1124,7 @@ boolean success = cursor.positionToKeyOrNext(begin); // Step forward until we pass the ending value. while (success && cursor.getKey().compareTo(end) < 0) while (success && cursor.getKey().compareTo(afterLastChild) < 0) { if (lookthroughLimit > 0 && lookthroughCount > lookthroughLimit) {