Index: lucene/core/src/java/org/apache/lucene/index/DocumentsWriterPerThread.java =================================================================== --- lucene/core/src/java/org/apache/lucene/index/DocumentsWriterPerThread.java (revision 1445352) +++ lucene/core/src/java/org/apache/lucene/index/DocumentsWriterPerThread.java (working copy) @@ -520,7 +520,7 @@ } if (infoStream.isEnabled("DWPT")) { - final double newSegmentSize = segmentInfo.sizeInBytes()/1024./1024.; + final double newSegmentSize = segmentInfoPerCommit.sizeInBytes()/1024./1024.; infoStream.message("DWPT", "flushed: segment=" + segmentInfo.name + " ramUsed=" + nf.format(startMBUsed) + " MB" + " newFlushedSize(includes docstores)=" + nf.format(newSegmentSize) + " MB" + @@ -557,7 +557,7 @@ IndexWriter.setDiagnostics(newSegment.info, "flush"); - IOContext context = new IOContext(new FlushInfo(newSegment.info.getDocCount(), newSegment.info.sizeInBytes())); + IOContext context = new IOContext(new FlushInfo(newSegment.info.getDocCount(), newSegment.sizeInBytes())); boolean success = false; try { Index: lucene/core/src/java/org/apache/lucene/index/IndexWriter.java =================================================================== --- lucene/core/src/java/org/apache/lucene/index/IndexWriter.java (revision 1445352) +++ lucene/core/src/java/org/apache/lucene/index/IndexWriter.java (working copy) @@ -2301,7 +2301,7 @@ infoStream.message("IW", "addIndexes: process segment origName=" + info.info.name + " newName=" + newSegName + " info=" + info); } - IOContext context = new IOContext(new MergeInfo(info.info.getDocCount(), info.info.sizeInBytes(), true, -1)); + IOContext context = new IOContext(new MergeInfo(info.info.getDocCount(), info.sizeInBytes(), true, -1)); for(FieldInfo fi : getFieldInfos(info.info)) { globalFieldNumberMap.addOrGet(fi.name, fi.number, fi.getDocValuesType()); @@ -3458,7 +3458,7 @@ final int delCount = numDeletedDocs(info); assert delCount <= info.info.getDocCount(); final double delRatio = ((double) delCount)/info.info.getDocCount(); - merge.estimatedMergeBytes += info.info.sizeInBytes() * (1.0 - delRatio); + merge.estimatedMergeBytes += info.sizeInBytes() * (1.0 - delRatio); } } } @@ -3759,7 +3759,7 @@ // lost... if (infoStream.isEnabled("IW")) { - infoStream.message("IW", String.format(Locale.ROOT, "merged segment size=%.3f MB vs estimate=%.3f MB", merge.info.info.sizeInBytes()/1024./1024., merge.estimatedMergeBytes/1024/1024.)); + infoStream.message("IW", String.format(Locale.ROOT, "merged segment size=%.3f MB vs estimate=%.3f MB", merge.info.sizeInBytes()/1024./1024., merge.estimatedMergeBytes/1024/1024.)); } final IndexReaderWarmer mergedSegmentWarmer = config.getMergedSegmentWarmer(); Index: lucene/core/src/java/org/apache/lucene/index/MergePolicy.java =================================================================== --- lucene/core/src/java/org/apache/lucene/index/MergePolicy.java (revision 1445352) +++ lucene/core/src/java/org/apache/lucene/index/MergePolicy.java (working copy) @@ -192,7 +192,7 @@ public long totalBytesSize() throws IOException { long total = 0; for (SegmentInfoPerCommit info : segments) { - total += info.info.sizeInBytes(); + total += info.sizeInBytes(); } return total; } Index: lucene/core/src/java/org/apache/lucene/index/SegmentInfo.java =================================================================== --- lucene/core/src/java/org/apache/lucene/index/SegmentInfo.java (revision 1445352) +++ lucene/core/src/java/org/apache/lucene/index/SegmentInfo.java (working copy) @@ -18,7 +18,6 @@ */ -import java.io.IOException; import java.util.Collection; import java.util.Collections; import java.util.HashMap; @@ -57,8 +56,6 @@ private boolean isCompoundFile; - private volatile long sizeInBytes = -1; // total byte size of all files (computed on demand) - private Codec codec; private Map diagnostics; @@ -101,23 +98,6 @@ } /** - * Returns total size in bytes of all of files used by - * this segment. Note that this will not include any live - * docs for the segment; to include that use {@link - * SegmentInfoPerCommit#sizeInBytes()} instead. - */ - public long sizeInBytes() throws IOException { - if (sizeInBytes == -1) { - long sum = 0; - for (final String fileName : files()) { - sum += dir.fileLength(fileName); - } - sizeInBytes = sum; - } - return sizeInBytes; - } - - /** * Mark whether this segment is stored as a compound file. * * @param isCompoundFile true if this is a compound file; @@ -254,7 +234,6 @@ public void setFiles(Set files) { checkFileNames(files); setFiles = files; - sizeInBytes = -1; } /** Add these files to the set of files written for this @@ -262,7 +241,6 @@ public void addFiles(Collection files) { checkFileNames(files); setFiles.addAll(files); - sizeInBytes = -1; } /** Add this file to the set of files written for this @@ -270,7 +248,6 @@ public void addFile(String file) { checkFileNames(Collections.singleton(file)); setFiles.add(file); - sizeInBytes = -1; } private void checkFileNames(Collection files) { Index: lucene/core/src/java/org/apache/lucene/index/TieredMergePolicy.java =================================================================== --- lucene/core/src/java/org/apache/lucene/index/TieredMergePolicy.java (revision 1445352) +++ lucene/core/src/java/org/apache/lucene/index/TieredMergePolicy.java (working copy) @@ -374,7 +374,7 @@ for(int idx = tooBigCount; idx