static PForDeltaDocIdSet()
        {
            SINGLE_ZERO_BUFFER.Add(0);
            SINGLE_ZERO_BUFFER.Freeze();
            int maxByteBLockCount = 0;

            for (int i = 1; i < ITERATIONS.Length; ++i)
            {
                DECODERS[i] = PackedInts.GetDecoder(PackedInts.Format.PACKED, PackedInts.VERSION_CURRENT, i);
                Debug.Assert(BLOCK_SIZE % DECODERS[i].ByteValueCount() == 0);
                ITERATIONS[i]        = BLOCK_SIZE / DECODERS[i].ByteValueCount();
                BYTE_BLOCK_COUNTS[i] = ITERATIONS[i] * DECODERS[i].ByteBlockCount();
                maxByteBLockCount    = Math.Max(maxByteBLockCount, DECODERS[i].ByteBlockCount());
            }
            MAX_BYTE_BLOCK_COUNT = maxByteBLockCount;
        }
        private void Refill()
        {
            int  token        = @in.ReadByte() & 0xFF;
            bool minEquals0   = (token & AbstractBlockPackedWriter.MIN_VALUE_EQUALS_0) != 0;
            int  bitsPerValue = (int)((uint)token >> AbstractBlockPackedWriter.BPV_SHIFT);

            if (bitsPerValue > 64)
            {
                throw new System.IO.IOException("Corrupted");
            }
            long minValue = minEquals0 ? 0L : ZigZagDecode(1L + ReadVLong(@in));

            Debug.Assert(minEquals0 || minValue != 0);

            if (bitsPerValue == 0)
            {
                Arrays.Fill(Values, minValue);
            }
            else
            {
                PackedInts.Decoder decoder = PackedInts.GetDecoder(PackedInts.Format.PACKED, PackedIntsVersion, bitsPerValue);
                int iterations             = BlockSize / decoder.ByteValueCount();
                int blocksSize             = iterations * decoder.ByteBlockCount();
                if (Blocks == null || Blocks.Length < blocksSize)
                {
                    Blocks = new sbyte[blocksSize];
                }

                int valueCount  = (int)Math.Min(this.ValueCount - Ord_Renamed, BlockSize);
                int blocksCount = (int)PackedInts.Format.PACKED.ByteCount(PackedIntsVersion, valueCount, bitsPerValue);
                @in.ReadBytes(Blocks, 0, blocksCount);

                decoder.Decode(Blocks, 0, Values, 0, iterations);

                if (minValue != 0)
                {
                    for (int i = 0; i < valueCount; ++i)
                    {
                        Values[i] += minValue;
                    }
                }
            }
            Off = 0;
        }
Exemple #3
0
        /// <summary>
        /// Create a new <seealso cref="ForUtil"/> instance and save state into <code>out</code>.
        /// </summary>
        public ForUtil(float acceptableOverheadRatio, DataOutput @out)
        {
            @out.WriteVInt(PackedInts.VERSION_CURRENT);
            EncodedSizes = new int[33];
            Encoders     = new PackedInts.Encoder[33];
            Decoders     = new PackedInts.Decoder[33];
            Iterations   = new int[33];

            for (int bpv = 1; bpv <= 32; ++bpv)
            {
                PackedInts.FormatAndBits formatAndBits = PackedInts.FastestFormatAndBits(Lucene41PostingsFormat.BLOCK_SIZE, bpv, acceptableOverheadRatio);
                Debug.Assert(formatAndBits.format.IsSupported(formatAndBits.bitsPerValue));
                Debug.Assert(formatAndBits.bitsPerValue <= 32);
                EncodedSizes[bpv] = EncodedSize(formatAndBits.format, PackedInts.VERSION_CURRENT, formatAndBits.bitsPerValue);
                Encoders[bpv]     = PackedInts.GetEncoder(formatAndBits.format, PackedInts.VERSION_CURRENT, formatAndBits.bitsPerValue);
                Decoders[bpv]     = PackedInts.GetDecoder(formatAndBits.format, PackedInts.VERSION_CURRENT, formatAndBits.bitsPerValue);
                Iterations[bpv]   = ComputeIterations(Decoders[bpv]);

                @out.WriteVInt(formatAndBits.format.id << 5 | (formatAndBits.bitsPerValue - 1));
            }
        }
Exemple #4
0
        static ForUtil()
        {
            int maxDataSize = 0;

            for (int version = PackedInts.VERSION_START; version <= PackedInts.VERSION_CURRENT; version++)
            {
                foreach (PackedInts.Format format in PackedInts.Format.Values() /* Enum.GetValues(typeof(PackedInts.Format))*/)
                {
                    for (int bpv = 1; bpv <= 32; ++bpv)
                    {
                        if (!format.IsSupported(bpv))
                        {
                            continue;
                        }
                        PackedInts.Decoder decoder = PackedInts.GetDecoder(format, version, bpv);
                        int iterations             = ComputeIterations(decoder);
                        maxDataSize = Math.Max(maxDataSize, iterations * decoder.ByteValueCount());
                    }
                }
            }
            MAX_DATA_SIZE = maxDataSize;
        }
Exemple #5
0
        /// <summary>
        /// Restore a <seealso cref="ForUtil"/> from a <seealso cref="DataInput"/>.
        /// </summary>
        public ForUtil(DataInput @in)
        {
            int packedIntsVersion = @in.ReadVInt();

            PackedInts.CheckVersion(packedIntsVersion);
            EncodedSizes = new int[33];
            Encoders     = new PackedInts.Encoder[33];
            Decoders     = new PackedInts.Decoder[33];
            Iterations   = new int[33];

            for (int bpv = 1; bpv <= 32; ++bpv)
            {
                var code         = @in.ReadVInt();
                var formatId     = (int)((uint)code >> 5);
                var bitsPerValue = (code & 31) + 1;

                PackedInts.Format format = PackedInts.Format.ById(formatId);
                Debug.Assert(format.IsSupported(bitsPerValue));
                EncodedSizes[bpv] = EncodedSize(format, packedIntsVersion, bitsPerValue);
                Encoders[bpv]     = PackedInts.GetEncoder(format, packedIntsVersion, bitsPerValue);
                Decoders[bpv]     = PackedInts.GetDecoder(format, packedIntsVersion, bitsPerValue);
                Iterations[bpv]   = ComputeIterations(Decoders[bpv]);
            }
        }