diff --git a/lucene/core/src/java/org/apache/lucene/codecs/DocValuesConsumer.java b/lucene/core/src/java/org/apache/lucene/codecs/DocValuesConsumer.java index 94665faced1..d001053eb5b 100644 --- a/lucene/core/src/java/org/apache/lucene/codecs/DocValuesConsumer.java +++ b/lucene/core/src/java/org/apache/lucene/codecs/DocValuesConsumer.java @@ -103,7 +103,7 @@ public abstract class DocValuesConsumer { } // only finish if no exception is thrown! if (hasMerged) { - finish(mergeState.mergedDocCount); + finish(mergeState.segmentInfo.getDocCount()); } } diff --git a/lucene/core/src/java/org/apache/lucene/codecs/TermsConsumer.java b/lucene/core/src/java/org/apache/lucene/codecs/TermsConsumer.java index 3d887f3c813..a8f03887bdd 100644 --- a/lucene/core/src/java/org/apache/lucene/codecs/TermsConsumer.java +++ b/lucene/core/src/java/org/apache/lucene/codecs/TermsConsumer.java @@ -79,7 +79,7 @@ public abstract class TermsConsumer { long sumTotalTermFreq = 0; long sumDocFreq = 0; long sumDFsinceLastAbortCheck = 0; - FixedBitSet visitedDocs = new FixedBitSet(mergeState.mergedDocCount); + FixedBitSet visitedDocs = new FixedBitSet(mergeState.segmentInfo.getDocCount()); IndexOptions indexOptions = mergeState.fieldInfo.getIndexOptions(); if (indexOptions == IndexOptions.DOCS_ONLY) { diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene40/values/FixedSortedBytesImpl.java b/lucene/core/src/java/org/apache/lucene/codecs/lucene40/values/FixedSortedBytesImpl.java index 278cb89d30a..6b3454d3f1b 100644 --- a/lucene/core/src/java/org/apache/lucene/codecs/lucene40/values/FixedSortedBytesImpl.java +++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene40/values/FixedSortedBytesImpl.java @@ -68,7 +68,7 @@ class FixedSortedBytesImpl { throws IOException { boolean success = false; try { - final MergeContext ctx = SortedBytesMergeUtils.init(Type.BYTES_FIXED_SORTED, docValues, comp, mergeState.mergedDocCount); + final MergeContext ctx = SortedBytesMergeUtils.init(Type.BYTES_FIXED_SORTED, docValues, comp, mergeState.segmentInfo.getDocCount()); List slices = SortedBytesMergeUtils.buildSlices(mergeState.docBase, mergeState.docMaps, docValues, ctx); final IndexOutput datOut = getOrCreateDataOut(); datOut.writeInt(ctx.sizePerValues); diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene40/values/VarSortedBytesImpl.java b/lucene/core/src/java/org/apache/lucene/codecs/lucene40/values/VarSortedBytesImpl.java index 87c3f653d5f..978761ada5c 100644 --- a/lucene/core/src/java/org/apache/lucene/codecs/lucene40/values/VarSortedBytesImpl.java +++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene40/values/VarSortedBytesImpl.java @@ -71,7 +71,7 @@ final class VarSortedBytesImpl { throws IOException { boolean success = false; try { - MergeContext ctx = SortedBytesMergeUtils.init(Type.BYTES_VAR_SORTED, docValues, comp, mergeState.mergedDocCount); + MergeContext ctx = SortedBytesMergeUtils.init(Type.BYTES_VAR_SORTED, docValues, comp, mergeState.segmentInfo.getDocCount()); final List slices = SortedBytesMergeUtils.buildSlices(mergeState.docBase, mergeState.docMaps, docValues, ctx); IndexOutput datOut = getOrCreateDataOut(); diff --git a/lucene/core/src/java/org/apache/lucene/index/MergeState.java b/lucene/core/src/java/org/apache/lucene/index/MergeState.java index b1d1cdb7487..367d231e8e8 100644 --- a/lucene/core/src/java/org/apache/lucene/index/MergeState.java +++ b/lucene/core/src/java/org/apache/lucene/index/MergeState.java @@ -45,7 +45,6 @@ public class MergeState { public List readers; // Readers & liveDocs being merged public int[][] docMaps; // Maps docIDs around deletions public int[] docBase; // New docID base per reader - public int mergedDocCount; // Total # merged docs public CheckAbort checkAbort; public InfoStream infoStream; diff --git a/lucene/core/src/java/org/apache/lucene/index/SegmentMerger.java b/lucene/core/src/java/org/apache/lucene/index/SegmentMerger.java index eba81f12bb2..313de472169 100644 --- a/lucene/core/src/java/org/apache/lucene/index/SegmentMerger.java +++ b/lucene/core/src/java/org/apache/lucene/index/SegmentMerger.java @@ -107,13 +107,11 @@ final class SegmentMerger { // IndexWriter.close(false) takes to actually stop the // threads. - // nocommit: can we nuke this count too? - mergeState.mergedDocCount = setDocMaps(); - mergeState.segmentInfo.setDocCount(mergeState.mergedDocCount); + mergeState.segmentInfo.setDocCount(setDocMaps()); mergeDocValuesAndNormsFieldInfos(); setMatchingSegmentReaders(); int numMerged = mergeFields(); - assert numMerged == mergeState.mergedDocCount; + assert numMerged == mergeState.segmentInfo.getDocCount(); final SegmentWriteState segmentWriteState = new SegmentWriteState(mergeState.infoStream, directory, mergeState.segmentInfo, mergeState.fieldInfos, termIndexInterval, null, context); @@ -126,7 +124,7 @@ final class SegmentMerger { if (mergeState.fieldInfos.hasVectors()) { numMerged = mergeVectors(); - assert numMerged == mergeState.mergedDocCount; + assert numMerged == mergeState.segmentInfo.getDocCount(); } // write the merged infos diff --git a/lucene/core/src/test/org/apache/lucene/index/TestSegmentMerger.java b/lucene/core/src/test/org/apache/lucene/index/TestSegmentMerger.java index 3fed03c6169..2cff5c3cb0e 100644 --- a/lucene/core/src/test/org/apache/lucene/index/TestSegmentMerger.java +++ b/lucene/core/src/test/org/apache/lucene/index/TestSegmentMerger.java @@ -84,7 +84,7 @@ public class TestSegmentMerger extends LuceneTestCase { merger.add(reader1); merger.add(reader2); MergeState mergeState = merger.merge(); - int docsMerged = mergeState.mergedDocCount; + int docsMerged = mergeState.segmentInfo.getDocCount(); assertTrue(docsMerged == 2); //Should be able to open a new SegmentReader against the new directory SegmentReader mergedReader = new SegmentReader(new SegmentInfoPerCommit(