Skip to content

Commit b7b834b

Browse files
authored
LUCENE-9998: delete useless param fis in StoredFieldsWriter.finish() and TermVectorsWriter.finish() (#183)
1 parent 6f5a413 commit b7b834b

18 files changed

+37
-41
lines changed

lucene/CHANGES.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ API Changes
127127

128128
* LUCENE-8143: SpanBoostQuery has been removed. (Alan Woodward)
129129

130+
* LUCENE-9998: Remove unused parameter fis in StoredFieldsWriter.finish() and TermVectorsWriter.finish(),
131+
including those subclasses. (kkewwei)
132+
130133
Improvements
131134

132135
* LUCENE-9960: Avoid unnecessary top element replacement for equal elements in PriorityQueue. (Dawid Weiss)

lucene/backward-codecs/src/test/org/apache/lucene/backward_codecs/lucene50/compressing/Lucene50CompressingStoredFieldsWriter.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
import org.apache.lucene.codecs.compressing.CompressionMode;
3737
import org.apache.lucene.codecs.compressing.Compressor;
3838
import org.apache.lucene.index.FieldInfo;
39-
import org.apache.lucene.index.FieldInfos;
4039
import org.apache.lucene.index.IndexFileNames;
4140
import org.apache.lucene.index.IndexableField;
4241
import org.apache.lucene.index.SegmentInfo;
@@ -480,7 +479,7 @@ static void writeTLong(DataOutput out, long l) throws IOException {
480479
}
481480

482481
@Override
483-
public void finish(FieldInfos fis, int numDocs) throws IOException {
482+
public void finish(int numDocs) throws IOException {
484483
if (numBufferedDocs > 0) {
485484
flush(true);
486485
} else {

lucene/backward-codecs/src/test/org/apache/lucene/backward_codecs/lucene50/compressing/Lucene50CompressingTermVectorsWriter.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
import org.apache.lucene.codecs.compressing.CompressionMode;
4343
import org.apache.lucene.codecs.compressing.Compressor;
4444
import org.apache.lucene.index.FieldInfo;
45-
import org.apache.lucene.index.FieldInfos;
4645
import org.apache.lucene.index.IndexFileNames;
4746
import org.apache.lucene.index.SegmentInfo;
4847
import org.apache.lucene.store.ByteBuffersDataOutput;
@@ -701,7 +700,7 @@ private void flushPayloadLengths() throws IOException {
701700
}
702701

703702
@Override
704-
public void finish(FieldInfos fis, int numDocs) throws IOException {
703+
public void finish(int numDocs) throws IOException {
705704
if (!pendingDocs.isEmpty()) {
706705
numDirtyChunks++; // incomplete: we had to force this flush
707706
numDirtyDocs += pendingDocs.size();

lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextStoredFieldsWriter.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import java.io.IOException;
2020
import org.apache.lucene.codecs.StoredFieldsWriter;
2121
import org.apache.lucene.index.FieldInfo;
22-
import org.apache.lucene.index.FieldInfos;
2322
import org.apache.lucene.index.IndexFileNames;
2423
import org.apache.lucene.index.IndexableField;
2524
import org.apache.lucene.store.Directory;
@@ -152,7 +151,7 @@ public void writeField(FieldInfo info, IndexableField field) throws IOException
152151
}
153152

154153
@Override
155-
public void finish(FieldInfos fis, int numDocs) throws IOException {
154+
public void finish(int numDocs) throws IOException {
156155
if (numDocsWritten != numDocs) {
157156
throw new RuntimeException(
158157
"mergeFields produced an invalid result: docCount is "

lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextTermVectorsWriter.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import java.io.IOException;
2020
import org.apache.lucene.codecs.TermVectorsWriter;
2121
import org.apache.lucene.index.FieldInfo;
22-
import org.apache.lucene.index.FieldInfos;
2322
import org.apache.lucene.index.IndexFileNames;
2423
import org.apache.lucene.store.Directory;
2524
import org.apache.lucene.store.IOContext;
@@ -165,7 +164,7 @@ public void addPosition(int position, int startOffset, int endOffset, BytesRef p
165164
}
166165

167166
@Override
168-
public void finish(FieldInfos fis, int numDocs) throws IOException {
167+
public void finish(int numDocs) throws IOException {
169168
if (numDocsWritten != numDocs) {
170169
throw new RuntimeException(
171170
"mergeVectors produced an invalid result: mergedDocs is "

lucene/core/src/java/org/apache/lucene/codecs/StoredFieldsWriter.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
* <li>For every document, {@link #startDocument()} is called, informing the Codec that a new
4545
* document has started.
4646
* <li>{@link #writeField(FieldInfo, IndexableField)} is called for each field in the document.
47-
* <li>After all documents have been written, {@link #finish(FieldInfos, int)} is called for
47+
* <li>After all documents have been written, {@link #finish(int)} is called for
4848
* verification/sanity-checks.
4949
* <li>Finally the writer is closed ({@link #close()})
5050
* </ol>
@@ -74,7 +74,7 @@ public void finishDocument() throws IOException {}
7474
* this is intentionally redundant (equivalent to the number of calls to {@link #startDocument()},
7575
* but a Codec should check that this is the case to detect the JRE bug described in LUCENE-1282.
7676
*/
77-
public abstract void finish(FieldInfos fis, int numDocs) throws IOException;
77+
public abstract void finish(int numDocs) throws IOException;
7878

7979
private static class StoredFieldsMergeSub extends DocIDMerger.Sub {
8080
private final StoredFieldsReader reader;
@@ -104,9 +104,9 @@ public int nextDoc() {
104104
/**
105105
* Merges in the stored fields from the readers in <code>mergeState</code>. The default
106106
* implementation skips over deleted documents, and uses {@link #startDocument()}, {@link
107-
* #writeField(FieldInfo, IndexableField)}, and {@link #finish(FieldInfos, int)}, returning the
108-
* number of documents that were written. Implementations can override this method for more
109-
* sophisticated merging (bulk-byte copying, etc).
107+
* #writeField(FieldInfo, IndexableField)}, and {@link #finish(int)}, returning the number of
108+
* documents that were written. Implementations can override this method for more sophisticated
109+
* merging (bulk-byte copying, etc).
110110
*/
111111
public int merge(MergeState mergeState) throws IOException {
112112
List<StoredFieldsMergeSub> subs = new ArrayList<>();
@@ -136,7 +136,7 @@ public int merge(MergeState mergeState) throws IOException {
136136
finishDocument();
137137
docCount++;
138138
}
139-
finish(mergeState.mergeFieldInfos, docCount);
139+
finish(docCount);
140140
return docCount;
141141
}
142142

lucene/core/src/java/org/apache/lucene/codecs/TermVectorsWriter.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import java.util.List;
2626
import org.apache.lucene.index.DocIDMerger;
2727
import org.apache.lucene.index.FieldInfo;
28-
import org.apache.lucene.index.FieldInfos;
2928
import org.apache.lucene.index.Fields;
3029
import org.apache.lucene.index.MergeState;
3130
import org.apache.lucene.index.PostingsEnum;
@@ -49,7 +48,7 @@
4948
* <li>Within each field, {@link #startTerm(BytesRef, int)} is called for each term.
5049
* <li>If offsets and/or positions are enabled, then {@link #addPosition(int, int, int, BytesRef)}
5150
* will be called for each term occurrence.
52-
* <li>After all documents have been written, {@link #finish(FieldInfos, int)} is called for
51+
* <li>After all documents have been written, {@link #finish(int)} is called for
5352
* verification/sanity-checks.
5453
* <li>Finally the writer is closed ({@link #close()})
5554
* </ol>
@@ -105,7 +104,7 @@ public abstract void addPosition(int position, int startOffset, int endOffset, B
105104
* #startDocument(int)}, but a Codec should check that this is the case to detect the JRE bug
106105
* described in LUCENE-1282.
107106
*/
108-
public abstract void finish(FieldInfos fis, int numDocs) throws IOException;
107+
public abstract void finish(int numDocs) throws IOException;
109108

110109
/**
111110
* Called by IndexWriter when writing new segments.
@@ -193,9 +192,9 @@ public int nextDoc() {
193192
* Merges in the term vectors from the readers in <code>mergeState</code>. The default
194193
* implementation skips over deleted documents, and uses {@link #startDocument(int)}, {@link
195194
* #startField(FieldInfo, int, boolean, boolean, boolean)}, {@link #startTerm(BytesRef, int)},
196-
* {@link #addPosition(int, int, int, BytesRef)}, and {@link #finish(FieldInfos, int)}, returning
197-
* the number of documents that were written. Implementations can override this method for more
198-
* sophisticated merging (bulk-byte copying, etc).
195+
* {@link #addPosition(int, int, int, BytesRef)}, and {@link #finish(int)}, returning the number
196+
* of documents that were written. Implementations can override this method for more sophisticated
197+
* merging (bulk-byte copying, etc).
199198
*/
200199
public int merge(MergeState mergeState) throws IOException {
201200

@@ -229,7 +228,7 @@ public int merge(MergeState mergeState) throws IOException {
229228
addAllDocVectors(vectors, mergeState);
230229
docCount++;
231230
}
232-
finish(mergeState.mergeFieldInfos, docCount);
231+
finish(docCount);
233232
return docCount;
234233
}
235234

lucene/core/src/java/org/apache/lucene/codecs/lucene90/compressing/Lucene90CompressingStoredFieldsWriter.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import org.apache.lucene.index.CorruptIndexException;
3232
import org.apache.lucene.index.DocIDMerger;
3333
import org.apache.lucene.index.FieldInfo;
34-
import org.apache.lucene.index.FieldInfos;
3534
import org.apache.lucene.index.IndexFileNames;
3635
import org.apache.lucene.index.IndexableField;
3736
import org.apache.lucene.index.MergeState;
@@ -478,7 +477,7 @@ static void writeTLong(DataOutput out, long l) throws IOException {
478477
}
479478

480479
@Override
481-
public void finish(FieldInfos fis, int numDocs) throws IOException {
480+
public void finish(int numDocs) throws IOException {
482481
if (numBufferedDocs > 0) {
483482
flush(true);
484483
} else {
@@ -654,7 +653,7 @@ public int merge(MergeState mergeState) throws IOException {
654653
throw new AssertionError("Unknown merge strategy [" + sub.mergeStrategy + "]");
655654
}
656655
}
657-
finish(mergeState.mergeFieldInfos, docCount);
656+
finish(docCount);
658657
return docCount;
659658
}
660659

lucene/core/src/java/org/apache/lucene/codecs/lucene90/compressing/Lucene90CompressingTermVectorsWriter.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
import org.apache.lucene.index.CorruptIndexException;
3838
import org.apache.lucene.index.DocIDMerger;
3939
import org.apache.lucene.index.FieldInfo;
40-
import org.apache.lucene.index.FieldInfos;
4140
import org.apache.lucene.index.Fields;
4241
import org.apache.lucene.index.IndexFileNames;
4342
import org.apache.lucene.index.MergeState;
@@ -721,7 +720,7 @@ private void flushPayloadLengths() throws IOException {
721720
}
722721

723722
@Override
724-
public void finish(FieldInfos fis, int numDocs) throws IOException {
723+
public void finish(int numDocs) throws IOException {
725724
if (!pendingDocs.isEmpty()) {
726725
flush(true);
727726
}
@@ -939,7 +938,7 @@ public int merge(MergeState mergeState) throws IOException {
939938
sub = docIDMerger.next();
940939
}
941940
}
942-
finish(mergeState.mergeFieldInfos, docCount);
941+
finish(docCount);
943942
return docCount;
944943
}
945944

lucene/core/src/java/org/apache/lucene/index/SortingStoredFieldsConsumer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ void flush(SegmentWriteState state, Sorter.DocMap sortMap) throws IOException {
115115
reader.visitDocument(sortMap == null ? docID : sortMap.newToOld(docID), visitor);
116116
sortWriter.finishDocument();
117117
}
118-
sortWriter.finish(state.fieldInfos, state.segmentInfo.maxDoc());
118+
sortWriter.finish(state.segmentInfo.maxDoc());
119119
} finally {
120120
IOUtils.close(reader, sortWriter);
121121
IOUtils.deleteFiles(tmpDirectory, tmpDirectory.getTemporaryFiles().values());

0 commit comments

Comments
 (0)