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 04:48:45 UTC

svn commit: r1603044 - in /lucene/dev/trunk/lucene: CHANGES.txt core/src/java/org/apache/lucene/index/SingletonSortedSetDocValues.java

Author: rmuir
Date: Tue Jun 17 02:48:44 2014
New Revision: 1603044

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

Modified:
    lucene/dev/trunk/lucene/CHANGES.txt
    lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/SingletonSortedSetDocValues.java

Modified: lucene/dev/trunk/lucene/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/CHANGES.txt?rev=1603044&r1=1603043&r2=1603044&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/CHANGES.txt (original)
+++ lucene/dev/trunk/lucene/CHANGES.txt Tue Jun 17 02:48:44 2014
@@ -285,6 +285,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/trunk/lucene/core/src/java/org/apache/lucene/index/SingletonSortedSetDocValues.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/SingletonSortedSetDocValues.java?rev=1603044&r1=1603043&r2=1603044&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/SingletonSortedSetDocValues.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/SingletonSortedSetDocValues.java Tue Jun 17 02:48:44 2014
@@ -25,10 +25,10 @@ import org.apache.lucene.util.BytesRef;
  * This can be used if you want to have one multi-valued implementation
  * that works for single or multi-valued types.
  */
-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) {
@@ -43,18 +43,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
@@ -72,4 +68,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();
+  }
 }