mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Jean-Noel Rouvignac
16.22.2014 16247331def711fd3013de17374dc4da61c83951
OPENDJ-1602 (CR-5566) New pluggable storage based backend

JebFormat.java:
In entryIDListFromDatabase(ByteSequence), used ByteSequenceReader.getLong().
1 files modified
43 ■■■■■ changed files
opendj3-server-dev/src/server/org/opends/server/backends/pluggable/JebFormat.java 43 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/backends/pluggable/JebFormat.java
@@ -30,6 +30,7 @@
import java.util.TreeSet;
import org.forgerock.opendj.ldap.ByteSequence;
import org.forgerock.opendj.ldap.ByteSequenceReader;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ByteStringBuilder;
import org.opends.server.types.DN;
@@ -43,19 +44,11 @@
public class JebFormat
{
  /**
   * The format version used by this class to encode and decode a ByteString.
   */
  /** The format version used by this class to encode and decode a ByteString. */
  public static final byte FORMAT_VERSION = 0x01;
  /**
   * The ASN1 tag for the ByteString type.
   */
  /** The ASN1 tag for the ByteString type. */
  public static final byte TAG_DATABASE_ENTRY = 0x60;
  /**
   * The ASN1 tag for the DirectoryServerEntry type.
   */
  /** The ASN1 tag for the DirectoryServerEntry type. */
  public static final byte TAG_DIRECTORY_SERVER_ENTRY = 0x61;
  /**
@@ -125,22 +118,14 @@
   */
  public static long[] entryIDListFromDatabase(ByteSequence bytes)
  {
    int count = bytes.length() / 8;
    long[] entryIDList = new long[count];
    for (int pos = 0, i = 0; i < count; i++)
    {
      long v = 0;
      v |= (bytes.byteAt(pos++) & 0xFFL) << 56;
      v |= (bytes.byteAt(pos++) & 0xFFL) << 48;
      v |= (bytes.byteAt(pos++) & 0xFFL) << 40;
      v |= (bytes.byteAt(pos++) & 0xFFL) << 32;
      v |= (bytes.byteAt(pos++) & 0xFFL) << 24;
      v |= (bytes.byteAt(pos++) & 0xFFL) << 16;
      v |= (bytes.byteAt(pos++) & 0xFFL) << 8;
      v |= (bytes.byteAt(pos++) & 0xFFL);
      entryIDList[i] = v;
    }
    final ByteSequenceReader r = bytes.asReader();
    final int count = bytes.length() / 8;
    final long[] entryIDList = new long[count];
    for (int i = 0; i < count; i++)
    {
      entryIDList[i] = r.getLong();
    }
    return entryIDList;
  }
@@ -291,8 +276,7 @@
      return -1;
    }
    // We will walk backwords through the buffer and find the first
    // unescaped comma
    // We will walk backwards through the buffer and find the first unescaped comma
    for(int i = offset+length - 1; i >= offset; i--)
    {
      if(dnKey[i] == 0x00 && i-1 >= offset && dnKey[i-1] != 0x5C)
@@ -311,8 +295,7 @@
      return -1;
    }
    // We will walk backwords through the buffer and find the first
    // unescaped comma
    // We will walk backwards through the buffer and find the first unescaped comma
    for (int i = dnKey.length() - 1; i >= 0; i--)
    {
      if (dnKey.byteAt(i) == 0x00 && i - 1 >= 0 && dnKey.byteAt(i - 1) != 0x5C)