/** Creates a {@code MultiLevelSkipListReader}. */ protected MultiLevelSkipListReader(IndexInput skipStream, int maxSkipLevels, int skipInterval, int skipMultiplier) { this.skipStream = new IndexInput[maxSkipLevels]; this.skipPointer = new long[maxSkipLevels]; this.childPointer = new long[maxSkipLevels]; this.numSkipped = new int[maxSkipLevels]; this.maxNumberOfSkipLevels = maxSkipLevels; this.skipInterval = new int[maxSkipLevels]; this.skipMultiplier = skipMultiplier; this.skipStream [0]= skipStream; this.inputIsBuffered = (skipStream instanceof BufferedIndexInput); this.skipInterval[0] = skipInterval; for (int i = 1; i < maxSkipLevels; i++) { // cache skip intervals this.skipInterval[i] = this.skipInterval[i - 1] * skipMultiplier; } skipDoc = new int[maxSkipLevels]; }
@Override public IndexInput slice(final String sliceDescription, final long offset, final long length) throws IOException { // TODO Auto-generated method stub logger.debug("FetchOnBufferReadJdbcIndexInput.slice()"); final RAMInputStream r = null; final BufferedIndexInput b = null; final ChecksumIndexInput c = null; return new SlicedIndexInput(sliceDescription, this, offset, length); }
SlicedIndexInput(final String sliceDescription, final IndexInput base, final long offset, final long length) { super(sliceDescription == null ? base.toString() : base.toString() + " [slice=" + sliceDescription + "]", BufferedIndexInput.BUFFER_SIZE); if (offset < 0 || length < 0 || offset + length > base.length()) { throw new IllegalArgumentException("slice() " + sliceDescription + " out of bounds: " + base); } this.base = base.clone(); fileOffset = offset; this.length = length; }
TermInfosReader(Directory dir, String seg, FieldInfos fis) throws CorruptIndexException, IOException { this(dir, seg, fis, BufferedIndexInput.BUFFER_SIZE); }
/** Loads the skip levels */ private void loadSkipLevels() throws IOException { if (docCount <= skipInterval[0]) { numberOfSkipLevels = 1; } else { numberOfSkipLevels = 1+MathUtil.log(docCount/skipInterval[0], skipMultiplier); } if (numberOfSkipLevels > maxNumberOfSkipLevels) { numberOfSkipLevels = maxNumberOfSkipLevels; } skipStream[0].seek(skipPointer[0]); int toBuffer = numberOfLevelsToBuffer; for (int i = numberOfSkipLevels - 1; i > 0; i--) { // the length of the current level long length = skipStream[0].readVLong(); // the start pointer of the current level skipPointer[i] = skipStream[0].getFilePointer(); if (toBuffer > 0) { // buffer this level skipStream[i] = new SkipBuffer(skipStream[0], (int) length); toBuffer--; } else { // clone this stream, it is already at the start of the current level skipStream[i] = skipStream[0].clone(); if (inputIsBuffered && length < BufferedIndexInput.BUFFER_SIZE) { ((BufferedIndexInput) skipStream[i]).setBufferSize(Math.max(BufferedIndexInput.MIN_BUFFER_SIZE, (int) length)); } // move base stream beyond the current level skipStream[0].seek(skipStream[0].getFilePointer() + length); } } // use base stream for the lowest level skipPointer[0] = skipStream[0].getFilePointer(); }
@Override public IndexInput slice(String description, long offset, long length) throws IOException { return BufferedIndexInput.wrap(description, this, offset, length); }
private FaultyIndexInput(IndexInput delegate) { super("FaultyIndexInput(" + delegate + ")", BufferedIndexInput.BUFFER_SIZE); this.delegate = delegate; }
@Override public IndexInput slice(String sliceDescription, long offset, long length) throws IOException { return BufferedIndexInput.wrap(sliceDescription, this, offset, length); }
public MockIndexInput(byte[] bytes) { super("MockIndexInput", BufferedIndexInput.BUFFER_SIZE); buffer = bytes; length = bytes.length; }
/** Loads the skip levels */ private void loadSkipLevels() throws IOException { if (docCount <= skipInterval[0]) { numberOfSkipLevels = 1; } else { numberOfSkipLevels = 1+MathUtil.log(docCount/skipInterval[0], skipMultiplier); } if (numberOfSkipLevels > maxNumberOfSkipLevels) { numberOfSkipLevels = maxNumberOfSkipLevels; } skipStream[0].seek(skipPointer[0]); int toBuffer = numberOfLevelsToBuffer; for (int i = numberOfSkipLevels - 1; i > 0; i--) { // the length of the current level long length = skipStream[0].readVLong(); // the start pointer of the current level skipPointer[i] = skipStream[0].getFilePointer(); if (toBuffer > 0) { // buffer this level skipStream[i] = new SkipBuffer(skipStream[0], (int) length); toBuffer--; } else { // clone this stream, it is already at the start of the current level skipStream[i] = skipStream[0].clone(); if (inputIsBuffered && length < BufferedIndexInput.BUFFER_SIZE) { ((BufferedIndexInput) skipStream[i]).setBufferSize((int) length); } // move base stream beyond the current level skipStream[0].seek(skipStream[0].getFilePointer() + length); } } // use base stream for the lowest level skipPointer[0] = skipStream[0].getFilePointer(); }
synchronized public IndexInput openInput(String name) throws IOException { return openInput(name, BufferedIndexInput.BUFFER_SIZE); }