Added subDoc() method, renamed searcherIndex() to subSearcher().

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@149895 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Doug Cutting 2002-11-25 20:50:15 +00:00
parent 686bdde10b
commit 57cdbe4187
1 changed files with 17 additions and 4 deletions

View File

@ -98,13 +98,20 @@ public class MultiSearcher extends Searcher implements Searchable {
/** For use by {@link HitCollector} implementations. */
public Document doc(int n) throws IOException {
int i = searcherIndex(n); // find searcher index
int i = subSearcher(n); // find searcher index
return searchables[i].doc(n - starts[i]); // dispatch to searcher
}
/** For use by {@link HitCollector} implementations to identify the
* index of the sub-searcher that a particular hit came from. */
public int searcherIndex(int n) { // find searcher for doc n:
/** Call {@link #subSearcher} instead.
* @deprecated
*/
public int searcherIndex(int n) {
return subSearcher(n);
}
/** Returns index of the searcher for document <code>n</code> in the array
* used to construct this searcher. */
public int subSearcher(int n) { // find searcher for doc n:
// replace w/ call to Arrays.binarySearch in Java 1.2
int lo = 0; // search starts array
int hi = searchables.length - 1; // for first element less
@ -126,6 +133,12 @@ public class MultiSearcher extends Searcher implements Searchable {
return hi;
}
/** Returns the document number of document <code>n</code> within its
* sub-index. */
public int subDoc(int n) {
return n - starts[subSearcher(n)];
}
public int maxDoc() throws IOException {
return maxDoc;
}