From b506a6cd184bd8cf477f7d9a7f968c990f153528 Mon Sep 17 00:00:00 2001
From: Matthew Swift <matthew.swift@forgerock.com>
Date: Mon, 23 Mar 2015 23:03:19 +0000
Subject: [PATCH] OPENDJ-1848 CR-6383: Remove Storage getRMW and putIfAbsent methods
---
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/VLVIndex.java | 19 ++++++++++++++-----
1 files changed, 14 insertions(+), 5 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 5bc65ae..497e679 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
@@ -227,7 +227,7 @@
/** {@inheritDoc} */
@Override
- public void open(WriteableStorage txn) throws StorageRuntimeException
+ void open(WriteableStorage txn) throws StorageRuntimeException
{
super.open(txn);
@@ -402,12 +402,12 @@
DirectoryException
{
ByteString key = encodeKey(entryID, values, types);
- return getSortValuesSet(txn, key, false);
+ ByteString value = txn.read(getName(), key);
+ return decodeSortValuesSet(key, value);
}
- private SortValuesSet getSortValuesSet(ReadableStorage txn, ByteString key, boolean isRMW)
+ private SortValuesSet decodeSortValuesSet(ByteString key, ByteString value)
{
- ByteString value = isRMW ? txn.getRMW(getName(), key) : txn.read(getName(), key);
if (value == null)
{
// There are no records in the database
@@ -544,7 +544,12 @@
break;
}
- final SortValuesSet sortValuesSet = getSortValuesSet(txn, key, true);
+ /*
+ * FIXME: replace getRMW+updates with single call to update()
+ */
+ ByteString value = txn.read(getName(), key);
+ final SortValuesSet sortValuesSet = decodeSortValuesSet(key, value);
+
int oldSize = sortValuesSet.size();
if(key.length() == 0)
{
@@ -581,6 +586,10 @@
int newSize = sortValuesSet.size();
if(newSize >= sortedSetCapacity)
{
+ /*
+ * FIXME: is one record becoming two or three? The call to split() looks like it is changing
+ * the key.
+ */
SortValuesSet splitSortValuesSet = sortValuesSet.split(newSize / 2);
txn.create(getName(), splitSortValuesSet.getKeyBytes(), splitSortValuesSet.toByteString()); // splitAfter
txn.create(getName(), sortValuesSet.getKeyBytes(), sortValuesSet.toByteString()); // after
--
Gitblit v1.10.0