lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rm...@apache.org
Subject svn commit: r1586607 - in /lucene/dev/branches/lucene_solr_4_8: ./ lucene/ lucene/codecs/ lucene/codecs/src/java/org/apache/lucene/codecs/memory/ lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/ lucene/core/ lucene/core/src/java/org/apache/l...
Date Fri, 11 Apr 2014 09:14:06 GMT
Author: rmuir
Date: Fri Apr 11 09:14:05 2014
New Revision: 1586607

URL: http://svn.apache.org/r1586607
Log:
LUCENE-5573: Move docvalues constants and helper methods to o.a.l.index.DocValues

Added:
    lucene/dev/branches/lucene_solr_4_8/lucene/core/src/java/org/apache/lucene/index/DocValues.java
      - copied unchanged from r1586604, lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/index/DocValues.java
Modified:
    lucene/dev/branches/lucene_solr_4_8/   (props changed)
    lucene/dev/branches/lucene_solr_4_8/lucene/   (props changed)
    lucene/dev/branches/lucene_solr_4_8/lucene/CHANGES.txt   (contents, props changed)
    lucene/dev/branches/lucene_solr_4_8/lucene/codecs/   (props changed)
    lucene/dev/branches/lucene_solr_4_8/lucene/codecs/src/java/org/apache/lucene/codecs/memory/DirectDocValuesProducer.java
    lucene/dev/branches/lucene_solr_4_8/lucene/codecs/src/java/org/apache/lucene/codecs/memory/MemoryDocValuesProducer.java
    lucene/dev/branches/lucene_solr_4_8/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextDocValuesReader.java
    lucene/dev/branches/lucene_solr_4_8/lucene/core/   (props changed)
    lucene/dev/branches/lucene_solr_4_8/lucene/core/src/java/org/apache/lucene/codecs/DocValuesProducer.java
    lucene/dev/branches/lucene_solr_4_8/lucene/core/src/java/org/apache/lucene/codecs/lucene42/Lucene42DocValuesProducer.java
    lucene/dev/branches/lucene_solr_4_8/lucene/core/src/java/org/apache/lucene/codecs/lucene45/Lucene45DocValuesProducer.java
    lucene/dev/branches/lucene_solr_4_8/lucene/core/src/java/org/apache/lucene/index/BinaryDocValues.java
    lucene/dev/branches/lucene_solr_4_8/lucene/core/src/java/org/apache/lucene/index/DocTermOrds.java
    lucene/dev/branches/lucene_solr_4_8/lucene/core/src/java/org/apache/lucene/index/MultiDocValues.java
    lucene/dev/branches/lucene_solr_4_8/lucene/core/src/java/org/apache/lucene/index/NumericDocValues.java
    lucene/dev/branches/lucene_solr_4_8/lucene/core/src/java/org/apache/lucene/index/SegmentMerger.java
    lucene/dev/branches/lucene_solr_4_8/lucene/core/src/java/org/apache/lucene/index/SingletonSortedSetDocValues.java
    lucene/dev/branches/lucene_solr_4_8/lucene/core/src/java/org/apache/lucene/index/SlowCompositeReaderWrapper.java
    lucene/dev/branches/lucene_solr_4_8/lucene/core/src/java/org/apache/lucene/index/SortedDocValues.java
    lucene/dev/branches/lucene_solr_4_8/lucene/core/src/java/org/apache/lucene/index/SortedSetDocValues.java
    lucene/dev/branches/lucene_solr_4_8/lucene/core/src/java/org/apache/lucene/search/FieldCacheImpl.java
    lucene/dev/branches/lucene_solr_4_8/lucene/facet/   (props changed)
    lucene/dev/branches/lucene_solr_4_8/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/DocValuesOrdinalsReader.java
    lucene/dev/branches/lucene_solr_4_8/lucene/sandbox/   (props changed)
    lucene/dev/branches/lucene_solr_4_8/lucene/sandbox/src/java/org/apache/lucene/sandbox/queries/SortedSetSortField.java
    lucene/dev/branches/lucene_solr_4_8/lucene/test-framework/   (props changed)
    lucene/dev/branches/lucene_solr_4_8/lucene/test-framework/src/java/org/apache/lucene/index/BaseDocValuesFormatTestCase.java
    lucene/dev/branches/lucene_solr_4_8/solr/   (props changed)
    lucene/dev/branches/lucene_solr_4_8/solr/core/   (props changed)
    lucene/dev/branches/lucene_solr_4_8/solr/core/src/java/org/apache/solr/request/DocValuesFacets.java

Modified: lucene/dev/branches/lucene_solr_4_8/lucene/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_4_8/lucene/CHANGES.txt?rev=1586607&r1=1586606&r2=1586607&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_4_8/lucene/CHANGES.txt (original)
+++ lucene/dev/branches/lucene_solr_4_8/lucene/CHANGES.txt Fri Apr 11 09:14:05 2014
@@ -144,6 +144,9 @@ API Changes
 
 * LUCENE-5565: Refactor SpatialPrefixTree/Cell to not use Strings. (David Smiley)
 
+* LUCENE-5573: Move docvalues constants and helper methods to o.a.l.index.DocValues.
+  (Dawid Weiss, Robert Muir)
+
 Optimizations
 
 * LUCENE-5468: HunspellStemFilter uses 10 to 100x less RAM. It also loads

Modified: lucene/dev/branches/lucene_solr_4_8/lucene/codecs/src/java/org/apache/lucene/codecs/memory/DirectDocValuesProducer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_4_8/lucene/codecs/src/java/org/apache/lucene/codecs/memory/DirectDocValuesProducer.java?rev=1586607&r1=1586606&r2=1586607&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_4_8/lucene/codecs/src/java/org/apache/lucene/codecs/memory/DirectDocValuesProducer.java
(original)
+++ lucene/dev/branches/lucene_solr_4_8/lucene/codecs/src/java/org/apache/lucene/codecs/memory/DirectDocValuesProducer.java
Fri Apr 11 09:14:05 2014
@@ -26,6 +26,7 @@ import org.apache.lucene.codecs.CodecUti
 import org.apache.lucene.codecs.DocValuesProducer;
 import org.apache.lucene.index.BinaryDocValues;
 import org.apache.lucene.index.CorruptIndexException;
+import org.apache.lucene.index.DocValues;
 import org.apache.lucene.index.FieldInfo;
 import org.apache.lucene.index.IndexFileNames;
 import org.apache.lucene.index.NumericDocValues;
@@ -446,9 +447,9 @@ class DirectDocValuesProducer extends Do
   public Bits getDocsWithField(FieldInfo field) throws IOException {
     switch(field.getDocValuesType()) {
       case SORTED_SET:
-        return new SortedSetDocsWithField(getSortedSet(field), maxDoc);
+        return DocValues.docsWithValue(getSortedSet(field), maxDoc);
       case SORTED:
-        return new SortedDocsWithField(getSorted(field), maxDoc);
+        return DocValues.docsWithValue(getSorted(field), maxDoc);
       case BINARY:
         BinaryEntry be = binaries.get(field.number);
         return getMissingBits(field.number, be.missingOffset, be.missingBytes);

Modified: lucene/dev/branches/lucene_solr_4_8/lucene/codecs/src/java/org/apache/lucene/codecs/memory/MemoryDocValuesProducer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_4_8/lucene/codecs/src/java/org/apache/lucene/codecs/memory/MemoryDocValuesProducer.java?rev=1586607&r1=1586606&r2=1586607&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_4_8/lucene/codecs/src/java/org/apache/lucene/codecs/memory/MemoryDocValuesProducer.java
(original)
+++ lucene/dev/branches/lucene_solr_4_8/lucene/codecs/src/java/org/apache/lucene/codecs/memory/MemoryDocValuesProducer.java
Fri Apr 11 09:14:05 2014
@@ -27,6 +27,7 @@ import org.apache.lucene.codecs.CodecUti
 import org.apache.lucene.codecs.DocValuesProducer;
 import org.apache.lucene.index.BinaryDocValues;
 import org.apache.lucene.index.CorruptIndexException;
+import org.apache.lucene.index.DocValues;
 import org.apache.lucene.index.DocsAndPositionsEnum;
 import org.apache.lucene.index.DocsEnum;
 import org.apache.lucene.index.FieldInfo;
@@ -322,7 +323,7 @@ class MemoryDocValuesProducer extends Do
   public SortedDocValues getSorted(FieldInfo field) throws IOException {
     final FSTEntry entry = fsts.get(field.number);
     if (entry.numOrds == 0) {
-      return SortedDocValues.EMPTY;
+      return DocValues.EMPTY_SORTED;
     }
     FST<Long> instance;
     synchronized(this) {
@@ -397,7 +398,7 @@ class MemoryDocValuesProducer extends Do
   public SortedSetDocValues getSortedSet(FieldInfo field) throws IOException {
     final FSTEntry entry = fsts.get(field.number);
     if (entry.numOrds == 0) {
-      return SortedSetDocValues.EMPTY; // empty FST!
+      return DocValues.EMPTY_SORTED_SET; // empty FST!
     }
     FST<Long> instance;
     synchronized(this) {
@@ -510,9 +511,9 @@ class MemoryDocValuesProducer extends Do
   public Bits getDocsWithField(FieldInfo field) throws IOException {
     switch(field.getDocValuesType()) {
       case SORTED_SET:
-        return new SortedSetDocsWithField(getSortedSet(field), maxDoc);
+        return DocValues.docsWithValue(getSortedSet(field), maxDoc);
       case SORTED:
-        return new SortedDocsWithField(getSorted(field), maxDoc);
+        return DocValues.docsWithValue(getSorted(field), maxDoc);
       case BINARY:
         BinaryEntry be = binaries.get(field.number);
         return getMissingBits(field.number, be.missingOffset, be.missingBytes);

Modified: lucene/dev/branches/lucene_solr_4_8/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextDocValuesReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_4_8/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextDocValuesReader.java?rev=1586607&r1=1586606&r2=1586607&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_4_8/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextDocValuesReader.java
(original)
+++ lucene/dev/branches/lucene_solr_4_8/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextDocValuesReader.java
Fri Apr 11 09:14:05 2014
@@ -41,6 +41,7 @@ import java.util.Map;
 import org.apache.lucene.codecs.DocValuesProducer;
 import org.apache.lucene.index.BinaryDocValues;
 import org.apache.lucene.index.CorruptIndexException;
+import org.apache.lucene.index.DocValues;
 import org.apache.lucene.index.FieldInfo;
 import org.apache.lucene.index.FieldInfo.DocValuesType;
 import org.apache.lucene.index.IndexFileNames;
@@ -433,9 +434,9 @@ class SimpleTextDocValuesReader extends 
   public Bits getDocsWithField(FieldInfo field) throws IOException {
     switch (field.getDocValuesType()) {
       case SORTED_SET:
-        return new SortedSetDocsWithField(getSortedSet(field), maxDoc);
+        return DocValues.docsWithValue(getSortedSet(field), maxDoc);
       case SORTED:
-        return new SortedDocsWithField(getSorted(field), maxDoc);
+        return DocValues.docsWithValue(getSorted(field), maxDoc);
       case BINARY:
         return getBinaryDocsWithField(field);
       case NUMERIC:

Modified: lucene/dev/branches/lucene_solr_4_8/lucene/core/src/java/org/apache/lucene/codecs/DocValuesProducer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_4_8/lucene/core/src/java/org/apache/lucene/codecs/DocValuesProducer.java?rev=1586607&r1=1586606&r2=1586607&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_4_8/lucene/core/src/java/org/apache/lucene/codecs/DocValuesProducer.java
(original)
+++ lucene/dev/branches/lucene_solr_4_8/lucene/core/src/java/org/apache/lucene/codecs/DocValuesProducer.java
Fri Apr 11 09:14:05 2014
@@ -75,61 +75,4 @@ public abstract class DocValuesProducer 
    * @lucene.internal
    */
   public abstract void checkIntegrity() throws IOException;
-  
-  /** 
-   * A simple implementation of {@link DocValuesProducer#getDocsWithField} that 
-   * returns {@code true} if a document has an ordinal &gt;= 0
-   * <p>
-   * Codecs can choose to use this (or implement it more efficiently another way), but
-   * in most cases a Bits is unnecessary anyway: users can check this as they go.
-   */
-  public static class SortedDocsWithField implements Bits {
-    final SortedDocValues in;
-    final int maxDoc;
-    
-    /** Creates a {@link Bits} returning true if the document has a value */
-    public SortedDocsWithField(SortedDocValues in, int maxDoc) {
-      this.in = in;
-      this.maxDoc = maxDoc;
-    }
-    
-    @Override
-    public boolean get(int index) {
-      return in.getOrd(index) >= 0;
-    }
-
-    @Override
-    public int length() {
-      return maxDoc;
-    }
-  }
-  
-  /** 
-   * A simple implementation of {@link DocValuesProducer#getDocsWithField} that 
-   * returns {@code true} if a document has any ordinals.
-   * <p>
-   * Codecs can choose to use this (or implement it more efficiently another way), but
-   * in most cases a Bits is unnecessary anyway: users can check this as they go.
-   */
-  public static class SortedSetDocsWithField implements Bits {
-    final SortedSetDocValues in;
-    final int maxDoc;
-    
-    /** Creates a {@link Bits} returning true if the document has a value */
-    public SortedSetDocsWithField(SortedSetDocValues in, int maxDoc) {
-      this.in = in;
-      this.maxDoc = maxDoc;
-    }
-    
-    @Override
-    public boolean get(int index) {
-      in.setDocument(index);
-      return in.nextOrd() != SortedSetDocValues.NO_MORE_ORDS;
-    }
-
-    @Override
-    public int length() {
-      return maxDoc;
-    }
-  }
 }

Modified: lucene/dev/branches/lucene_solr_4_8/lucene/core/src/java/org/apache/lucene/codecs/lucene42/Lucene42DocValuesProducer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_4_8/lucene/core/src/java/org/apache/lucene/codecs/lucene42/Lucene42DocValuesProducer.java?rev=1586607&r1=1586606&r2=1586607&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_4_8/lucene/core/src/java/org/apache/lucene/codecs/lucene42/Lucene42DocValuesProducer.java
(original)
+++ lucene/dev/branches/lucene_solr_4_8/lucene/core/src/java/org/apache/lucene/codecs/lucene42/Lucene42DocValuesProducer.java
Fri Apr 11 09:14:05 2014
@@ -27,6 +27,7 @@ import org.apache.lucene.codecs.CodecUti
 import org.apache.lucene.codecs.DocValuesProducer;
 import org.apache.lucene.index.BinaryDocValues;
 import org.apache.lucene.index.CorruptIndexException;
+import org.apache.lucene.index.DocValues;
 import org.apache.lucene.index.DocsAndPositionsEnum;
 import org.apache.lucene.index.DocsEnum;
 import org.apache.lucene.index.FieldInfo;
@@ -381,7 +382,7 @@ class Lucene42DocValuesProducer extends 
   public SortedSetDocValues getSortedSet(FieldInfo field) throws IOException {
     final FSTEntry entry = fsts.get(field.number);
     if (entry.numOrds == 0) {
-      return SortedSetDocValues.EMPTY; // empty FST!
+      return DocValues.EMPTY_SORTED_SET; // empty FST!
     }
     FST<Long> instance;
     synchronized(this) {
@@ -470,7 +471,7 @@ class Lucene42DocValuesProducer extends 
   @Override
   public Bits getDocsWithField(FieldInfo field) throws IOException {
     if (field.getDocValuesType() == FieldInfo.DocValuesType.SORTED_SET) {
-      return new SortedSetDocsWithField(getSortedSet(field), maxDoc);
+      return DocValues.docsWithValue(getSortedSet(field), maxDoc);
     } else {
       return new Bits.MatchAllBits(maxDoc);
     }

Modified: lucene/dev/branches/lucene_solr_4_8/lucene/core/src/java/org/apache/lucene/codecs/lucene45/Lucene45DocValuesProducer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_4_8/lucene/core/src/java/org/apache/lucene/codecs/lucene45/Lucene45DocValuesProducer.java?rev=1586607&r1=1586606&r2=1586607&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_4_8/lucene/core/src/java/org/apache/lucene/codecs/lucene45/Lucene45DocValuesProducer.java
(original)
+++ lucene/dev/branches/lucene_solr_4_8/lucene/core/src/java/org/apache/lucene/codecs/lucene45/Lucene45DocValuesProducer.java
Fri Apr 11 09:14:05 2014
@@ -38,6 +38,7 @@ import org.apache.lucene.codecs.CodecUti
 import org.apache.lucene.codecs.DocValuesProducer;
 import org.apache.lucene.index.BinaryDocValues;
 import org.apache.lucene.index.CorruptIndexException;
+import org.apache.lucene.index.DocValues;
 import org.apache.lucene.index.DocsAndPositionsEnum;
 import org.apache.lucene.index.DocsEnum;
 import org.apache.lucene.index.FieldInfo;
@@ -46,7 +47,6 @@ import org.apache.lucene.index.IndexFile
 import org.apache.lucene.index.NumericDocValues;
 import org.apache.lucene.index.RandomAccessOrds;
 import org.apache.lucene.index.SegmentReadState;
-import org.apache.lucene.index.SingletonSortedSetDocValues;
 import org.apache.lucene.index.SortedDocValues;
 import org.apache.lucene.index.SortedSetDocValues;
 import org.apache.lucene.index.TermsEnum;
@@ -526,7 +526,7 @@ public class Lucene45DocValuesProducer e
     SortedSetEntry ss = sortedSets.get(field.number);
     if (ss.format == SORTED_SET_SINGLE_VALUED_SORTED) {
       final SortedDocValues values = getSorted(field);
-      return new SingletonSortedSetDocValues(values);
+      return DocValues.singleton(values);
     } else if (ss.format != SORTED_SET_WITH_ADDRESSES) {
       throw new AssertionError();
     }
@@ -630,9 +630,9 @@ public class Lucene45DocValuesProducer e
   public Bits getDocsWithField(FieldInfo field) throws IOException {
     switch(field.getDocValuesType()) {
       case SORTED_SET:
-        return new SortedSetDocsWithField(getSortedSet(field), maxDoc);
+        return DocValues.docsWithValue(getSortedSet(field), maxDoc);
       case SORTED:
-        return new SortedDocsWithField(getSorted(field), maxDoc);
+        return DocValues.docsWithValue(getSorted(field), maxDoc);
       case BINARY:
         BinaryEntry be = binaries.get(field.number);
         return getMissingBits(be.missingOffset);

Modified: lucene/dev/branches/lucene_solr_4_8/lucene/core/src/java/org/apache/lucene/index/BinaryDocValues.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_4_8/lucene/core/src/java/org/apache/lucene/index/BinaryDocValues.java?rev=1586607&r1=1586606&r2=1586607&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_4_8/lucene/core/src/java/org/apache/lucene/index/BinaryDocValues.java
(original)
+++ lucene/dev/branches/lucene_solr_4_8/lucene/core/src/java/org/apache/lucene/index/BinaryDocValues.java
Fri Apr 11 09:14:05 2014
@@ -30,14 +30,4 @@ public abstract class BinaryDocValues {
 
   /** Lookup the value for document. */
   public abstract void get(int docID, BytesRef result);
-  
-  /** An empty BinaryDocValues which returns {@link BytesRef#EMPTY_BYTES} for every document
*/
-  public static final BinaryDocValues EMPTY = new BinaryDocValues() {
-    @Override
-    public void get(int docID, BytesRef result) {
-      result.bytes = BytesRef.EMPTY_BYTES;
-      result.offset = 0;
-      result.length = 0;
-    }
-  };
 }

Modified: lucene/dev/branches/lucene_solr_4_8/lucene/core/src/java/org/apache/lucene/index/DocTermOrds.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_4_8/lucene/core/src/java/org/apache/lucene/index/DocTermOrds.java?rev=1586607&r1=1586606&r2=1586607&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_4_8/lucene/core/src/java/org/apache/lucene/index/DocTermOrds.java
(original)
+++ lucene/dev/branches/lucene_solr_4_8/lucene/core/src/java/org/apache/lucene/index/DocTermOrds.java
Fri Apr 11 09:14:05 2014
@@ -768,7 +768,7 @@ public class DocTermOrds {
   /** Returns a SortedSetDocValues view of this instance */
   public SortedSetDocValues iterator(AtomicReader reader) throws IOException {
     if (isEmpty()) {
-      return SortedSetDocValues.EMPTY;
+      return DocValues.EMPTY_SORTED_SET;
     } else {
       return new Iterator(reader);
     }

Modified: lucene/dev/branches/lucene_solr_4_8/lucene/core/src/java/org/apache/lucene/index/MultiDocValues.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_4_8/lucene/core/src/java/org/apache/lucene/index/MultiDocValues.java?rev=1586607&r1=1586606&r2=1586607&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_4_8/lucene/core/src/java/org/apache/lucene/index/MultiDocValues.java
(original)
+++ lucene/dev/branches/lucene_solr_4_8/lucene/core/src/java/org/apache/lucene/index/MultiDocValues.java
Fri Apr 11 09:14:05 2014
@@ -73,7 +73,7 @@ public class MultiDocValues {
       AtomicReaderContext context = leaves.get(i);
       NumericDocValues v = context.reader().getNormValues(field);
       if (v == null) {
-        v = NumericDocValues.EMPTY;
+        v = DocValues.EMPTY_NUMERIC;
       } else {
         anyReal = true;
       }
@@ -115,7 +115,7 @@ public class MultiDocValues {
       AtomicReaderContext context = leaves.get(i);
       NumericDocValues v = context.reader().getNumericDocValues(field);
       if (v == null) {
-        v = NumericDocValues.EMPTY;
+        v = DocValues.EMPTY_NUMERIC;
       } else {
         anyReal = true;
       }
@@ -205,7 +205,7 @@ public class MultiDocValues {
       AtomicReaderContext context = leaves.get(i);
       BinaryDocValues v = context.reader().getBinaryDocValues(field);
       if (v == null) {
-        v = BinaryDocValues.EMPTY;
+        v = DocValues.EMPTY_BINARY;
       } else {
         anyReal = true;
       }
@@ -250,7 +250,7 @@ public class MultiDocValues {
       AtomicReaderContext context = leaves.get(i);
       SortedDocValues v = context.reader().getSortedDocValues(field);
       if (v == null) {
-        v = SortedDocValues.EMPTY;
+        v = DocValues.EMPTY_SORTED;
       } else {
         anyReal = true;
       }
@@ -294,7 +294,7 @@ public class MultiDocValues {
       AtomicReaderContext context = leaves.get(i);
       SortedSetDocValues v = context.reader().getSortedSetDocValues(field);
       if (v == null) {
-        v = SortedSetDocValues.EMPTY;
+        v = DocValues.EMPTY_SORTED_SET;
       } else {
         anyReal = true;
       }

Modified: lucene/dev/branches/lucene_solr_4_8/lucene/core/src/java/org/apache/lucene/index/NumericDocValues.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_4_8/lucene/core/src/java/org/apache/lucene/index/NumericDocValues.java?rev=1586607&r1=1586606&r2=1586607&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_4_8/lucene/core/src/java/org/apache/lucene/index/NumericDocValues.java
(original)
+++ lucene/dev/branches/lucene_solr_4_8/lucene/core/src/java/org/apache/lucene/index/NumericDocValues.java
Fri Apr 11 09:14:05 2014
@@ -32,12 +32,4 @@ public abstract class NumericDocValues {
    * @return numeric value
    */
   public abstract long get(int docID);
-
-  /** An empty NumericDocValues which returns zero for every document */
-  public static final NumericDocValues EMPTY = new NumericDocValues() {
-    @Override
-    public long get(int docID) {
-      return 0;
-    }
-  };
 }

Modified: lucene/dev/branches/lucene_solr_4_8/lucene/core/src/java/org/apache/lucene/index/SegmentMerger.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_4_8/lucene/core/src/java/org/apache/lucene/index/SegmentMerger.java?rev=1586607&r1=1586606&r2=1586607&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_4_8/lucene/core/src/java/org/apache/lucene/index/SegmentMerger.java
(original)
+++ lucene/dev/branches/lucene_solr_4_8/lucene/core/src/java/org/apache/lucene/index/SegmentMerger.java
Fri Apr 11 09:14:05 2014
@@ -170,7 +170,7 @@ final class SegmentMerger {
               NumericDocValues values = reader.getNumericDocValues(field.name);
               Bits bits = reader.getDocsWithField(field.name);
               if (values == null) {
-                values = NumericDocValues.EMPTY;
+                values = DocValues.EMPTY_NUMERIC;
                 bits = new Bits.MatchNoBits(reader.maxDoc());
               }
               toMerge.add(values);
@@ -184,7 +184,7 @@ final class SegmentMerger {
               BinaryDocValues values = reader.getBinaryDocValues(field.name);
               Bits bits = reader.getDocsWithField(field.name);
               if (values == null) {
-                values = BinaryDocValues.EMPTY;
+                values = DocValues.EMPTY_BINARY;
                 bits = new Bits.MatchNoBits(reader.maxDoc());
               }
               toMerge.add(values);
@@ -196,7 +196,7 @@ final class SegmentMerger {
             for (AtomicReader reader : mergeState.readers) {
               SortedDocValues values = reader.getSortedDocValues(field.name);
               if (values == null) {
-                values = SortedDocValues.EMPTY;
+                values = DocValues.EMPTY_SORTED;
               }
               toMerge.add(values);
             }
@@ -206,7 +206,7 @@ final class SegmentMerger {
             for (AtomicReader reader : mergeState.readers) {
               SortedSetDocValues values = reader.getSortedSetDocValues(field.name);
               if (values == null) {
-                values = SortedSetDocValues.EMPTY;
+                values = DocValues.EMPTY_SORTED_SET;
               }
               toMerge.add(values);
             }
@@ -237,7 +237,7 @@ final class SegmentMerger {
           for (AtomicReader reader : mergeState.readers) {
             NumericDocValues norms = reader.getNormValues(field.name);
             if (norms == null) {
-              norms = NumericDocValues.EMPTY;
+              norms = DocValues.EMPTY_NUMERIC;
             }
             toMerge.add(norms);
             docsWithField.add(new Bits.MatchAllBits(reader.maxDoc()));

Modified: lucene/dev/branches/lucene_solr_4_8/lucene/core/src/java/org/apache/lucene/index/SingletonSortedSetDocValues.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_4_8/lucene/core/src/java/org/apache/lucene/index/SingletonSortedSetDocValues.java?rev=1586607&r1=1586606&r2=1586607&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_4_8/lucene/core/src/java/org/apache/lucene/index/SingletonSortedSetDocValues.java
(original)
+++ lucene/dev/branches/lucene_solr_4_8/lucene/core/src/java/org/apache/lucene/index/SingletonSortedSetDocValues.java
Fri Apr 11 09:14:05 2014
@@ -26,7 +26,7 @@ import org.apache.lucene.util.BytesRef;
  * against e.g. FieldCache.getDocTermOrds that also works for single-valued 
  * fields.
  */
-public class SingletonSortedSetDocValues extends SortedSetDocValues {
+final class SingletonSortedSetDocValues extends SortedSetDocValues {
   private final SortedDocValues in;
   private int docID;
   private boolean set;

Modified: lucene/dev/branches/lucene_solr_4_8/lucene/core/src/java/org/apache/lucene/index/SlowCompositeReaderWrapper.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_4_8/lucene/core/src/java/org/apache/lucene/index/SlowCompositeReaderWrapper.java?rev=1586607&r1=1586606&r2=1586607&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_4_8/lucene/core/src/java/org/apache/lucene/index/SlowCompositeReaderWrapper.java
(original)
+++ lucene/dev/branches/lucene_solr_4_8/lucene/core/src/java/org/apache/lucene/index/SlowCompositeReaderWrapper.java
Fri Apr 11 09:14:05 2014
@@ -130,7 +130,7 @@ public final class SlowCompositeReaderWr
       AtomicReaderContext context = in.leaves().get(i);
       SortedDocValues v = context.reader().getSortedDocValues(field);
       if (v == null) {
-        v = SortedDocValues.EMPTY;
+        v = DocValues.EMPTY_SORTED;
       }
       values[i] = v;
       starts[i] = context.docBase;
@@ -169,7 +169,7 @@ public final class SlowCompositeReaderWr
       AtomicReaderContext context = in.leaves().get(i);
       SortedSetDocValues v = context.reader().getSortedSetDocValues(field);
       if (v == null) {
-        v = SortedSetDocValues.EMPTY;
+        v = DocValues.EMPTY_SORTED_SET;
       }
       values[i] = v;
       starts[i] = context.docBase;

Modified: lucene/dev/branches/lucene_solr_4_8/lucene/core/src/java/org/apache/lucene/index/SortedDocValues.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_4_8/lucene/core/src/java/org/apache/lucene/index/SortedDocValues.java?rev=1586607&r1=1586606&r2=1586607&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_4_8/lucene/core/src/java/org/apache/lucene/index/SortedDocValues.java
(original)
+++ lucene/dev/branches/lucene_solr_4_8/lucene/core/src/java/org/apache/lucene/index/SortedDocValues.java
Fri Apr 11 09:14:05 2014
@@ -68,26 +68,6 @@ public abstract class SortedDocValues ex
     }
   }
 
-  /** An empty SortedDocValues which returns {@link BytesRef#EMPTY_BYTES} for every document
*/
-  public static final SortedDocValues EMPTY = new SortedDocValues() {
-    @Override
-    public int getOrd(int docID) {
-      return -1;
-    }
-
-    @Override
-    public void lookupOrd(int ord, BytesRef result) {
-      result.bytes = BytesRef.EMPTY_BYTES;
-      result.offset = 0;
-      result.length = 0;
-    }
-
-    @Override
-    public int getValueCount() {
-      return 0;
-    }
-  };
-
   /** If {@code key} exists, returns its ordinal, else
    *  returns {@code -insertionPoint-1}, like {@code
    *  Arrays.binarySearch}.

Modified: lucene/dev/branches/lucene_solr_4_8/lucene/core/src/java/org/apache/lucene/index/SortedSetDocValues.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_4_8/lucene/core/src/java/org/apache/lucene/index/SortedSetDocValues.java?rev=1586607&r1=1586606&r2=1586607&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_4_8/lucene/core/src/java/org/apache/lucene/index/SortedSetDocValues.java
(original)
+++ lucene/dev/branches/lucene_solr_4_8/lucene/core/src/java/org/apache/lucene/index/SortedSetDocValues.java
Fri Apr 11 09:14:05 2014
@@ -67,39 +67,6 @@ public abstract class SortedSetDocValues
    */
   public abstract long getValueCount();
 
-
-  /** An empty SortedDocValues which returns {@link #NO_MORE_ORDS} for every document */
-  public static final SortedSetDocValues EMPTY = new RandomAccessOrds() {
-
-    @Override
-    public long nextOrd() {
-      return NO_MORE_ORDS;
-    }
-
-    @Override
-    public void setDocument(int docID) {}
-
-    @Override
-    public void lookupOrd(long ord, BytesRef result) {
-      throw new IndexOutOfBoundsException();
-    }
-
-    @Override
-    public long getValueCount() {
-      return 0;
-    }
-
-    @Override
-    public long ordAt(int index) {
-      throw new IndexOutOfBoundsException();
-    }
-
-    @Override
-    public int cardinality() {
-      return 0;
-    }
-  };
-
   /** If {@code key} exists, returns its ordinal, else
    *  returns {@code -insertionPoint-1}, like {@code
    *  Arrays.binarySearch}.

Modified: lucene/dev/branches/lucene_solr_4_8/lucene/core/src/java/org/apache/lucene/search/FieldCacheImpl.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_4_8/lucene/core/src/java/org/apache/lucene/search/FieldCacheImpl.java?rev=1586607&r1=1586606&r2=1586607&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_4_8/lucene/core/src/java/org/apache/lucene/search/FieldCacheImpl.java
(original)
+++ lucene/dev/branches/lucene_solr_4_8/lucene/core/src/java/org/apache/lucene/search/FieldCacheImpl.java
Fri Apr 11 09:14:05 2014
@@ -28,12 +28,12 @@ import java.util.WeakHashMap;
 import org.apache.lucene.index.AtomicReader;
 import org.apache.lucene.index.BinaryDocValues;
 import org.apache.lucene.index.DocTermOrds;
+import org.apache.lucene.index.DocValues;
 import org.apache.lucene.index.DocsEnum;
 import org.apache.lucene.index.FieldInfo;
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.NumericDocValues;
 import org.apache.lucene.index.SegmentReader;
-import org.apache.lucene.index.SingletonSortedSetDocValues;
 import org.apache.lucene.index.SortedDocValues;
 import org.apache.lucene.index.SortedSetDocValues;
 import org.apache.lucene.index.Terms;
@@ -1154,13 +1154,13 @@ class FieldCacheImpl implements FieldCac
     } else {
       final FieldInfo info = reader.getFieldInfos().fieldInfo(field);
       if (info == null) {
-        return SortedDocValues.EMPTY;
+        return DocValues.EMPTY_SORTED;
       } else if (info.hasDocValues()) {
         // we don't try to build a sorted instance from numeric/binary doc
         // values because dedup can be very costly
         throw new IllegalStateException("Type mismatch: " + field + " was indexed as " +
info.getDocValuesType());
       } else if (!info.isIndexed()) {
-        return SortedDocValues.EMPTY;
+        return DocValues.EMPTY_SORTED;
       }
       return (SortedDocValues) caches.get(SortedDocValues.class).get(reader, new CacheKey(field,
acceptableOverheadRatio), false);
     }
@@ -1296,11 +1296,11 @@ class FieldCacheImpl implements FieldCac
 
     final FieldInfo info = reader.getFieldInfos().fieldInfo(field);
     if (info == null) {
-      return BinaryDocValues.EMPTY;
+      return DocValues.EMPTY_BINARY;
     } else if (info.hasDocValues()) {
       throw new IllegalStateException("Type mismatch: " + field + " was indexed as " + info.getDocValuesType());
     } else if (!info.isIndexed()) {
-      return BinaryDocValues.EMPTY;
+      return DocValues.EMPTY_BINARY;
     }
 
     return (BinaryDocValues) caches.get(BinaryDocValues.class).get(reader, new CacheKey(field,
acceptableOverheadRatio), setDocsWithField);
@@ -1410,16 +1410,16 @@ class FieldCacheImpl implements FieldCac
     
     SortedDocValues sdv = reader.getSortedDocValues(field);
     if (sdv != null) {
-      return new SingletonSortedSetDocValues(sdv);
+      return DocValues.singleton(sdv);
     }
     
     final FieldInfo info = reader.getFieldInfos().fieldInfo(field);
     if (info == null) {
-      return SortedSetDocValues.EMPTY;
+      return DocValues.EMPTY_SORTED_SET;
     } else if (info.hasDocValues()) {
       throw new IllegalStateException("Type mismatch: " + field + " was indexed as " + info.getDocValuesType());
     } else if (!info.isIndexed()) {
-      return SortedSetDocValues.EMPTY;
+      return DocValues.EMPTY_SORTED_SET;
     }
     
     DocTermOrds dto = (DocTermOrds) caches.get(DocTermOrds.class).get(reader, new CacheKey(field,
null), false);

Modified: lucene/dev/branches/lucene_solr_4_8/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/DocValuesOrdinalsReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_4_8/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/DocValuesOrdinalsReader.java?rev=1586607&r1=1586606&r2=1586607&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_4_8/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/DocValuesOrdinalsReader.java
(original)
+++ lucene/dev/branches/lucene_solr_4_8/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/DocValuesOrdinalsReader.java
Fri Apr 11 09:14:05 2014
@@ -22,6 +22,7 @@ import java.io.IOException;
 import org.apache.lucene.facet.FacetsConfig;
 import org.apache.lucene.index.AtomicReaderContext;
 import org.apache.lucene.index.BinaryDocValues;
+import org.apache.lucene.index.DocValues;
 import org.apache.lucene.util.ArrayUtil;
 import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.IntsRef;
@@ -45,7 +46,7 @@ public class DocValuesOrdinalsReader ext
   public OrdinalsSegmentReader getReader(AtomicReaderContext context) throws IOException
{
     BinaryDocValues values0 = context.reader().getBinaryDocValues(field);
     if (values0 == null) {
-      values0 = BinaryDocValues.EMPTY;
+      values0 = DocValues.EMPTY_BINARY;
     }
 
     final BinaryDocValues values = values0;

Modified: lucene/dev/branches/lucene_solr_4_8/lucene/sandbox/src/java/org/apache/lucene/sandbox/queries/SortedSetSortField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_4_8/lucene/sandbox/src/java/org/apache/lucene/sandbox/queries/SortedSetSortField.java?rev=1586607&r1=1586606&r2=1586607&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_4_8/lucene/sandbox/src/java/org/apache/lucene/sandbox/queries/SortedSetSortField.java
(original)
+++ lucene/dev/branches/lucene_solr_4_8/lucene/sandbox/src/java/org/apache/lucene/sandbox/queries/SortedSetSortField.java
Fri Apr 11 09:14:05 2014
@@ -20,8 +20,8 @@ package org.apache.lucene.sandbox.querie
 import java.io.IOException;
 
 import org.apache.lucene.index.AtomicReaderContext;
+import org.apache.lucene.index.DocValues;
 import org.apache.lucene.index.RandomAccessOrds;
-import org.apache.lucene.index.SingletonSortedSetDocValues;
 import org.apache.lucene.index.SortedDocValues;
 import org.apache.lucene.index.SortedSetDocValues;
 import org.apache.lucene.search.FieldCache;
@@ -165,11 +165,12 @@ public class SortedSetSortField extends 
           throw new UnsupportedOperationException("fields containing more than " + (Integer.MAX_VALUE-1)
+ " unique terms are unsupported");
         }
         
-        if (sortedSet instanceof SingletonSortedSetDocValues) {
+        SortedDocValues singleton = DocValues.unwrapSingleton(sortedSet);
+        if (singleton != null) {
           // it's actually single-valued in practice, but indexed as multi-valued,
           // so just sort on the underlying single-valued dv directly.
           // regardless of selector type, this optimization is safe!
-          return ((SingletonSortedSetDocValues) sortedSet).getSortedDocValues();
+          return singleton;
         } else if (selector == Selector.MIN) {
           return new MinValue(sortedSet);
         } else {

Modified: lucene/dev/branches/lucene_solr_4_8/lucene/test-framework/src/java/org/apache/lucene/index/BaseDocValuesFormatTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_4_8/lucene/test-framework/src/java/org/apache/lucene/index/BaseDocValuesFormatTestCase.java?rev=1586607&r1=1586606&r2=1586607&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_4_8/lucene/test-framework/src/java/org/apache/lucene/index/BaseDocValuesFormatTestCase.java
(original)
+++ lucene/dev/branches/lucene_solr_4_8/lucene/test-framework/src/java/org/apache/lucene/index/BaseDocValuesFormatTestCase.java
Fri Apr 11 09:14:05 2014
@@ -2188,7 +2188,7 @@ public abstract class BaseDocValuesForma
     // can be null for the segment if no docs actually had any SortedDocValues
     // in this case FC.getDocTermsOrds returns EMPTY
     if (actual == null) {
-      assertEquals(SortedSetDocValues.EMPTY, expected);
+      assertEquals(DocValues.EMPTY_SORTED_SET, expected);
       return;
     }
     assertEquals(expected.getValueCount(), actual.getValueCount());

Modified: lucene/dev/branches/lucene_solr_4_8/solr/core/src/java/org/apache/solr/request/DocValuesFacets.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_4_8/solr/core/src/java/org/apache/solr/request/DocValuesFacets.java?rev=1586607&r1=1586606&r2=1586607&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_4_8/solr/core/src/java/org/apache/solr/request/DocValuesFacets.java
(original)
+++ lucene/dev/branches/lucene_solr_4_8/solr/core/src/java/org/apache/solr/request/DocValuesFacets.java
Fri Apr 11 09:14:05 2014
@@ -21,10 +21,10 @@ import java.io.IOException;
 import java.util.List;
 
 import org.apache.lucene.index.AtomicReaderContext;
+import org.apache.lucene.index.DocValues;
 import org.apache.lucene.index.MultiDocValues.MultiSortedDocValues;
 import org.apache.lucene.index.MultiDocValues.MultiSortedSetDocValues;
 import org.apache.lucene.index.MultiDocValues.OrdinalMap;
-import org.apache.lucene.index.SingletonSortedSetDocValues;
 import org.apache.lucene.index.SortedDocValues;
 import org.apache.lucene.index.SortedSetDocValues;
 import org.apache.lucene.search.DocIdSet;
@@ -70,7 +70,7 @@ public class DocValuesFacets {
       }
     } else {
       SortedDocValues single = searcher.getAtomicReader().getSortedDocValues(fieldName);
-      si = single == null ? null : new SingletonSortedSetDocValues(single);
+      si = single == null ? null : DocValues.singleton(single);
       if (single instanceof MultiSortedDocValues) {
         ordinalMap = ((MultiSortedDocValues)single).mapping;
       }
@@ -129,19 +129,19 @@ public class DocValuesFacets {
           if (schemaField.multiValued()) {
             SortedSetDocValues sub = leaf.reader().getSortedSetDocValues(fieldName);
             if (sub == null) {
-              sub = SortedSetDocValues.EMPTY;
+              sub = DocValues.EMPTY_SORTED_SET;
             }
-            if (sub instanceof SingletonSortedSetDocValues) {
+            final SortedDocValues singleton = DocValues.unwrapSingleton(sub);
+            if (singleton != null) {
               // some codecs may optimize SORTED_SET storage for single-valued fields
-              final SortedDocValues values = ((SingletonSortedSetDocValues) sub).getSortedDocValues();
-              accumSingle(counts, startTermIndex, values, disi, subIndex, ordinalMap);
+              accumSingle(counts, startTermIndex, singleton, disi, subIndex, ordinalMap);
             } else {
               accumMulti(counts, startTermIndex, sub, disi, subIndex, ordinalMap);
             }
           } else {
             SortedDocValues sub = leaf.reader().getSortedDocValues(fieldName);
             if (sub == null) {
-              sub = SortedDocValues.EMPTY;
+              sub = DocValues.EMPTY_SORTED;
             }
             accumSingle(counts, startTermIndex, sub, disi, subIndex, ordinalMap);
           }



Mime
View raw message