Java Code Examples for org.apache.lucene.store.IndexInput#toString()

The following examples show how to use org.apache.lucene.store.IndexInput#toString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CompressedIndexInput.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
public CompressedIndexInput(IndexInput in) throws IOException {
    super("compressed(" + in.toString() + ")");
    this.in = in;
    readHeader(in);
    this.version = in.readInt();
    long metaDataPosition = in.readLong();
    long headerLength = in.getFilePointer();
    in.seek(metaDataPosition);
    this.totalUncompressedLength = in.readVLong();
    int size = in.readVInt();
    offsets = BigArrays.NON_RECYCLING_INSTANCE.newLongArray(size);
    for (int i = 0; i < size; i++) {
        offsets.set(i, in.readVLong());
    }
    this.currentOffsetIdx = -1;
    this.currentUncompressedChunkPointer = 0;
    in.seek(headerLength);
}
 
Example 2
Source File: CacheIndexInput.java    From incubator-retired-blur with Apache License 2.0 6 votes vote down vote up
public CacheIndexInput(CacheDirectory directory, String fileName, IndexInput indexInput, Cache cache)
    throws IOException {
  super("CacheIndexInput(" + indexInput.toString() + ")");
  _directory = directory;
  _fileName = fileName;
  _indexInput = indexInput;
  _fileLength = indexInput.length();
  _cache = cache;

  _fileId = _cache.getFileId(_directory, _fileName);
  _cacheBlockSize = _cache.getCacheBlockSize(_directory, _fileName);
  _indexInputCache = _cache.createIndexInputCache(_directory, _fileName, _fileLength);
  _bufferSize = _cache.getFileBufferSize(_directory, _fileName);
  _quiet = _cache.shouldBeQuiet(_directory, _fileName);
  _key.setFileId(_fileId);
  _isClosed = false;
  _store = BufferStore.instance(_bufferSize);
}
 
Example 3
Source File: BaseCompoundFormatTestCase.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
public void testResourceNameInsideCompoundFile() throws Exception {
  Directory dir = newDirectory();
  String subFile = "_123.xyz";
  SegmentInfo si = newSegmentInfo(dir, "_123");
  createSequenceFile(dir, subFile, (byte) 0, 10, si.getId(), "suffix");
  
  si.setFiles(Collections.singletonList(subFile));
  si.getCodec().compoundFormat().write(dir, si, IOContext.DEFAULT);
  Directory cfs = si.getCodec().compoundFormat().getCompoundReader(dir, si, IOContext.DEFAULT);
  IndexInput in = cfs.openInput(subFile, IOContext.DEFAULT);
  String desc = in.toString();
  assertTrue("resource description hides that it's inside a compound file: " + desc, desc.contains("[slice=" + subFile + "]"));
  cfs.close();
  dir.close();
}
 
Example 4
Source File: CachedDecompressor.java    From incubator-retired-blur with Apache License 2.0 5 votes vote down vote up
@Override
public void decompress(final DataInput in, final int originalLength, final int offset, final int length,
    final BytesRef bytes) throws IOException {
  if (in instanceof IndexInput) {
    IndexInput indexInput = (IndexInput) in;
    String name = indexInput.toString();
    long filePointer = indexInput.getFilePointer();

    Entry entry = _entry.get();
    if (!entry.isValid(indexInput, name, filePointer)) {
      entry.setup(indexInput, name, filePointer);
      entry._cache.grow(originalLength + 7);
      _decompressor.decompress(indexInput, originalLength, 0, originalLength, entry._cache);
      entry._cache.length = originalLength;
      entry._cache.offset = 0;
      _entry.set(entry);
    }
    if (bytes.bytes.length < originalLength + 7) {
      bytes.bytes = new byte[ArrayUtil.oversize(originalLength + 7, 1)];
    }
    System.arraycopy(entry._cache.bytes, entry._cache.offset, bytes.bytes, 0, length + offset);
    bytes.offset = offset;
    bytes.length = length;
  } else {
    _decompressor.decompress(in, originalLength, offset, length, bytes);
  }
}
 
Example 5
Source File: BlockDirectory.java    From incubator-retired-blur with Apache License 2.0 5 votes vote down vote up
public CachedIndexInput(IndexInput source, int blockSize, String name, String cacheName, Cache cache,
    IOContext context) {
  super("CachedIndexInput(" + source.toString() + ")", context);
  _source = source;
  _blockSize = blockSize;
  _fileLength = source.length();
  _cacheName = cacheName;
  _cache = cache;
  _store = BufferStore.instance(_blockSize);
}
 
Example 6
Source File: BaseIndexFileFormatTestCase.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
ReadBytesIndexInputWrapper(IndexInput in, IntConsumer readByte) {
  super(in.toString());
  this.in = in;
  this.readByte = readByte;
}
 
Example 7
Source File: ProgressableDirectory.java    From incubator-retired-blur with Apache License 2.0 4 votes vote down vote up
ProgressableIndexInput(String name, IndexInput indexInput, int buffer, Progressable progressable) {
  super("ProgressableIndexInput(" + indexInput.toString() + ")", buffer);
  _indexInput = indexInput;
  _length = indexInput.length();
  _progressable = progressable;
}