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 2011/12/14 13:51:32 UTC

svn commit: r1214219 - /lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/MultiDocValues.java

Author: rmuir
Date: Wed Dec 14 12:51:32 2011
New Revision: 1214219

URL: http://svn.apache.org/viewvc?rev=1214219&view=rev
Log:
LUCENE-3647: for segments with no docvalues, when promoting to a fixed type we need to use an EmptyFixedSource

Modified:
    lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/MultiDocValues.java

Modified: lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/MultiDocValues.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/MultiDocValues.java?rev=1214219&r1=1214218&r2=1214219&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/MultiDocValues.java (original)
+++ lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/MultiDocValues.java Wed Dec 14 12:51:32 2011
@@ -109,7 +109,15 @@ public class MultiDocValues extends DocV
         DocValuesSlice slice = slices.get(i);
         starts[i] = slice.start;
         if (slice.docValues == null) {
-          slice.docValues = new EmptyDocValues(slice.length, promotedType[0].type());
+          Type promoted = promotedType[0].type();
+          switch(promoted) {
+            case BYTES_FIXED_DEREF:
+            case BYTES_FIXED_STRAIGHT:
+              slice.docValues = new EmptyFixedDocValues(slice.length, promoted, promotedType[0].getValueSize());
+              break;
+            default:
+              slice.docValues = new EmptyDocValues(slice.length, promoted);
+          }
         }
       }
       
@@ -147,6 +155,38 @@ public class MultiDocValues extends DocV
       return emptySource;
     }
   }
+  
+  public static class EmptyFixedDocValues extends DocValues {
+    final int maxDoc;
+    final Source emptyFixedSource;
+    final int valueSize;
+
+    public EmptyFixedDocValues(int maxDoc, Type type, int valueSize) {
+      this.maxDoc = maxDoc;
+      this.emptyFixedSource = new EmptyFixedSource(type, valueSize);
+      this.valueSize = valueSize;
+    }
+
+    @Override
+    public Source load() throws IOException {
+      return emptyFixedSource;
+    }
+
+    @Override
+    public Type type() {
+      return emptyFixedSource.type();
+    }
+
+    @Override
+    public int getValueSize() {
+      return valueSize;
+    }
+
+    @Override
+    public Source getDirectSource() throws IOException {
+      return emptyFixedSource;
+    }
+  }
 
   private static class MultiSource extends Source {
     private int numDocs = 0;
@@ -216,7 +256,33 @@ public class MultiDocValues extends DocV
     public BytesRef getBytes(int docID, BytesRef ref) {
       ref.length = 0;
       return ref;
+    }
+
+    @Override
+    public double getFloat(int docID) {
+      return 0d;
+    }
 
+    @Override
+    public long getInt(int docID) {
+      return 0;
+    }
+  }
+  
+  private static class EmptyFixedSource extends Source {
+    private final int valueSize;
+    
+    public EmptyFixedSource(Type type, int valueSize) {
+      super(type);
+      this.valueSize = valueSize;
+    }
+
+    @Override
+    public BytesRef getBytes(int docID, BytesRef ref) {
+      ref.grow(valueSize);
+      ref.length = valueSize;
+      Arrays.fill(ref.bytes, ref.offset, ref.offset+valueSize, (byte)0);
+      return ref;
     }
 
     @Override