IndexedDISI(IndexInput in, long offset, long length, long cost) throws IOException { this.slice = in.slice("docs", offset, length); this.cost = cost; }
final IndexInput slice = slice("randomaccess", offset, length); if (slice instanceof RandomAccessInput) {
@Override public IndexInput openInput(String name, IOContext context) throws IOException { ensureOpen(); final String id = IndexFileNames.stripSegmentName(name); final FileEntry entry = entries.get(id); if (entry == null) { String datFileName = IndexFileNames.segmentFileName(segmentName, "", Lucene50CompoundFormat.DATA_EXTENSION); throw new FileNotFoundException("No sub-file with id " + id + " found in compound file \"" + datFileName + "\" (fileName=" + name + " files: " + entries.keySet() + ")"); } return handle.slice(name, entry.offset, entry.length); }
TermsDict(TermsDictEntry entry, IndexInput data) throws IOException { this.entry = entry; RandomAccessInput addressesSlice = data.randomAccessSlice(entry.termsAddressesOffset, entry.termsAddressesLength); blockAddresses = DirectMonotonicReader.getInstance(entry.termsAddressesMeta, addressesSlice); bytes = data.slice("terms", entry.termsDataOffset, entry.termsDataLength); blockMask = (1L << entry.termsDictBlockShift) - 1; RandomAccessInput indexAddressesSlice = data.randomAccessSlice(entry.termsIndexAddressesOffset, entry.termsIndexAddressesLength); indexAddresses = DirectMonotonicReader.getInstance(entry.termsIndexAddressesMeta, indexAddressesSlice); indexBytes = data.slice("terms-index", entry.termsIndexOffset, entry.termsIndexLength); term = new BytesRef(entry.maxTermLength); }
final IndexInput bytesSlice = data.slice("fixed-binary", entry.dataOffset, entry.dataLength);
/** * Reads the state from a given file and compares the expected version against the actual version of * the state. */ public final T read(NamedXContentRegistry namedXContentRegistry, Path file) throws IOException { try (Directory dir = newDirectory(file.getParent())) { try (IndexInput indexInput = dir.openInput(file.getFileName().toString(), IOContext.DEFAULT)) { // We checksum the entire file before we even go and parse it. If it's corrupted we barf right here. CodecUtil.checksumEntireFile(indexInput); CodecUtil.checkHeader(indexInput, STATE_FILE_CODEC, MIN_COMPATIBLE_STATE_FILE_VERSION, STATE_FILE_VERSION); final XContentType xContentType = XContentType.values()[indexInput.readInt()]; if (xContentType != FORMAT) { throw new IllegalStateException("expected state in " + file + " to be " + FORMAT + " format but was " + xContentType); } long filePointer = indexInput.getFilePointer(); long contentSize = indexInput.length() - CodecUtil.footerLength() - filePointer; try (IndexInput slice = indexInput.slice("state_xcontent", filePointer, contentSize)) { try (XContentParser parser = XContentFactory.xContent(FORMAT) .createParser(namedXContentRegistry, LoggingDeprecationHandler.INSTANCE, new InputStreamIndexInput(slice, contentSize))) { return fromXContent(parser); } } } catch(CorruptIndexException | IndexFormatTooOldException | IndexFormatTooNewException ex) { // we trick this into a dedicated exception with the original stacktrace throw new CorruptStateException(ex); } } }
IndexedDISI(IndexInput in, long offset, long length, long cost) throws IOException { this.slice = in.slice("docs", offset, length); this.cost = cost; }
@Override public IndexInput slice(String sliceDescription, long offset, long length) throws IOException { return delegate.slice( sliceDescription, offset, length ); }
private LegacyBinaryDocValues getFixedBinary(FieldInfo field, final BinaryEntry bytes) throws IOException { final IndexInput data = this.data.slice("fixed-binary", bytes.offset, bytes.count * bytes.maxLength); final BytesRef term = new BytesRef(bytes.maxLength); final byte[] buffer = term.bytes; final int length = term.length = bytes.maxLength; return new LongBinaryDocValues() { @Override public BytesRef get(long id) { try { data.seek(id * length); data.readBytes(buffer, 0, buffer.length); return term; } catch (IOException e) { throw new RuntimeException(e); } } }; }
@Override public IndexInput openInput(String name, IOContext context) throws IOException { ensureOpen(); final String id = IndexFileNames.stripSegmentName(name); final FileEntry entry = entries.get(id); if (entry == null) { throw new FileNotFoundException("No sub-file with id " + id + " found (fileName=" + name + " files: " + entries.keySet() + ")"); } return handle.slice(name, entry.offset, entry.length); }
@Override public IndexInput openInput(String name, IOContext context) throws IOException { ensureOpen(); final String id = IndexFileNames.stripSegmentName(name); final FileEntry entry = entries.get(id); if (entry == null) { throw new FileNotFoundException("No sub-file with id " + id + " found (fileName=" + name + " files: " + entries.keySet() + ")"); } return handle.slice(name, entry.offset, entry.length); }
@Override public synchronized IndexInput openInput(String name, IOContext context) throws IOException { ensureOpen(); assert !openForWrite; final String id = IndexFileNames.stripSegmentName(name); final FileEntry entry = entries.get(id); if (entry == null) { throw new FileNotFoundException("No sub-file with id " + id + " found (fileName=" + name + " files: " + entries.keySet() + ")"); } return handle.slice(name, entry.offset, entry.length); }
@Override public IndexInput openInput(String name, IOContext context) throws IOException { ensureOpen(); final String id = IndexFileNames.stripSegmentName(name); final FileEntry entry = entries.get(id); if (entry == null) { String datFileName = IndexFileNames.segmentFileName(segmentName, "", Lucene50CompoundFormat.DATA_EXTENSION); throw new FileNotFoundException("No sub-file with id " + id + " found in compound file \"" + datFileName + "\" (fileName=" + name + " files: " + entries.keySet() + ")"); } return handle.slice(name, entry.offset, entry.length); }
@Override public IndexInput openInput(String name, IOContext context) throws IOException { ensureOpen(); int index = getIndex(name); return in.slice(name, startOffsets[index], endOffsets[index] - startOffsets[index]); }
TermsDict(TermsDictEntry entry, IndexInput data) throws IOException { this.entry = entry; RandomAccessInput addressesSlice = data.randomAccessSlice(entry.termsAddressesOffset, entry.termsAddressesLength); blockAddresses = DirectMonotonicReader.getInstance(entry.termsAddressesMeta, addressesSlice); bytes = data.slice("terms", entry.termsDataOffset, entry.termsDataLength); blockMask = (1L << entry.termsDictBlockShift) - 1; RandomAccessInput indexAddressesSlice = data.randomAccessSlice(entry.termsIndexAddressesOffset, entry.termsIndexAddressesLength); indexAddresses = DirectMonotonicReader.getInstance(entry.termsIndexAddressesMeta, indexAddressesSlice); indexBytes = data.slice("terms-index", entry.termsIndexOffset, entry.termsIndexLength); term = new BytesRef(entry.maxTermLength); }
private BinaryDocValues getCompressedBinary(FieldInfo field, final BinaryEntry bytes) throws IOException { final MonotonicBlockPackedReader addresses = getIntervalInstance(field, bytes); final ReverseTermsIndex index = getReverseIndexInstance(field, bytes); assert addresses.size() > 0; // we don't have to handle empty case IndexInput slice = data.slice("terms", bytes.offset, bytes.addressesOffset - bytes.offset); return new CompressedBinaryDocValues(bytes, addresses, index, slice); }
private BinaryDocValues getCompressedBinary(FieldInfo field, final BinaryEntry bytes) throws IOException { final MonotonicBlockPackedReader addresses = getIntervalInstance(field, bytes); final ReverseTermsIndex index = getReverseIndexInstance(field, bytes); assert addresses.size() > 0; // we don't have to handle empty case IndexInput slice = data.slice("terms", bytes.offset, bytes.addressesOffset - bytes.offset); return new CompressedBinaryDocValues(bytes, addresses, index, slice); }
private BinaryDocValues getCompressedBinary(FieldInfo field, final BinaryEntry bytes) throws IOException { final MonotonicBlockPackedReader addresses = getIntervalInstance(field, bytes); final ReverseTermsIndex index = getReverseIndexInstance(field, bytes); assert addresses.size() > 0; // we don't have to handle empty case IndexInput slice = data.slice("terms", bytes.offset, bytes.addressesOffset - bytes.offset); return new CompressedBinaryDocValues(bytes, addresses, index, slice); }
private LegacyBinaryDocValues getCompressedBinary(FieldInfo field, final BinaryEntry bytes) throws IOException { final MonotonicBlockPackedReader addresses = getIntervalInstance(field, bytes); final ReverseTermsIndex index = getReverseIndexInstance(field, bytes); assert addresses.size() > 0; // we don't have to handle empty case IndexInput slice = data.slice("terms", bytes.offset, bytes.addressesOffset - bytes.offset); return new CompressedBinaryDocValues(bytes, addresses, index, slice); }
private BinaryDocValues getCompressedBinary(FieldInfo field, final BinaryEntry bytes) throws IOException { final MonotonicBlockPackedReader addresses = getIntervalInstance(field, bytes); final ReverseTermsIndex index = getReverseIndexInstance(field, bytes); assert addresses.size() > 0; // we don't have to handle empty case IndexInput slice = data.slice("terms", bytes.offset, bytes.addressesOffset - bytes.offset); return new CompressedBinaryDocValues(bytes, addresses, index, slice); }