From e9880ffb37cdf3ec13061801d0c81c0dff2f35c2 Mon Sep 17 00:00:00 2001
From: Matthew Swift <matthew.swift@forgerock.com>
Date: Thu, 18 Dec 2014 21:08:18 +0000
Subject: [PATCH] OPENDJ-1602 (CR-5566) New pluggable storage based backend
---
opendj3-server-dev/src/server/org/opends/server/backends/pluggable/VLVIndex.java | 12 ++++++------
opendj3-server-dev/src/server/org/opends/server/backends/pluggable/SortValuesSet.java | 48 +++++++++++++++++++-----------------------------
2 files changed, 25 insertions(+), 35 deletions(-)
diff --git a/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/SortValuesSet.java b/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/SortValuesSet.java
index 75027d8..a172adf 100644
--- a/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/SortValuesSet.java
+++ b/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/SortValuesSet.java
@@ -42,13 +42,10 @@
public class SortValuesSet
{
private long[] entryIDs;
-
private int[] valuesBytesOffsets;
private byte[] valuesBytes;
-
private ByteString key;
-
- private VLVIndex vlvIndex;
+ private final VLVIndex vlvIndex;
/**
* Construct an empty sort values set with the given information.
@@ -57,11 +54,7 @@
*/
public SortValuesSet(VLVIndex vlvIndex)
{
- this.key = ByteString.empty();
- this.entryIDs = null;
- this.valuesBytes = null;
- this.valuesBytesOffsets = null;
- this.vlvIndex = vlvIndex;
+ this(vlvIndex, ByteString.empty(), null, null, null);
}
/**
@@ -81,7 +74,7 @@
return;
}
- entryIDs = getEncodedIDs(value, 0);
+ entryIDs = getEncodedIDs(value);
int valuesBytesOffset = entryIDs.length * 8 + 4;
int valuesBytesLength = value.length() - valuesBytesOffset;
valuesBytes = new byte[valuesBytesLength];
@@ -90,8 +83,15 @@
this.valuesBytesOffsets = null;
}
- private SortValuesSet()
- {}
+ private SortValuesSet(VLVIndex vlvIndex, ByteString key, long[] entryIDs,
+ byte[] valuesBytes, int[] valuesBytesOffsets)
+ {
+ this.vlvIndex = vlvIndex;
+ this.key = key;
+ this.entryIDs = entryIDs;
+ this.valuesBytes = valuesBytes;
+ this.valuesBytesOffsets = valuesBytesOffsets;
+ }
/**
* Add the given entryID and values from these sort values.
@@ -329,19 +329,12 @@
valuesBytesOffsets[updatedValuesBytesOffsets.length];
}
- SortValuesSet splitValuesSet = new SortValuesSet();
-
- splitValuesSet.entryIDs = splitEntryIDs;
- splitValuesSet.key = this.key;
- splitValuesSet.valuesBytes = splitValuesBytes;
- splitValuesSet.valuesBytesOffsets = splitValuesBytesOffsets;
- splitValuesSet.vlvIndex = this.vlvIndex;
-
+ SortValuesSet splitValuesSet = new SortValuesSet(vlvIndex, key,
+ splitEntryIDs, splitValuesBytes, splitValuesBytesOffsets);
entryIDs = updatedEntryIDs;
valuesBytes = updatedValuesBytes;
valuesBytesOffsets = updatedValuesBytesOffsets;
key = null;
-
return splitValuesSet;
}
@@ -379,13 +372,12 @@
* Get the size of the provided encoded set.
*
* @param bytes The encoded bytes of a SortValuesSet to decode the size from.
- * @param offset The byte offset to start decoding.
* @return The size of the provided encoded set.
*/
- public static int getEncodedSize(ByteString bytes, int offset)
+ public static int getEncodedSize(ByteString bytes)
{
int v = 0;
- for (int i = offset; i < offset + 4; i++)
+ for (int i = 0; i < 4; i++)
{
v <<= 8;
v |= (bytes.byteAt(i) & 0xFF);
@@ -397,14 +389,12 @@
* Get the IDs from the provided encoded set.
*
* @param bytes The encoded bytes of a SortValuesSet to decode the IDs from.
- * @param offset The byte offset to start decoding.
* @return The decoded IDs in the provided encoded set.
*/
- public static long[] getEncodedIDs(ByteString bytes, int offset)
+ public static long[] getEncodedIDs(ByteString bytes)
{
- int length = getEncodedSize(bytes, offset) * 8;
- int offset2 = offset + 4;
- ByteString entryIDBytes = bytes.subSequence(offset2, offset2 + length);
+ int length = getEncodedSize(bytes) * 8;
+ ByteString entryIDBytes = bytes.subSequence(4, 4 + length);
return JebFormat.entryIDListFromDatabase(entryIDBytes);
}
diff --git a/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/VLVIndex.java b/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/VLVIndex.java
index f6ed8f3..b7ec6a4 100644
--- a/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/VLVIndex.java
+++ b/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/VLVIndex.java
@@ -230,7 +230,7 @@
{
while (cursor.next())
{
- count.getAndAdd(SortValuesSet.getEncodedSize(cursor.getValue(), 0));
+ count.getAndAdd(SortValuesSet.getEncodedSize(cursor.getValue()));
}
}
finally
@@ -790,7 +790,7 @@
{
logSearchKeyResult(cursor.getKey());
}
- long[] IDs = SortValuesSet.getEncodedIDs(cursor.getValue(), 0);
+ long[] IDs = SortValuesSet.getEncodedIDs(cursor.getValue());
for(int i = startPos + selectedPos - cursorCount;
i < IDs.length && selectedPos < count;
i++, selectedPos++)
@@ -881,13 +881,13 @@
if(includedBeforeCount < beforeCount)
{
- lastIDs = SortValuesSet.getEncodedIDs(cursor.getValue(), 0);
+ lastIDs = SortValuesSet.getEncodedIDs(cursor.getValue());
lastOffset = lastIDs.length - 1;
targetOffset += lastIDs.length;
}
else
{
- targetOffset += SortValuesSet.getEncodedSize(cursor.getValue(), 0);
+ targetOffset += SortValuesSet.getEncodedSize(cursor.getValue());
}
}
@@ -920,7 +920,7 @@
break;
}
- lastIDs = SortValuesSet.getEncodedIDs(cursor.getValue(), 0);
+ lastIDs = SortValuesSet.getEncodedIDs(cursor.getValue());
lastOffset = 0;
afterIDCount += lastIDs.length;
}
@@ -964,7 +964,7 @@
{
logSearchKeyResult(cursor.getKey());
}
- long[] ids = SortValuesSet.getEncodedIDs(cursor.getValue(), 0);
+ long[] ids = SortValuesSet.getEncodedIDs(cursor.getValue());
idSets.add(ids);
currentCount += ids.length;
}
--
Gitblit v1.10.0