/// <summary> /// Sole constructor. </summary> /// <param name="blockSize"> The number of values of a block, must be equal to the /// block size of the <see cref="BlockPackedWriter"/> which has /// been used to write the stream. </param> public BlockPackedReaderIterator(DataInput @in, int packedIntsVersion, int blockSize, long valueCount) { PackedInt32s.CheckBlockSize(blockSize, AbstractBlockPackedWriter.MIN_BLOCK_SIZE, AbstractBlockPackedWriter.MAX_BLOCK_SIZE); this.packedIntsVersion = packedIntsVersion; this.blockSize = blockSize; this.values = new long[blockSize]; this.valuesRef = new Int64sRef(this.values, 0, 0); Reset(@in, valueCount); }
internal AbstractPagedMutable(int bitsPerValue, long size, int pageSize) { this.bitsPerValue = bitsPerValue; this.size = size; pageShift = PackedInt32s.CheckBlockSize(pageSize, MIN_BLOCK_SIZE, MAX_BLOCK_SIZE); pageMask = pageSize - 1; int numPages = PackedInt32s.NumBlocks(size, pageSize); subMutables = new PackedInt32s.Mutable[numPages]; }
internal AbstractAppendingInt64Buffer(int initialBlockCount, int pageSize, float acceptableOverheadRatio) { values = new PackedInt32s.Reader[initialBlockCount]; pending = new long[pageSize]; pageShift = PackedInt32s.CheckBlockSize(pageSize, MIN_PAGE_SIZE, MAX_PAGE_SIZE); pageMask = pageSize - 1; valuesOff = 0; pendingOff = 0; this.acceptableOverheadRatio = acceptableOverheadRatio; }
/// <summary> /// Sole constructor. </summary> public BlockPackedReader(IndexInput @in, int packedIntsVersion, int blockSize, long valueCount, bool direct) { this.valueCount = valueCount; blockShift = PackedInt32s.CheckBlockSize(blockSize, AbstractBlockPackedWriter.MIN_BLOCK_SIZE, AbstractBlockPackedWriter.MAX_BLOCK_SIZE); blockMask = blockSize - 1; int numBlocks = PackedInt32s.NumBlocks(valueCount, blockSize); long[] minValues = null; subReaders = new PackedInt32s.Reader[numBlocks]; for (int i = 0; i < numBlocks; ++i) { int token = @in.ReadByte() & 0xFF; int bitsPerValue = token.TripleShift(AbstractBlockPackedWriter.BPV_SHIFT); if (bitsPerValue > 64) { throw new Exception("Corrupted"); } if ((token & AbstractBlockPackedWriter.MIN_VALUE_EQUALS_0) == 0) { if (minValues == null) { minValues = new long[numBlocks]; } minValues[i] = BlockPackedReaderIterator.ZigZagDecode(1L + BlockPackedReaderIterator.ReadVInt64(@in)); } if (bitsPerValue == 0) { subReaders[i] = new PackedInt32s.NullReader(blockSize); } else { int size = (int)Math.Min(blockSize, valueCount - (long)i * blockSize); if (direct) { long pointer = @in.GetFilePointer(); subReaders[i] = PackedInt32s.GetDirectReaderNoHeader(@in, PackedInt32s.Format.PACKED, packedIntsVersion, size, bitsPerValue); @in.Seek(pointer + PackedInt32s.Format.PACKED.ByteCount(packedIntsVersion, size, bitsPerValue)); } else { subReaders[i] = PackedInt32s.GetReaderNoHeader(@in, PackedInt32s.Format.PACKED, packedIntsVersion, size, bitsPerValue); } } } this.minValues = minValues; }
/// <summary> /// Sole constructor. </summary> public MonotonicBlockPackedReader(IndexInput @in, int packedIntsVersion, int blockSize, long valueCount, bool direct) { this.valueCount = valueCount; blockShift = PackedInt32s.CheckBlockSize(blockSize, AbstractBlockPackedWriter.MIN_BLOCK_SIZE, AbstractBlockPackedWriter.MAX_BLOCK_SIZE); blockMask = blockSize - 1; int numBlocks = PackedInt32s.NumBlocks(valueCount, blockSize); minValues = new long[numBlocks]; averages = new float[numBlocks]; subReaders = new PackedInt32s.Reader[numBlocks]; for (int i = 0; i < numBlocks; ++i) { minValues[i] = @in.ReadVInt64(); averages[i] = J2N.BitConversion.Int32BitsToSingle(@in.ReadInt32()); int bitsPerValue = @in.ReadVInt32(); if (bitsPerValue > 64) { throw new Exception("Corrupted"); } if (bitsPerValue == 0) { subReaders[i] = new PackedInt32s.NullReader(blockSize); } else { int size = (int)Math.Min(blockSize, valueCount - (long)i * blockSize); if (direct) { long pointer = @in.GetFilePointer(); subReaders[i] = PackedInt32s.GetDirectReaderNoHeader(@in, PackedInt32s.Format.PACKED, packedIntsVersion, size, bitsPerValue); @in.Seek(pointer + PackedInt32s.Format.PACKED.ByteCount(packedIntsVersion, size, bitsPerValue)); } else { subReaders[i] = PackedInt32s.GetReaderNoHeader(@in, PackedInt32s.Format.PACKED, packedIntsVersion, size, bitsPerValue); } } } }
/// <summary> /// Sole constructor. </summary> /// <param name="blockSize"> the number of values of a single block, must be a multiple of <c>64</c>. </param> protected AbstractBlockPackedWriter(DataOutput @out, int blockSize) // LUCENENET specific - marked protected instead of public { PackedInt32s.CheckBlockSize(blockSize, MIN_BLOCK_SIZE, MAX_BLOCK_SIZE); Reset(@out); m_values = new long[blockSize]; }
/// <summary> /// Sole constructor. </summary> /// <param name="blockSize"> the number of values of a single block, must be a multiple of <c>64</c>. </param> public AbstractBlockPackedWriter(DataOutput @out, int blockSize) { PackedInt32s.CheckBlockSize(blockSize, MIN_BLOCK_SIZE, MAX_BLOCK_SIZE); Reset(@out); m_values = new long[blockSize]; }