diff --git a/lucene/core/src/java/org/apache/lucene/index/DocTermOrds.java b/lucene/core/src/java/org/apache/lucene/index/DocTermOrds.java index f91a31deb73..ca9c5332833 100644 --- a/lucene/core/src/java/org/apache/lucene/index/DocTermOrds.java +++ b/lucene/core/src/java/org/apache/lucene/index/DocTermOrds.java @@ -597,7 +597,7 @@ public class DocTermOrds { } /** Iterates over the ords for a single document. */ - public class TermOrdsIterator { + private class TermOrdsIterator { private int tnum; private int upto; private byte[] arr; diff --git a/lucene/core/src/test/org/apache/lucene/index/TestDocTermOrds.java b/lucene/core/src/test/org/apache/lucene/index/TestDocTermOrds.java index 53df62bef68..84dd30c9797 100644 --- a/lucene/core/src/test/org/apache/lucene/index/TestDocTermOrds.java +++ b/lucene/core/src/test/org/apache/lucene/index/TestDocTermOrds.java @@ -29,7 +29,6 @@ import org.apache.lucene.codecs.PostingsFormat; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; import org.apache.lucene.document.IntField; -import org.apache.lucene.index.DocTermOrds.TermOrdsIterator; import org.apache.lucene.search.FieldCache; import org.apache.lucene.store.Directory; import org.apache.lucene.util.BytesRef; @@ -63,25 +62,26 @@ public class TestDocTermOrds extends LuceneTestCase { final IndexReader r = w.getReader(); w.close(); - final DocTermOrds dto = new DocTermOrds(SlowCompositeReaderWrapper.wrap(r), "field"); + final AtomicReader ar = SlowCompositeReaderWrapper.wrap(r); + final DocTermOrds dto = new DocTermOrds(ar, "field"); + SortedSetDocValues iter = dto.iterator(ar.terms("field").iterator(null)); + + iter.setDocument(0); + assertEquals(0, iter.nextOrd()); + assertEquals(1, iter.nextOrd()); + assertEquals(2, iter.nextOrd()); + assertEquals(SortedSetDocValues.NO_MORE_ORDS, iter.nextOrd()); + + iter.setDocument(1); + assertEquals(3, iter.nextOrd()); + assertEquals(4, iter.nextOrd()); + assertEquals(5, iter.nextOrd()); + assertEquals(SortedSetDocValues.NO_MORE_ORDS, iter.nextOrd()); - TermOrdsIterator iter = dto.lookup(0, null); - final int[] buffer = new int[5]; - assertEquals(3, iter.read(buffer)); - assertEquals(0, buffer[0]); - assertEquals(1, buffer[1]); - assertEquals(2, buffer[2]); - - iter = dto.lookup(1, iter); - assertEquals(3, iter.read(buffer)); - assertEquals(3, buffer[0]); - assertEquals(4, buffer[1]); - assertEquals(5, buffer[2]); - - iter = dto.lookup(2, iter); - assertEquals(2, iter.read(buffer)); - assertEquals(0, buffer[0]); - assertEquals(5, buffer[1]); + iter.setDocument(2); + assertEquals(0, iter.nextOrd()); + assertEquals(5, iter.nextOrd()); + assertEquals(SortedSetDocValues.NO_MORE_ORDS, iter.nextOrd()); r.close(); dir.close(); @@ -352,31 +352,24 @@ public class TestDocTermOrds extends LuceneTestCase { } } - TermOrdsIterator iter = null; - final int[] buffer = new int[5]; + SortedSetDocValues iter = dto.iterator(te); for(int docID=0;docID