From 540ea316e77eb38f09a74b07365964c2a1161d8e Mon Sep 17 00:00:00 2001
From: Yannick Lecaillez <yannick.lecaillez@forgerock.com>
Date: Tue, 31 Mar 2015 16:02:26 +0000
Subject: [PATCH] OPENDJ-1199: Reduce memory/disk usage of JE backend (variable length encoding for EntryIDSet)

---
 opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/ImportIDSet.java |   15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/ImportIDSet.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/ImportIDSet.java
index 9be82e4..d00cfad 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/ImportIDSet.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/ImportIDSet.java
@@ -29,9 +29,12 @@
 import static org.forgerock.util.Reject.*;
 import static org.opends.server.backends.pluggable.EntryIDSet.*;
 
+import java.util.Iterator;
+
 import org.forgerock.opendj.ldap.ByteSequence;
 import org.forgerock.opendj.ldap.ByteString;
 import org.forgerock.util.Reject;
+import org.opends.server.backends.pluggable.EntryIDSet.EntryIDSetCodec;
 
 /**
  * This class manages the set of ID that are to be eventually added to an index
@@ -39,7 +42,7 @@
  * the configured ID limit. If the limit it reached, the class stops tracking
  * individual IDs and marks the set as undefined. This class is not thread safe.
  */
-final class ImportIDSet {
+final class ImportIDSet implements Iterable<EntryID> {
 
   /** The encapsulated entryIDSet where elements are stored until reaching the limit. */
   private EntryIDSet entryIDSet;
@@ -162,11 +165,17 @@
     return key;
   }
 
+  @Override
+  public Iterator<EntryID> iterator() {
+      return entryIDSet.iterator();
+  }
+
   /**
    * @return Binary representation of this ID set
    */
-  ByteString valueToByteString() {
-    return entryIDSet.toByteString();
+  ByteString valueToByteString(EntryIDSetCodec codec) {
+    checkNotNull(codec, "codec must not be null");
+    return codec.encode(entryIDSet);
   }
 
   @Override

--
Gitblit v1.10.0