You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by rm...@apache.org on 2014/06/17 05:01:41 UTC

svn commit: r1603045 - in /lucene/dev/branches/branch_4x: ./ lucene/ lucene/CHANGES.txt lucene/core/ lucene/core/src/java/org/apache/lucene/index/SingletonSortedSetDocValues.java

Author: rmuir
Date: Tue Jun 17 03:01:40 2014
New Revision: 1603045

URL: http://svn.apache.org/r1603045
Log:
LUCENE-5769: SingletonSortedSetDocValues now supports random access ordinals

Modified:
    lucene/dev/branches/branch_4x/   (props changed)
    lucene/dev/branches/branch_4x/lucene/   (props changed)
    lucene/dev/branches/branch_4x/lucene/CHANGES.txt   (contents, props changed)
    lucene/dev/branches/branch_4x/lucene/core/   (props changed)
    lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/index/SingletonSortedSetDocValues.java

Modified: lucene/dev/branches/branch_4x/lucene/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/CHANGES.txt?rev=1603045&r1=1603044&r2=1603045&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/CHANGES.txt (original)
+++ lucene/dev/branches/branch_4x/lucene/CHANGES.txt Tue Jun 17 03:01:40 2014
@@ -194,6 +194,9 @@ Optimizations
 * LUCENE-5767: OrdinalMap optimizations, that mostly help on low cardinalities.
   (Martijn van Groningen, Adrien Grand) 
 
+* LUCENE-5769: SingletonSortedSetDocValues now supports random access ordinals.
+  (Robert Muir)
+
 Bug fixes
 
 * LUCENE-5738: Ensure NativeFSLock prevents opening the file channel for the

Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/index/SingletonSortedSetDocValues.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/index/SingletonSortedSetDocValues.java?rev=1603045&r1=1603044&r2=1603045&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/index/SingletonSortedSetDocValues.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/index/SingletonSortedSetDocValues.java Tue Jun 17 03:01:40 2014
@@ -26,10 +26,10 @@ import org.apache.lucene.util.BytesRef;
  * against e.g. FieldCache.getDocTermOrds that also works for single-valued 
  * fields.
  */
-final class SingletonSortedSetDocValues extends SortedSetDocValues {
+final class SingletonSortedSetDocValues extends RandomAccessOrds {
   private final SortedDocValues in;
-  private int docID;
-  private boolean set;
+  private long currentOrd;
+  private long ord;
   
   /** Creates a multi-valued view over the provided SortedDocValues */
   public SingletonSortedSetDocValues(SortedDocValues in) {
@@ -44,18 +44,14 @@ final class SingletonSortedSetDocValues 
 
   @Override
   public long nextOrd() {
-    if (set) {
-      return NO_MORE_ORDS;
-    } else {
-      set = true;
-      return in.getOrd(docID);
-    }
+    long v = currentOrd;
+    currentOrd = NO_MORE_ORDS;
+    return v;
   }
 
   @Override
   public void setDocument(int docID) {
-    this.docID = docID;
-    set = false;
+    currentOrd = ord = in.getOrd(docID);
   }
 
   @Override
@@ -73,4 +69,19 @@ final class SingletonSortedSetDocValues 
   public long lookupTerm(BytesRef key) {
     return in.lookupTerm(key);
   }
+
+  @Override
+  public long ordAt(int index) {
+    return ord;
+  }
+
+  @Override
+  public int cardinality() {
+    return (int) (ord >>> 63) ^ 1;
+  }
+
+  @Override
+  public TermsEnum termsEnum() {
+    return in.termsEnum();
+  }
 }