Skip to content

Apache Lucene open-source search software

LUCENE-4055: no more SI file cache

Michael McCandlessf4e1fa138762
diff --git a/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java b/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java
index 78d643f7c80..416f34319a5 100644
--- a/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java
+++ b/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java
@@ -2039,7 +2039,6 @@ public class IndexWriter implements Closeable, TwoPhaseCommit {
// and 2) .si reflects useCompoundFile=true change
// above:
codec.segmentInfosFormat().getSegmentInfosWriter().write(directory, newSegment, flushedSegment.fieldInfos, context);
- newSegment.clearFilesCache();
// nocommit ideally we would freeze merge.info here!!
// because any changes after writing the .si will be
@@ -2329,7 +2328,6 @@ public class IndexWriter implements Closeable, TwoPhaseCommit {
// and 2) .si reflects useCompoundFile=true change
// above:
codec.segmentInfosFormat().getSegmentInfosWriter().write(trackingDir, info, mergeState.fieldInfos, context);
- info.clearFilesCache();
info.getFiles().addAll(trackingDir.getCreatedFiles());
// Register the new segment
@@ -3596,7 +3594,6 @@ public class IndexWriter implements Closeable, TwoPhaseCommit {
}
}
}
- merge.info.clearFilesCache();
// nocommit ideally we would freeze merge.info here!!
// because any changes after writing the .si will be
diff --git a/lucene/core/src/java/org/apache/lucene/index/SegmentInfo.java b/lucene/core/src/java/org/apache/lucene/index/SegmentInfo.java
index 78824da88d1..6e0d89c9594 100644
--- a/lucene/core/src/java/org/apache/lucene/index/SegmentInfo.java
+++ b/lucene/core/src/java/org/apache/lucene/index/SegmentInfo.java
@@ -73,9 +73,6 @@ public class SegmentInfo implements Cloneable {
private boolean isCompoundFile;
- private volatile List<String> files; // Cached list of files that this segment uses
- // in the Directory
-
private volatile long sizeInBytes = -1; // total byte size of all files (computed on demand)
//TODO: LUCENE-2555: remove once we don't need to support shared doc stores (pre 4.0)
@@ -168,7 +165,7 @@ public class SegmentInfo implements Cloneable {
} else {
delGen++;
}
- clearFilesCache();
+ sizeInBytes = -1;
}
public long getNextDelGen() {
@@ -181,7 +178,7 @@ public class SegmentInfo implements Cloneable {
void clearDelGen() {
delGen = NO;
- clearFilesCache();
+ sizeInBytes = -1;
}
@Override
@@ -196,8 +193,6 @@ public class SegmentInfo implements Cloneable {
clonedNormGen = null;
}
-
-
SegmentInfo newInfo = new SegmentInfo(dir, version, name, docCount, docStoreOffset,
docStoreSegment, docStoreIsCompoundFile, clonedNormGen, isCompoundFile,
delCount, codec, new HashMap<String,String>(diagnostics));
@@ -239,7 +234,6 @@ public class SegmentInfo implements Cloneable {
*/
void setUseCompoundFile(boolean isCompoundFile) {
this.isCompoundFile = isCompoundFile;
- clearFilesCache();
}
/**
@@ -261,6 +255,7 @@ public class SegmentInfo implements Cloneable {
public void setDelGen(long delGen) {
this.delGen = delGen;
+ sizeInBytes = -1;
}
/**
@@ -325,14 +320,6 @@ public class SegmentInfo implements Cloneable {
return new ArrayList<String>(files);
}
- /* Called whenever any change is made that affects which
- * files this segment has. */
- // nocommit make private again
- public void clearFilesCache() {
- sizeInBytes = -1;
- files = null;
- }
-
/** {@inheritDoc} */
@Override
public String toString() {
@@ -443,6 +430,7 @@ public class SegmentInfo implements Cloneable {
// are in it... maybe we should somehow preserve it...
public void setFiles(Set<String> files) {
setFiles = files;
+ sizeInBytes = -1;
}
// nocommit remove this! it's only needed for
diff --git a/lucene/core/src/java/org/apache/lucene/index/SegmentInfos.java b/lucene/core/src/java/org/apache/lucene/index/SegmentInfos.java
index 2b04c296191..32a93dd4a26 100644
--- a/lucene/core/src/java/org/apache/lucene/index/SegmentInfos.java
+++ b/lucene/core/src/java/org/apache/lucene/index/SegmentInfos.java
@@ -358,7 +358,6 @@ public final class SegmentInfos implements Cloneable, Iterable<SegmentInfo> {
String fileName = IndexFileNames.segmentFileName(si.name, "", Lucene3xSegmentInfosFormat.SI_EXTENSION);
if (!directory.fileExists(fileName)) {
upgradedSIFiles.add(write3xInfo(directory, si, IOContext.DEFAULT));
- si.clearFilesCache();
}
}
}