From 1815c2396e62b5a1fa6a0414a0dc5e30484a4a3c Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Mon, 01 Jun 2015 09:47:10 +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/ID2Count.java | 27 +++++++++++++++++++++++----
1 files changed, 23 insertions(+), 4 deletions(-)
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/ID2Count.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/ID2Count.java
index 2dfead2..24cf15f 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/ID2Count.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/ID2Count.java
@@ -41,6 +41,7 @@
* Store a counter associated to a key. Counter value is sharded amongst multiple keys to allow concurrent
* update without contention (at the price of a slower read).
*/
+@SuppressWarnings("javadoc")
final class ID2Count extends AbstractTree
{
/**
@@ -70,7 +71,7 @@
@Override
public Long transform(ByteString key, ByteString value) throws NeverThrowsException
{
- return value.toLong();
+ return fromValue(value);
}
});
}
@@ -98,7 +99,7 @@
public ByteSequence computeNewValue(ByteSequence oldValue)
{
final long currentValue = oldValue != null ? oldValue.asReader().getLong() : 0;
- return ByteString.valueOf(currentValue + delta);
+ return toValue(currentValue + delta);
}
});
}
@@ -118,7 +119,7 @@
{
Reject.ifNull(importer, "importer must not be null");
final ByteSequence shardedKey = getShardedKey(entryID);
- importer.put(getName(), shardedKey, ByteString.valueOf(delta));
+ importer.put(getName(), shardedKey, toValue(delta));
}
private ByteSequence getShardedKey(EntryID entryID)
@@ -127,6 +128,25 @@
return getKeyFromEntryIDAndBucket(entryID, bucket);
}
+ ByteSequence toKey(EntryID entryID)
+ {
+ if (entryID == null)
+ {
+ entryID = TOTAL_COUNT_ENTRY_ID;
+ }
+ return getShardedKey(entryID);
+ }
+
+ ByteString toValue(final long count)
+ {
+ return ByteString.valueOf(count);
+ }
+
+ long fromValue(ByteString value)
+ {
+ return value.toLong();
+ }
+
/**
* Get the counter value for the specified key
* @param txn The transaction
@@ -144,7 +164,6 @@
cursor.next();
}
}
-
return counterValue;
}
--
Gitblit v1.10.0