/** * Cleans up residuals from a segment that could not be entirely flushed due to an error */ private synchronized final void flushFailed(SegmentInfo info) throws IOException { // TODO: this really should be a tragic Collection<String> files; try { files = info.files(); } catch (IllegalStateException ise) { // OK files = null; } if (files != null) { deleter.deleteNewFiles(files); } }
/** Returns all files in use by this segment. */ public Collection<String> files() throws IOException { // Start from the wrapped info's files: Collection<String> files = new HashSet<>(info.files()); // TODO we could rely on TrackingDir.getCreatedFiles() (like we do for // updates) and then maybe even be able to remove LiveDocsFormat.files(). // Must separately add any live docs files: info.getCodec().liveDocsFormat().files(this, files); // must separately add any field updates files for (Set<String> updatefiles : dvUpdatesFiles.values()) { files.addAll(updatefiles); } // must separately add fieldInfos files files.addAll(fieldInfosFiles); return files; }
info.getFieldInfosGen(), info.getDocValuesGen()); newInfo.setFiles(info.info.files()); newInfoPerCommit.setFieldInfosFiles(info.getFieldInfosFiles()); newInfoPerCommit.setDocValuesUpdatesFiles(info.getDocValuesUpdatesFiles());
Set<String> files = si.files(); for (String file : files) { if (!IndexFileNames.parseSegmentName(file).equals(si.name)) {
Set<String> originalFiles = newSegment.info.files();
List files() throws IOException { return new ArrayList(si.files()); }
List files() throws IOException { return new ArrayList(si.files()); }
/** * Cleans up residuals from a segment that could not be entirely flushed due to an error */ synchronized final void flushFailed(SegmentInfo info) throws IOException { // TODO: this really should be a tragic Collection<String> files; try { files = info.files(); } catch (IllegalStateException ise) { // OK files = null; } if (files != null) { deleter.deleteNewFiles(files); } }
void init(Directory directory, SegmentInfos segmentInfos, boolean closeDirectory, boolean readOnly) throws IOException { this.directory = directory; this.segmentInfos = segmentInfos; this.closeDirectory = closeDirectory; this.readOnly = readOnly; if (!readOnly && segmentInfos != null) { // We assume that this segments_N was previously // properly sync'd: for(int i=0;i<segmentInfos.size();i++) { final SegmentInfo info = segmentInfos.info(i); List files = info.files(); for(int j=0;j<files.size();j++) synced.add(files.get(j)); } } }
/** Returns all files in use by this segment. */ public Collection<String> files() throws IOException { // Start from the wrapped info's files: Collection<String> files = new HashSet<>(info.files()); // TODO we could rely on TrackingDir.getCreatedFiles() (like we do for // updates) and then maybe even be able to remove LiveDocsFormat.files(). // Must separately add any live docs files: info.getCodec().liveDocsFormat().files(this, files); // must separately add any field updates files for (Set<String> updatefiles : dvUpdatesFiles.values()) { files.addAll(updatefiles); } // must separately add fieldInfos files files.addAll(fieldInfosFiles); return files; }
void decRef(SegmentInfos segmentInfos) throws IOException { final int size = segmentInfos.size(); for(int i=0;i<size;i++) { SegmentInfo segmentInfo = segmentInfos.info(i); if (segmentInfo.dir == directory) { decRef(segmentInfo.files()); } } }
private void decrefMergeSegments(MergePolicy.OneMerge merge) throws IOException { final SegmentInfos sourceSegmentsClone = merge.segmentsClone; final int numSegmentsToMerge = sourceSegmentsClone.size(); assert merge.increfDone; merge.increfDone = false; for(int i=0;i<numSegmentsToMerge;i++) { final SegmentInfo previousInfo = sourceSegmentsClone.info(i); // Decref all files for this SegmentInfo (this // matches the incref in mergeInit): if (previousInfo.dir == directory) deleter.decRef(previousInfo.files()); } }
private void decrefMergeSegments(MergePolicy.OneMerge merge) throws IOException { final SegmentInfos sourceSegmentsClone = merge.segmentsClone; final int numSegmentsToMerge = sourceSegmentsClone.size(); assert merge.increfDone; merge.increfDone = false; for(int i=0;i<numSegmentsToMerge;i++) { final SegmentInfo previousInfo = sourceSegmentsClone.info(i); // Decref all files for this SegmentInfo (this // matches the incref in mergeInit): if (previousInfo.dir == directory) deleter.decRef(previousInfo.files()); } }
void decRef(SegmentInfos segmentInfos) throws IOException { final int size = segmentInfos.size(); for(int i=0;i<size;i++) { SegmentInfo segmentInfo = segmentInfos.info(i); if (segmentInfo.dir == directory) { decRef(segmentInfo.files()); } } }
@Override public void write(Directory dir, SegmentInfo si, IOContext context) throws IOException { String fileName = IndexFileNames.segmentFileName(si.name, "", COMPOUND_FILE_EXTENSION); try (Directory cfs = new Lucene40CompoundReader(dir, fileName, context, true)) { for (String file : si.files()) { cfs.copyFrom(dir, file, file, context); } } }
ReaderCommit(SegmentInfos infos, Directory dir) throws IOException { segmentsFileName = infos.getCurrentSegmentFileName(); this.dir = dir; final int size = infos.size(); files = new ArrayList(size); files.add(segmentsFileName); for(int i=0;i<size;i++) { SegmentInfo info = infos.info(i); if (info.dir == dir) files.addAll(info.files()); } version = infos.getVersion(); generation = infos.getGeneration(); isOptimized = infos.size() == 1 && !infos.info(0).hasDeletions(); }
ReaderCommit(SegmentInfos infos, Directory dir) throws IOException { segmentsFileName = infos.getCurrentSegmentFileName(); this.dir = dir; final int size = infos.size(); files = new ArrayList(size); files.add(segmentsFileName); for(int i=0;i<size;i++) { SegmentInfo info = infos.info(i); if (info.dir == dir) files.addAll(info.files()); } version = infos.getVersion(); generation = infos.getGeneration(); isOptimized = infos.size() == 1 && !infos.info(0).hasDeletions(); }
void incRef(SegmentInfos segmentInfos, boolean isCommit) throws IOException { int size = segmentInfos.size(); for(int i=0;i<size;i++) { SegmentInfo segmentInfo = segmentInfos.info(i); if (segmentInfo.dir == directory) { incRef(segmentInfo.files()); } } if (isCommit) { // Since this is a commit point, also incref its // segments_N file: getRefCount(segmentInfos.getCurrentSegmentFileName()).IncRef(); } }
void incRef(SegmentInfos segmentInfos, boolean isCommit) throws IOException { int size = segmentInfos.size(); for(int i=0;i<size;i++) { SegmentInfo segmentInfo = segmentInfos.info(i); if (segmentInfo.dir == directory) { incRef(segmentInfo.files()); } } if (isCommit) { // Since this is a commit point, also incref its // segments_N file: getRefCount(segmentInfos.getCurrentSegmentFileName()).IncRef(); } }