mirror of https://github.com/apache/lucene.git
LUCENE-761: The proxStream is now cloned lazily in SegmentTermPositions when nextPosition() is called for the first time.
git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@516863 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
45ff9e467a
commit
0b706b4688
|
@ -66,6 +66,10 @@ New features
|
|||
|
||||
Optimizations
|
||||
|
||||
1. LUCENE-761: The proxStream is now cloned lazily in SegmentTermPositions
|
||||
when nextPosition() is called for the first time. This allows using instances
|
||||
of SegmentTermPositions instead of SegmentTermDocs without additional costs.
|
||||
(Michael Busch)
|
||||
|
||||
Documentation:
|
||||
1. LUCENE 791 && INFRA-1173: Infrastructure moved the Wiki to http://wiki.apache.org/lucene-java/ Updated the links in the docs and wherever else I found references. (Grant Ingersoll, Joe Schaefer)
|
||||
|
|
|
@ -34,7 +34,7 @@ extends SegmentTermDocs implements TermPositions {
|
|||
|
||||
SegmentTermPositions(SegmentReader p) {
|
||||
super(p);
|
||||
this.proxStream = (IndexInput)parent.proxStream.clone();
|
||||
this.proxStream = null; // the proxStream will be cloned lazily when nextPosition() is called for the first time
|
||||
}
|
||||
|
||||
final void seek(TermInfo ti) throws IOException {
|
||||
|
@ -48,7 +48,7 @@ extends SegmentTermDocs implements TermPositions {
|
|||
|
||||
public final void close() throws IOException {
|
||||
super.close();
|
||||
proxStream.close();
|
||||
if (proxStream != null) proxStream.close();
|
||||
}
|
||||
|
||||
public final int nextPosition() throws IOException {
|
||||
|
@ -105,6 +105,11 @@ extends SegmentTermDocs implements TermPositions {
|
|||
// So we move the prox pointer lazily to the document
|
||||
// as soon as positions are requested.
|
||||
private void lazySkip() throws IOException {
|
||||
if (proxStream == null) {
|
||||
// clone lazily
|
||||
proxStream = (IndexInput)parent.proxStream.clone();
|
||||
}
|
||||
|
||||
if (lazySkipPointer != 0) {
|
||||
proxStream.seek(lazySkipPointer);
|
||||
lazySkipPointer = 0;
|
||||
|
|
Loading…
Reference in New Issue