diff --git a/lucene/src/java/org/apache/lucene/index/values/VarStraightBytesImpl.java b/lucene/src/java/org/apache/lucene/index/values/VarStraightBytesImpl.java index 7d71643f51a..8d0bb19c04e 100644 --- a/lucene/src/java/org/apache/lucene/index/values/VarStraightBytesImpl.java +++ b/lucene/src/java/org/apache/lucene/index/values/VarStraightBytesImpl.java @@ -146,6 +146,20 @@ class VarStraightBytesImpl { : (int) (addresses.get(1 + docID) - address); return data.fillSlice(bytesRef, address, length); } + + @Override + public ValuesEnum getEnum(AttributeSource attrSource) throws IOException { + return new SourceEnum(attrSource, type(), this, maxDoc()) { + @Override + public int advance(int target) throws IOException { + if (target >= numDocs) { + return pos = NO_MORE_DOCS; + } + source.getBytes(target, bytesRef); + return pos = target; + } + }; + } @Override public int getValueCount() { diff --git a/lucene/src/test/org/apache/lucene/index/values/TestDocValuesIndexing.java b/lucene/src/test/org/apache/lucene/index/values/TestDocValuesIndexing.java index 20ffa085e80..f76bb40af57 100644 --- a/lucene/src/test/org/apache/lucene/index/values/TestDocValuesIndexing.java +++ b/lucene/src/test/org/apache/lucene/index/values/TestDocValuesIndexing.java @@ -207,6 +207,13 @@ public class TestDocValuesIndexing extends LuceneTestCase { case INTS: assertEquals(msg, valuesPerIndex-1, vE_2_merged.advance(valuesPerIndex-1)); } +// switch (first) { // these variants don't advance over missing values +// case BYTES_FIXED_STRAIGHT: +// case FLOAT_32: +// case FLOAT_64: +// case INTS: +// assertEquals(msg, valuesPerIndex-1, vE_1_merged.advance(valuesPerIndex-1)); +// } for (int i = 0; i < valuesPerIndex; i++) { assertEquals(msg, i, vE_1.nextDoc()); @@ -385,17 +392,9 @@ public class TestDocValuesIndexing extends LuceneTestCase { assertEquals(0, br.length); // make sure we advance at least until base ValuesEnum bytesEnum = getValuesEnum(bytesReader); - try { - final int advancedTo = bytesEnum.advance(0); assertTrue(byteIndexValue.name() + " advanced failed base:" + base + " advancedTo: " + advancedTo, base <= advancedTo); - }catch(Throwable e) { - final int advancedTo = bytesEnum.advance(0); - assertTrue(byteIndexValue.name() + " advanced failed base:" + base - + " advancedTo: " + advancedTo, base <= advancedTo); - - } } }