diff --git a/CHANGES.txt b/CHANGES.txt index 46d00cc0a91..e73c1c93991 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -345,6 +345,9 @@ Optimizations score should then call Scorer.score() per hit inside collect(). (Shai Erera via Mike McCandless) + 8. LUCENE-1596: MultiTermDocs speedup when set with + MultiTermDocs.seek(MultiTermEnum) (yonik) + Documentation Build diff --git a/src/java/org/apache/lucene/index/MultiSegmentReader.java b/src/java/org/apache/lucene/index/MultiSegmentReader.java index c14555b4080..b326e84caa9 100644 --- a/src/java/org/apache/lucene/index/MultiSegmentReader.java +++ b/src/java/org/apache/lucene/index/MultiSegmentReader.java @@ -533,10 +533,12 @@ class MultiSegmentReader extends DirectoryIndexReader implements Cloneable { private Term term; private int docFreq; - + final SegmentMergeInfo[] matchingSegments; // null terminated array of matching segments + public MultiTermEnum(IndexReader[] readers, int[] starts, Term t) throws IOException { queue = new SegmentMergeQueue(readers.length); + matchingSegments = new SegmentMergeInfo[readers.length+1]; for (int i = 0; i < readers.length; i++) { IndexReader reader = readers[i]; TermEnum termEnum; @@ -547,6 +549,7 @@ class MultiSegmentReader extends DirectoryIndexReader implements Cloneable { termEnum = reader.terms(); SegmentMergeInfo smi = new SegmentMergeInfo(starts[i], termEnum, reader); + smi.ord = i; if (t == null ? smi.next() : termEnum.term() != null) queue.put(smi); // initialize queue else @@ -559,7 +562,20 @@ class MultiSegmentReader extends DirectoryIndexReader implements Cloneable { } public boolean next() throws IOException { + for (int i=0; i