There was a message from Kirk Roberts, 18/4/2007 - MultiSearcher vs MultiReader

Grant mentioned the visibility of the readerIndex() method in MultiReader, but nothing seems ever came of it.

Is there any reason why the following could not be put into MultiReader? Something like this seems necessary when handling multiple indices to solve the BitSet caching issue I raised on the user thread.

It's slightly more efficient for a Filter implementation bits() method to know these reader numbers in the filter (as the doc id always seems to increment) rather than delegating back to the reader to resolve it each call. However, it gives useful utility methods for doing so, and gives freedom to the underlying implementation in case that needs to change.

Antony

/** Fetches the IndexReader instance where the specified document exists
 *  @param  n the MultiReader document number
 *  @return the reader index
 */
public int readerIndex(int n) {    // find reader for doc n:
  return MultiSegmentReader.readerIndex(n, this.starts, this.subReaders.length);
}

/** Fetches the document number in the specified reader for the given document
    number.
 *  @param  i the reader index obtained from [EMAIL PROTECTED] 
#readerIndex(int)}
 *  @param  n the MultiReader document number
 *  @return the mapped document number
 */
public int id(int i, int n) {    // find true doc for doc n:
  return n - this.starts[i];
}

/** Fetches the document number in the specified reader for the given document
    number.
 *  @param  n the MultiReader document number
 *  @return the mapped document number
 */
public int id(int n) {    // find true doc for doc n:
  return n - this.starts[readerIndex(n)];
}



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to