You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2013/01/15 12:48:42 UTC

svn commit: r1433362 - /lucene/dev/branches/lucene4547/lucene/core/src/java/org/apache/lucene/index/SortedDocValues.java

Author: mikemccand
Date: Tue Jan 15 11:48:42 2013
New Revision: 1433362

URL: http://svn.apache.org/viewvc?rev=1433362&view=rev
Log:
don't don binary search in two places

Modified:
    lucene/dev/branches/lucene4547/lucene/core/src/java/org/apache/lucene/index/SortedDocValues.java

Modified: lucene/dev/branches/lucene4547/lucene/core/src/java/org/apache/lucene/index/SortedDocValues.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4547/lucene/core/src/java/org/apache/lucene/index/SortedDocValues.java?rev=1433362&r1=1433361&r2=1433362&view=diff
==============================================================================
--- lucene/dev/branches/lucene4547/lucene/core/src/java/org/apache/lucene/index/SortedDocValues.java (original)
+++ lucene/dev/branches/lucene4547/lucene/core/src/java/org/apache/lucene/index/SortedDocValues.java Tue Jan 15 11:48:42 2013
@@ -52,28 +52,21 @@ public abstract class SortedDocValues ex
 
       @Override
       public SeekStatus seekCeil(BytesRef text, boolean useCache /* ignored */) throws IOException {
-        int low = 0;
-        int high = getValueCount()-1;
-        
-        while (low <= high) {
-          int mid = (low + high) >>> 1;
-          seekExact(mid);
-          int cmp = term.compareTo(text);
-
-          if (cmp < 0)
-            low = mid + 1;
-          else if (cmp > 0)
-            high = mid - 1;
-          else {
-            return SeekStatus.FOUND; // key found
-          }
-        }
-        
-        if (low == getValueCount()) {
-          return SeekStatus.END;
+        int ord = lookupTerm(text, term);
+        if (ord > 0) {
+          currentOrd = ord;
+          term.offset = 0;
+          term.copyBytes(text);
+          return SeekStatus.FOUND;
         } else {
-          seekExact(low);
-          return SeekStatus.NOT_FOUND;
+          currentOrd = -ord-1;
+          if (currentOrd == getValueCount()) {
+            return SeekStatus.END;
+          } else {
+            // nocommit hmm can we avoid this "extra" lookup?:
+            lookupOrd(currentOrd, term);
+            return SeekStatus.NOT_FOUND;
+          }
         }
       }