From 167b0dde925af61a07bed4ce3cc30def39a802b9 Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Thu, 21 May 2015 08:25:37 +0000
Subject: [PATCH] OPENDJ-2016 Implement new on disk merge import strategy based on storage engine
---
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/VLVIndex.java | 41 ++++++++++++++---------------------------
1 files changed, 14 insertions(+), 27 deletions(-)
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/VLVIndex.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/VLVIndex.java
index b671e73..546937e 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/VLVIndex.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/VLVIndex.java
@@ -91,7 +91,6 @@
{
private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
-
/** The VLV vlvIndex configuration. */
private BackendVLVIndexCfg config;
@@ -349,10 +348,15 @@
{
if (shouldInclude(entry))
{
- buffer.put(this, encodeVLVKey(entry, entryID.longValue()));
+ buffer.put(this, toKey(entry, entryID));
}
}
+ ByteString toKey(final Entry entry, final EntryID entryID)
+ {
+ return encodeVLVKey(entry, entryID.longValue());
+ }
+
private boolean shouldInclude(final Entry entry) throws DirectoryException
{
return entry.getName().matchesBaseAndScope(baseDN, scope) && filter.matchesEntry(entry);
@@ -415,7 +419,7 @@
{
if (shouldInclude(entry))
{
- buffer.remove(this, encodeVLVKey(entry, entryID.longValue()));
+ buffer.remove(this, toKey(entry, entryID));
}
}
@@ -489,16 +493,11 @@
private EntryIDSet evaluateNonVLVRequest(final ReadableTransaction txn, final StringBuilder debugBuilder)
{
- final Cursor<ByteString, ByteString> cursor = txn.openCursor(getName());
- try
+ try (Cursor<ByteString, ByteString> cursor = txn.openCursor(getName()))
{
final long[] selectedIDs = readRange(cursor, count.get(), debugBuilder);
return newDefinedSet(selectedIDs);
}
- finally
- {
- cursor.close();
- }
}
/**
@@ -516,10 +515,9 @@
final ByteString assertion = vlvRequest.getGreaterThanOrEqualAssertion();
final ByteSequence encodedTargetAssertion =
encodeTargetAssertion(sortOrder, assertion, searchOperation, currentCount);
- final Cursor<ByteString, ByteString> cursor = txn.openCursor(getName());
- try
+ try (Cursor<ByteString, ByteString> cursor = txn.openCursor(getName()))
{
- final LinkedList<Long> selectedIDs = new LinkedList<Long>();
+ final LinkedList<Long> selectedIDs = new LinkedList<>();
int targetPosition = 0;
// Don't waste cycles looking for an assertion that does not match anything.
@@ -572,10 +570,6 @@
LDAPResultCode.SUCCESS));
return newDefinedSet(toPrimitiveLongArray(selectedIDs));
}
- finally
- {
- cursor.close();
- }
}
private long[] toPrimitiveLongArray(final List<Long> entryIDs)
@@ -589,9 +583,7 @@
return result;
}
- /**
- * Normalize the assertion using the primary key's ordering matching rule.
- */
+ /** Normalize the assertion using the primary key's ordering matching rule. */
static ByteSequence encodeTargetAssertion(final SortOrder sortOrder, final ByteString assertion,
final SearchOperation searchOperation, final int resultSetSize) throws DirectoryException
{
@@ -669,8 +661,7 @@
}
final int count = 1 + beforeCount + afterCount;
- final Cursor<ByteString, ByteString> cursor = txn.openCursor(getName());
- try
+ try (Cursor<ByteString, ByteString> cursor = txn.openCursor(getName()))
{
final long[] selectedIDs;
if (cursor.positionToIndex(startPos))
@@ -684,10 +675,6 @@
searchOperation.addResponseControl(new VLVResponseControl(targetOffset, currentCount, LDAPResultCode.SUCCESS));
return newDefinedSet(selectedIDs);
}
- finally
- {
- cursor.close();
- }
}
private long[] readRange(final Cursor<ByteString, ByteString> cursor, final int count,
@@ -746,7 +733,7 @@
{
if (shouldInclude(entry))
{
- final ByteString key = encodeVLVKey(entry, entryID.longValue());
+ final ByteString key = toKey(entry, entryID);
return txn.read(getName(), key) != null;
}
return false;
@@ -760,7 +747,7 @@
return builder.toByteString();
}
- ByteString encodeVLVKey(final Entry entry, final long entryID)
+ private ByteString encodeVLVKey(final Entry entry, final long entryID)
{
return encodeVLVKey(sortOrder, entry, entryID);
}
--
Gitblit v1.10.0