Apache Solr open-source search software
LUCENE-761: The proxStream is now cloned lazily in SegmentTermPositions when nextPosition() is called for the first time.
Michael Busch0b706b468884
diff --git a/CHANGES.txt b/CHANGES.txtindex 2b2bfa8b5b7..c2d2740c025 100644--- a/CHANGES.txt+++ b/CHANGES.txt@@ -66,6 +66,10 @@ New featuresOptimizations+ 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)diff --git a/src/java/org/apache/lucene/index/SegmentTermPositions.java b/src/java/org/apache/lucene/index/SegmentTermPositions.javaindex 208ba92d55f..b5d9f7e2368 100644--- a/src/java/org/apache/lucene/index/SegmentTermPositions.java+++ b/src/java/org/apache/lucene/index/SegmentTermPositions.java@@ -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;