/** Read between <tt>1</tt> and <code>count</code> values. */ public LongsRef next(int count) throws IOException { assert count > 0; if (ord == valueCount) { throw new EOFException(); } if (off == blockSize) { refill(); } count = Math.min(count, blockSize - off); count = (int) Math.min(count, valueCount - ord); valuesRef.offset = off; valuesRef.length = count; off += count; ord += count; return valuesRef; }
/** Sole constructor. * @param blockSize the number of values of a block, must be equal to the * block size of the {@link BlockPackedWriter} which has * been used to write the stream */ public BlockPackedReaderIterator(DataInput in, int packedIntsVersion, int blockSize, long valueCount) { checkBlockSize(blockSize, MIN_BLOCK_SIZE, MAX_BLOCK_SIZE); this.packedIntsVersion = packedIntsVersion; this.blockSize = blockSize; this.values = new long[blockSize]; this.valuesRef = new LongsRef(this.values, 0, 0); reset(in, valueCount); }
@Override public LongsRef next(int count) throws IOException { assert nextValues.length >= 0; assert count > 0; assert nextValues.offset + nextValues.length <= nextValues.longs.length; nextValues.offset += nextValues.length; final int remaining = valueCount - position - 1; if (remaining <= 0) { throw new EOFException(); } count = Math.min(remaining, count); if (nextValues.offset == nextValues.longs.length) { final long remainingBlocks = format.byteCount(packedIntsVersion, remaining, bitsPerValue); final int blocksToRead = (int) Math.min(remainingBlocks, nextBlocks.length); in.readBytes(nextBlocks, 0, blocksToRead); if (blocksToRead < nextBlocks.length) { Arrays.fill(nextBlocks, blocksToRead, nextBlocks.length, (byte) 0); } bulkOperation.decode(nextBlocks, 0, nextValues.longs, 0, iterations); nextValues.offset = 0; } nextValues.length = Math.min(nextValues.longs.length - nextValues.offset, count); position += nextValues.length; return nextValues; }
public OrdinalsBuilder(long numTerms, int maxDoc, float acceptableOverheadRatio) throws IOException { this.maxDoc = maxDoc; int startBitsPerValue = 8; if (numTerms >= 0) { startBitsPerValue = PackedInts.bitsRequired(numTerms); } ordinals = new OrdinalsStore(maxDoc, startBitsPerValue, acceptableOverheadRatio); spare = new LongsRef(); }
/** Sole constructor. * @param blockSize the number of values of a block, must be equal to the * block size of the {@link BlockPackedWriter} which has * been used to write the stream */ public BlockPackedReaderIterator(DataInput in, int packedIntsVersion, int blockSize, long valueCount) { checkBlockSize(blockSize); this.packedIntsVersion = packedIntsVersion; this.blockSize = blockSize; this.values = new long[blockSize]; this.valuesRef = new LongsRef(this.values, 0, 0); reset(in, valueCount); }
public OrdinalsBuilder(int maxDoc, float acceptableOverheadRatio) throws IOException { this.maxDoc = maxDoc; int startBitsPerValue = 8; ordinals = new OrdinalsStore(maxDoc, startBitsPerValue, acceptableOverheadRatio); spare = new LongsRef(); }
/** * Returns a shared {@link LongsRef} instance for the given doc ID holding all ordinals associated with it. */ public LongsRef docOrds(int docID) { spare.offset = spare.length = 0; ordinals.appendOrdinals(docID, spare); return spare; }
/** Returns at least 1 and at most <code>count</code> next values, * the returned ref MUST NOT be modified */ LongsRef next(int count) throws IOException;