mirror of https://github.com/apache/lucene.git
LUCENE-10180: Avoid using lambdas in SegmentMerger. (#385)
This commit is contained in:
parent
8b68bf60c9
commit
1448e4739b
|
@ -130,21 +130,27 @@ final class SegmentMerger {
|
||||||
segmentWriteState.segmentSuffix);
|
segmentWriteState.segmentSuffix);
|
||||||
|
|
||||||
if (mergeState.mergeFieldInfos.hasNorms()) {
|
if (mergeState.mergeFieldInfos.hasNorms()) {
|
||||||
mergeWithLogging(() -> mergeNorms(segmentWriteState), "norms", numMerged);
|
mergeWithLogging(this::mergeNorms, segmentWriteState, segmentReadState, "norms", numMerged);
|
||||||
}
|
}
|
||||||
|
|
||||||
mergeWithLogging(() -> mergeTerms(segmentWriteState, segmentReadState), "postings", numMerged);
|
mergeWithLogging(this::mergeTerms, segmentWriteState, segmentReadState, "postings", numMerged);
|
||||||
|
|
||||||
if (mergeState.mergeFieldInfos.hasDocValues()) {
|
if (mergeState.mergeFieldInfos.hasDocValues()) {
|
||||||
mergeWithLogging(() -> mergeDocValues(segmentWriteState), "doc values", numMerged);
|
mergeWithLogging(
|
||||||
|
this::mergeDocValues, segmentWriteState, segmentReadState, "doc values", numMerged);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mergeState.mergeFieldInfos.hasPointValues()) {
|
if (mergeState.mergeFieldInfos.hasPointValues()) {
|
||||||
mergeWithLogging(() -> mergePoints(segmentWriteState), "points", numMerged);
|
mergeWithLogging(this::mergePoints, segmentWriteState, segmentReadState, "points", numMerged);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mergeState.mergeFieldInfos.hasVectorValues()) {
|
if (mergeState.mergeFieldInfos.hasVectorValues()) {
|
||||||
mergeWithLogging(() -> mergeVectorValues(segmentWriteState), "numeric vectors", numMerged);
|
mergeWithLogging(
|
||||||
|
this::mergeVectorValues,
|
||||||
|
segmentWriteState,
|
||||||
|
segmentReadState,
|
||||||
|
"numeric vectors",
|
||||||
|
numMerged);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mergeState.mergeFieldInfos.hasVectors()) {
|
if (mergeState.mergeFieldInfos.hasVectors()) {
|
||||||
|
@ -153,29 +159,34 @@ final class SegmentMerger {
|
||||||
|
|
||||||
// write the merged infos
|
// write the merged infos
|
||||||
mergeWithLogging(
|
mergeWithLogging(
|
||||||
() ->
|
this::mergeFieldInfos, segmentWriteState, segmentReadState, "field infos", numMerged);
|
||||||
codec
|
|
||||||
.fieldInfosFormat()
|
|
||||||
.write(directory, mergeState.segmentInfo, "", mergeState.mergeFieldInfos, context),
|
|
||||||
"field infos",
|
|
||||||
numMerged);
|
|
||||||
|
|
||||||
return mergeState;
|
return mergeState;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void mergeDocValues(SegmentWriteState segmentWriteState) throws IOException {
|
private void mergeFieldInfos(
|
||||||
|
SegmentWriteState segmentWriteState, SegmentReadState segmentReadState) throws IOException {
|
||||||
|
codec
|
||||||
|
.fieldInfosFormat()
|
||||||
|
.write(directory, mergeState.segmentInfo, "", mergeState.mergeFieldInfos, context);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void mergeDocValues(
|
||||||
|
SegmentWriteState segmentWriteState, SegmentReadState segmentReadState) throws IOException {
|
||||||
try (DocValuesConsumer consumer = codec.docValuesFormat().fieldsConsumer(segmentWriteState)) {
|
try (DocValuesConsumer consumer = codec.docValuesFormat().fieldsConsumer(segmentWriteState)) {
|
||||||
consumer.merge(mergeState);
|
consumer.merge(mergeState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void mergePoints(SegmentWriteState segmentWriteState) throws IOException {
|
private void mergePoints(SegmentWriteState segmentWriteState, SegmentReadState segmentReadState)
|
||||||
|
throws IOException {
|
||||||
try (PointsWriter writer = codec.pointsFormat().fieldsWriter(segmentWriteState)) {
|
try (PointsWriter writer = codec.pointsFormat().fieldsWriter(segmentWriteState)) {
|
||||||
writer.merge(mergeState);
|
writer.merge(mergeState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void mergeNorms(SegmentWriteState segmentWriteState) throws IOException {
|
private void mergeNorms(SegmentWriteState segmentWriteState, SegmentReadState segmentReadState)
|
||||||
|
throws IOException {
|
||||||
try (NormsConsumer consumer = codec.normsFormat().normsConsumer(segmentWriteState)) {
|
try (NormsConsumer consumer = codec.normsFormat().normsConsumer(segmentWriteState)) {
|
||||||
consumer.merge(mergeState);
|
consumer.merge(mergeState);
|
||||||
}
|
}
|
||||||
|
@ -235,7 +246,8 @@ final class SegmentMerger {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void mergeVectorValues(SegmentWriteState segmentWriteState) throws IOException {
|
private void mergeVectorValues(
|
||||||
|
SegmentWriteState segmentWriteState, SegmentReadState segmentReadState) throws IOException {
|
||||||
try (KnnVectorsWriter writer = codec.knnVectorsFormat().fieldsWriter(segmentWriteState)) {
|
try (KnnVectorsWriter writer = codec.knnVectorsFormat().fieldsWriter(segmentWriteState)) {
|
||||||
writer.merge(mergeState);
|
writer.merge(mergeState);
|
||||||
}
|
}
|
||||||
|
@ -246,7 +258,8 @@ final class SegmentMerger {
|
||||||
}
|
}
|
||||||
|
|
||||||
private interface VoidMerger {
|
private interface VoidMerger {
|
||||||
void merge() throws IOException;
|
void merge(SegmentWriteState segmentWriteState, SegmentReadState segmentReadState)
|
||||||
|
throws IOException;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int mergeWithLogging(Merger merger, String formatName) throws IOException {
|
private int mergeWithLogging(Merger merger, String formatName) throws IOException {
|
||||||
|
@ -264,13 +277,18 @@ final class SegmentMerger {
|
||||||
return numMerged;
|
return numMerged;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void mergeWithLogging(VoidMerger merger, String formatName, int numMerged)
|
private void mergeWithLogging(
|
||||||
|
VoidMerger merger,
|
||||||
|
SegmentWriteState segmentWriteState,
|
||||||
|
SegmentReadState segmentReadState,
|
||||||
|
String formatName,
|
||||||
|
int numMerged)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
long t0 = 0;
|
long t0 = 0;
|
||||||
if (mergeState.infoStream.isEnabled("SM")) {
|
if (mergeState.infoStream.isEnabled("SM")) {
|
||||||
t0 = System.nanoTime();
|
t0 = System.nanoTime();
|
||||||
}
|
}
|
||||||
merger.merge();
|
merger.merge(segmentWriteState, segmentReadState);
|
||||||
if (mergeState.infoStream.isEnabled("SM")) {
|
if (mergeState.infoStream.isEnabled("SM")) {
|
||||||
long t1 = System.nanoTime();
|
long t1 = System.nanoTime();
|
||||||
mergeState.infoStream.message(
|
mergeState.infoStream.message(
|
||||||
|
|
Loading…
Reference in New Issue