static FieldInfos readFieldInfos(SegmentCommitInfo si) throws IOException { Codec codec = si.info.getCodec(); FieldInfosFormat reader = codec.fieldInfosFormat(); if (si.hasFieldUpdates()) { // there are updates, we read latest (always outside of CFS) final String segmentSuffix = Long.toString(si.getFieldInfosGen(), Character.MAX_RADIX); return reader.read(si.info.dir, si.info, segmentSuffix, IOContext.READONCE); } else if (si.info.getUseCompoundFile()) { // cfs try (Directory cfs = codec.compoundFormat().getCompoundReader(si.info.dir, si.info, IOContext.DEFAULT)) { return reader.read(cfs, si.info, "", IOContext.READONCE); } } else { // no cfs return reader.read(si.info.dir, si.info, "", IOContext.READONCE); } }
/** * NOTE: this method creates a compound file for all files returned by * info.files(). While, generally, this may include separate norms and * deletion files, this SegmentInfo must not reference such files when this * method is called, because they are not allowed within a compound file. */ static final void createCompoundFile(InfoStream infoStream, TrackingDirectoryWrapper directory, final SegmentInfo info, IOContext context, IOUtils.IOConsumer<Collection<String>> deleteFiles) throws IOException { // maybe this check is not needed, but why take the risk? if (!directory.getCreatedFiles().isEmpty()) { throw new IllegalStateException("pass a clean trackingdir for CFS creation"); } if (infoStream.isEnabled("IW")) { infoStream.message("IW", "create compound file"); } // Now merge all added files boolean success = false; try { info.getCodec().compoundFormat().write(directory, info, context); success = true; } finally { if (!success) { // Safe: these files must exist deleteFiles.accept(directory.getCreatedFiles()); } } // Replace all previous files with the CFS/CFE files: info.setFiles(new HashSet<>(directory.getCreatedFiles())); }
private FieldInfos readFieldInfos() throws IOException { SegmentInfo segInfo = info.info; Directory dir = segInfo.dir; if (info.hasFieldUpdates() == false) { // updates always outside of CFS Closeable toClose; if (segInfo.getUseCompoundFile()) { toClose = dir = segInfo.getCodec().compoundFormat().getCompoundReader(segInfo.dir, segInfo, IOContext.READONCE); } else { toClose = null; dir = segInfo.dir; } try { return segInfo.getCodec().fieldInfosFormat().read(dir, segInfo, "", IOContext.READONCE); } finally { IOUtils.close(toClose); } } else { FieldInfosFormat fisFormat = segInfo.getCodec().fieldInfosFormat(); final String segmentSuffix = Long.toString(info.getFieldInfosGen(), Character.MAX_RADIX); return fisFormat.read(dir, segInfo, segmentSuffix, IOContext.READONCE); } }
/** * NOTE: this method creates a compound file for all files returned by * info.files(). While, generally, this may include separate norms and * deletion files, this SegmentInfo must not reference such files when this * method is called, because they are not allowed within a compound file. */ static final void createCompoundFile(InfoStream infoStream, TrackingDirectoryWrapper directory, final SegmentInfo info, IOContext context, IOUtils.IOConsumer<Collection<String>> deleteFiles) throws IOException { // maybe this check is not needed, but why take the risk? if (!directory.getCreatedFiles().isEmpty()) { throw new IllegalStateException("pass a clean trackingdir for CFS creation"); } if (infoStream.isEnabled("IW")) { infoStream.message("IW", "create compound file"); } // Now merge all added files boolean success = false; try { info.getCodec().compoundFormat().write(directory, info, context); success = true; } finally { if (!success) { // Safe: these files must exist deleteFiles.accept(directory.getCreatedFiles()); } } // Replace all previous files with the CFS/CFE files: info.setFiles(new HashSet<>(directory.getCreatedFiles())); }
cfsDir = cfsReader = codec.compoundFormat().getCompoundReader(dir, si.info, context); } else { cfsReader = null;
/** * NOTE: this method creates a compound file for all files returned by * info.files(). While, generally, this may include separate norms and * deletion files, this SegmentInfo must not reference such files when this * method is called, because they are not allowed within a compound file. */ final void createCompoundFile(InfoStream infoStream, TrackingDirectoryWrapper directory, final SegmentInfo info, IOContext context) throws IOException { // maybe this check is not needed, but why take the risk? if (!directory.getCreatedFiles().isEmpty()) { throw new IllegalStateException("pass a clean trackingdir for CFS creation"); } if (infoStream.isEnabled("IW")) { infoStream.message("IW", "create compound file"); } // Now merge all added files boolean success = false; try { info.getCodec().compoundFormat().write(directory, info, context); success = true; } finally { if (!success) { // Safe: these files must exist deleteNewFiles(directory.getCreatedFiles()); } } // Replace all previous files with the CFS/CFE files: info.setFiles(new HashSet<>(directory.getCreatedFiles())); }
if (useCompoundFile) { try { directory = engineConfig.getCodec().compoundFormat().getCompoundReader(segmentReader.directory(), segmentCommitInfo.info, IOContext.READ); } catch (IOException e) {
/** * NOTE: this method creates a compound file for all files returned by * info.files(). While, generally, this may include separate norms and * deletion files, this SegmentInfo must not reference such files when this * method is called, because they are not allowed within a compound file. */ final void createCompoundFile(InfoStream infoStream, TrackingDirectoryWrapper directory, final SegmentInfo info, IOContext context) throws IOException { // maybe this check is not needed, but why take the risk? if (!directory.getCreatedFiles().isEmpty()) { throw new IllegalStateException("pass a clean trackingdir for CFS creation"); } if (infoStream.isEnabled("IW")) { infoStream.message("IW", "create compound file"); } // Now merge all added files boolean success = false; try { info.getCodec().compoundFormat().write(directory, info, context); success = true; } finally { if (!success) { // Safe: these files must exist deleteNewFiles(directory.getCreatedFiles()); } } // Replace all previous files with the CFS/CFE files: info.setFiles(new HashSet<>(directory.getCreatedFiles())); }
static FieldInfos readFieldInfos(SegmentCommitInfo si) throws IOException { Codec codec = si.info.getCodec(); FieldInfosFormat reader = codec.fieldInfosFormat(); if (si.hasFieldUpdates()) { // there are updates, we read latest (always outside of CFS) final String segmentSuffix = Long.toString(si.getFieldInfosGen(), Character.MAX_RADIX); return reader.read(si.info.dir, si.info, segmentSuffix, IOContext.READONCE); } else if (si.info.getUseCompoundFile()) { // cfs try (Directory cfs = codec.compoundFormat().getCompoundReader(si.info.dir, si.info, IOContext.DEFAULT)) { return reader.read(cfs, si.info, "", IOContext.READONCE); } } else { // no cfs return reader.read(si.info.dir, si.info, "", IOContext.READONCE); } }
static FieldInfos readFieldInfos(SegmentCommitInfo si) throws IOException { Codec codec = si.info.getCodec(); FieldInfosFormat reader = codec.fieldInfosFormat(); if (si.hasFieldUpdates()) { // there are updates, we read latest (always outside of CFS) final String segmentSuffix = Long.toString(si.getFieldInfosGen(), Character.MAX_RADIX); return reader.read(si.info.dir, si.info, segmentSuffix, IOContext.READONCE); } else if (si.info.getUseCompoundFile()) { // cfs try (Directory cfs = codec.compoundFormat().getCompoundReader(si.info.dir, si.info, IOContext.DEFAULT)) { return reader.read(cfs, si.info, "", IOContext.READONCE); } } else { // no cfs return reader.read(si.info.dir, si.info, "", IOContext.READONCE); } }
static FieldInfos readFieldInfos(SegmentCommitInfo si) throws IOException { Codec codec = si.info.getCodec(); FieldInfosFormat reader = codec.fieldInfosFormat(); if (si.hasFieldUpdates()) { // there are updates, we read latest (always outside of CFS) final String segmentSuffix = Long.toString(si.getFieldInfosGen(), Character.MAX_RADIX); return reader.read(si.info.dir, si.info, segmentSuffix, IOContext.READONCE); } else if (si.info.getUseCompoundFile()) { // cfs try (Directory cfs = codec.compoundFormat().getCompoundReader(si.info.dir, si.info, IOContext.DEFAULT)) { return reader.read(cfs, si.info, "", IOContext.READONCE); } } else { // no cfs return reader.read(si.info.dir, si.info, "", IOContext.READONCE); } }
private FieldInfos readFieldInfos() throws IOException { SegmentInfo segInfo = info.info; Directory dir = segInfo.dir; if (info.hasFieldUpdates() == false) { // updates always outside of CFS Closeable toClose; if (segInfo.getUseCompoundFile()) { toClose = dir = segInfo.getCodec().compoundFormat().getCompoundReader(segInfo.dir, segInfo, IOContext.READONCE); } else { toClose = null; dir = segInfo.dir; } try { return segInfo.getCodec().fieldInfosFormat().read(dir, segInfo, "", IOContext.READONCE); } finally { IOUtils.close(toClose); } } else { FieldInfosFormat fisFormat = segInfo.getCodec().fieldInfosFormat(); final String segmentSuffix = Long.toString(info.getFieldInfosGen(), Character.MAX_RADIX); return fisFormat.read(dir, segInfo, segmentSuffix, IOContext.READONCE); } }
if (useCompoundFile) { try { directory = engineConfig.getCodec().compoundFormat().getCompoundReader(segmentReader.directory(), segmentCommitInfo.info, IOContext.READ); } catch (IOException e) { logger.warn(() -> new ParameterizedMessage("Error when opening compound reader for Directory [{}] and SegmentCommitInfo [{}]", segmentReader.directory(), segmentCommitInfo), e);
if (useCompoundFile) { try { directory = engineConfig.getCodec().compoundFormat().getCompoundReader(segmentReader.directory(), segmentCommitInfo.info, IOContext.READ); } catch (IOException e) { logger.warn((Supplier<?>) () -> new ParameterizedMessage("Error when opening compound reader for Directory [{}] and SegmentCommitInfo [{}]", segmentReader.directory(), segmentCommitInfo), e);
if (useCompoundFile) { try { directory = engineConfig.getCodec().compoundFormat().getCompoundReader(segmentReader.directory(), segmentCommitInfo.info, IOContext.READ); } catch (IOException e) { logger.warn(() -> new ParameterizedMessage("Error when opening compound reader for Directory [{}] and SegmentCommitInfo [{}]", segmentReader.directory(), segmentCommitInfo), e);
cfsDir = cfsReader = codec.compoundFormat().getCompoundReader(dir, si.info, context); } else { cfsReader = null;
cfsDir = cfsReader = codec.compoundFormat().getCompoundReader(dir, si.info, context); } else { cfsReader = null;
cfsDir = cfsReader = codec.compoundFormat().getCompoundReader(dir, si.info, context); } else { cfsReader = null;