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:
Yonik Seeley 2006-11-28 18:17:56 +00:00
parent 8dc26ad30e
commit 42e2191b93
2 changed files with 25 additions and 17 deletions

View File

@ -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)

View File

@ -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 {