mirror of https://github.com/apache/lucene.git
non-recursive MultiTermDocs.next,skipTo: LUCENE-729
git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@480147 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
8dc26ad30e
commit
42e2191b93
|
@ -275,6 +275,10 @@ Optimizations
|
|||
with calls to System.arraycopy instead, in DocumentWriter.java.
|
||||
(Nicolas Lalevee via Mike McCandless)
|
||||
|
||||
13. LUCENE-729: Non-recursive skipTo and next implementation of
|
||||
TermDocs for a MultiReader. The old implementation could
|
||||
recurse up to the number of segments in the index. (Yonik Seeley)
|
||||
|
||||
Test Cases
|
||||
1. Added TestTermScorer.java (Grant Ingersoll)
|
||||
|
||||
|
|
|
@ -352,14 +352,17 @@ class MultiTermDocs implements TermDocs {
|
|||
}
|
||||
|
||||
public boolean next() throws IOException {
|
||||
if (current != null && current.next()) {
|
||||
return true;
|
||||
} else if (pointer < readers.length) {
|
||||
base = starts[pointer];
|
||||
current = termDocs(pointer++);
|
||||
return next();
|
||||
} else
|
||||
return false;
|
||||
for(;;) {
|
||||
if (current!=null && current.next()) {
|
||||
return true;
|
||||
}
|
||||
else if (pointer < readers.length) {
|
||||
base = starts[pointer];
|
||||
current = termDocs(pointer++);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Optimized implementation. */
|
||||
|
@ -385,16 +388,17 @@ class MultiTermDocs implements TermDocs {
|
|||
}
|
||||
}
|
||||
|
||||
/* A Possible future optimization could skip entire segments */
|
||||
/* A Possible future optimization could skip entire segments */
|
||||
public boolean skipTo(int target) throws IOException {
|
||||
if (current != null && current.skipTo(target-base)) {
|
||||
return true;
|
||||
} else if (pointer < readers.length) {
|
||||
base = starts[pointer];
|
||||
current = termDocs(pointer++);
|
||||
return skipTo(target);
|
||||
} else
|
||||
return false;
|
||||
for(;;) {
|
||||
if (current != null && current.skipTo(target-base)) {
|
||||
return true;
|
||||
} else if (pointer < readers.length) {
|
||||
base = starts[pointer];
|
||||
current = termDocs(pointer++);
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private TermDocs termDocs(int i) throws IOException {
|
||||
|
|
Loading…
Reference in New Issue