From 172ae4c6e63be576376b32a68c8e8218f202fa22 Mon Sep 17 00:00:00 2001
From: neil_a_wilson <neil_a_wilson@localhost>
Date: Fri, 27 Apr 2007 20:43:17 +0000
Subject: [PATCH] Add initial support for server-side sorting in OpenDS.  This implementation will only work for indexed searches, and it operates by sorting the ID list before iterating through the entries to return them to the client.

---
 opends/src/server/org/opends/server/backends/jeb/IDSetIterator.java |   31 +++++++++++++++++++++++++++++++
 1 files changed, 31 insertions(+), 0 deletions(-)

diff --git a/opends/src/server/org/opends/server/backends/jeb/IDSetIterator.java b/opends/src/server/org/opends/server/backends/jeb/IDSetIterator.java
index f976fbd..4f624b0 100644
--- a/opends/src/server/org/opends/server/backends/jeb/IDSetIterator.java
+++ b/opends/src/server/org/opends/server/backends/jeb/IDSetIterator.java
@@ -54,6 +54,37 @@
   }
 
   /**
+   * Create a new iterator for a given array of entry IDs.
+   * @param entryIDList An array of IDs in order or ID.
+   * @param begin The entry ID of the first entry that should be returned, or
+   *              {@code null} if it should start at the beginning of the list.
+   */
+  public IDSetIterator(long[] entryIDList, EntryID begin)
+  {
+    this.entryIDList = entryIDList;
+
+    if (begin == null)
+    {
+      i = 0;
+    }
+    else
+    {
+      for (i=0; i < entryIDList.length; i++)
+      {
+        if (entryIDList[i] == begin.longValue())
+        {
+          break;
+        }
+      }
+
+      if (i >= entryIDList.length)
+      {
+        i = 0;
+      }
+    }
+  }
+
+  /**
    * Returns <tt>true</tt> if the iteration has more elements. (In other
    * words, returns <tt>true</tt> if <tt>next</tt> would return an element
    * rather than throwing an exception.)

--
Gitblit v1.10.0