public override Int64sRef Next(int count)
        {
            Debug.Assert(nextValues.Length >= 0);
            Debug.Assert(count > 0);
            Debug.Assert(nextValues.Offset + nextValues.Length <= nextValues.Int64s.Length);

            nextValues.Offset += nextValues.Length;

            int remaining = m_valueCount - position - 1;

            if (remaining <= 0)
            {
                throw new System.IO.EndOfStreamException();
            }
            count = Math.Min(remaining, count);

            if (nextValues.Offset == nextValues.Int64s.Length)
            {
                long remainingBlocks = format.ByteCount(packedIntsVersion, remaining, m_bitsPerValue);
                int  blocksToRead    = (int)Math.Min(remainingBlocks, nextBlocks.Length);
                m_in.ReadBytes(nextBlocks, 0, blocksToRead);
                if (blocksToRead < nextBlocks.Length)
                {
                    Arrays.Fill(nextBlocks, blocksToRead, nextBlocks.Length, (byte)0);
                }

                bulkOperation.Decode(nextBlocks, 0, nextValues.Int64s, 0, iterations);
                nextValues.Offset = 0;
            }

            nextValues.Length = Math.Min(nextValues.Int64s.Length - nextValues.Offset, count);
            position         += nextValues.Length;
            return(nextValues);
        }
Exemple #2
0
        public override LongsRef Next(int count)
        {
            Debug.Assert(NextValues.Length >= 0);
            Debug.Assert(count > 0);
            Debug.Assert(NextValues.Offset + NextValues.Length <= NextValues.Longs.Length);

            NextValues.Offset += NextValues.Length;

            int remaining = valueCount - Position - 1;

            if (remaining <= 0)
            {
                throw new System.IO.EndOfStreamException();
            }
            count = Math.Min(remaining, count);

            if (NextValues.Offset == NextValues.Longs.Length)
            {
                long remainingBlocks = Format.ByteCount(PackedIntsVersion, remaining, bitsPerValue);
                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_Renamed);
                NextValues.Offset = 0;
            }

            NextValues.Length = Math.Min(NextValues.Longs.Length - NextValues.Offset, count);
            Position         += NextValues.Length;
            return(NextValues);
        }