Example usage for org.apache.lucene.store IndexInput toString

List of usage examples for org.apache.lucene.store IndexInput toString

Introduction

In this page you can find the example usage for org.apache.lucene.store IndexInput toString.

Prototype

@Override
    public String toString() 

Source Link

Usage

From source file:org.apache.blur.lucene.codec.CachedDecompressor.java

License:Apache License

@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();/*from  w  ww.  jav a  2s  .co m*/
        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);
    }
}

From source file:org.apache.blur.lucene.store.refcounter.DirectoryReferenceCounter.java

License:Apache License

private IndexInput wrap(String name, IndexInput input) {
    AtomicInteger counter = _refCounters.get(name);
    if (counter == null) {
        counter = new AtomicInteger();
        _refCounters.put(name, counter);
    }/*ww  w .  j  a  v a2s. c om*/
    return new RefIndexInput(input.toString(), input, counter);
}

From source file:org.apache.blur.lucene.warmup.ThrottledIndexInput.java

License:Apache License

public ThrottledIndexInput(IndexInput rawStream, long maxBytesPerSec) {
    super(rawStream.toString());
    _rawStream = rawStream;//from   w w w  .ja  va 2 s .co  m
    _maxBytesPerSec = maxBytesPerSec;
}

From source file:org.apache.blur.store.blockcache_v2.CacheIndexInput.java

License:Apache License

public CacheIndexInput(CacheDirectory directory, String fileName, IndexInput indexInput, Cache cache)
        throws IOException {
    super("CacheIndexInput(" + indexInput.toString() + ")");
    _directory = directory;/*w w w  . j  av a  2 s .  c o  m*/
    _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);
}

From source file:org.elasticsearch.common.compress.CompressedIndexInput.java

License:Apache License

public CompressedIndexInput(IndexInput in, T context) throws IOException {
    super("compressed(" + in.toString() + ")");
    this.in = in;
    this.context = context;
    readHeader(in);/* w ww . j av a2 s  .c  o m*/
    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.newLongArray(size);
    for (int i = 0; i < size; i++) {
        offsets.set(i, in.readVLong());
    }
    this.currentOffsetIdx = -1;
    this.currentUncompressedChunkPointer = 0;
    in.seek(headerLength);
}

From source file:org.elasticsearch.common.lucene.store.ByteArrayIndexInputTests.java

License:Apache License

private byte[] randomReadAndSlice(IndexInput indexInput, int length) throws IOException {
    int readPos = (int) indexInput.getFilePointer();
    byte[] output = new byte[length];
    while (readPos < length) {
        switch (randomIntBetween(0, 3)) {
        case 0://from   w w  w .  java2 s  . co m
            // Read by one byte at a time
            output[readPos++] = indexInput.readByte();
            break;
        case 1:
            // Read several bytes into target
            int len = randomIntBetween(1, length - readPos);
            indexInput.readBytes(output, readPos, len);
            readPos += len;
            break;
        case 2:
            // Read several bytes into 0-offset target
            len = randomIntBetween(1, length - readPos);
            byte[] temp = new byte[len];
            indexInput.readBytes(temp, 0, len);
            System.arraycopy(temp, 0, output, readPos, len);
            readPos += len;
            break;
        case 3:
            // Read using slice
            len = randomIntBetween(1, length - readPos);
            IndexInput slice = indexInput
                    .slice("slice (" + readPos + ", " + len + ") of " + indexInput.toString(), readPos, len);
            temp = randomReadAndSlice(slice, len);
            // assert that position in the original input didn't change
            assertEquals(readPos, indexInput.getFilePointer());
            System.arraycopy(temp, 0, output, readPos, len);
            readPos += len;
            indexInput.seek(readPos);
            assertEquals(readPos, indexInput.getFilePointer());
            break;
        default:
            fail();
        }
        assertEquals((long) readPos, indexInput.getFilePointer());
    }
    return output;
}