From 16247331def711fd3013de17374dc4da61c83951 Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Tue, 16 Dec 2014 11:22:04 +0000
Subject: [PATCH] OPENDJ-1602 (CR-5566) New pluggable storage based backend

---
 opendj3-server-dev/src/server/org/opends/server/backends/pluggable/JebFormat.java |   43 +++++++++++++------------------------------
 1 files changed, 13 insertions(+), 30 deletions(-)

diff --git a/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/JebFormat.java b/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/JebFormat.java
index 383b0b4..2ee3071 100644
--- a/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/JebFormat.java
+++ b/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)

--
Gitblit v1.10.0