RampUp.Buffers.IndexCalculator.GetIndexInSegment C# (CSharp) Method

GetIndexInSegment() private method

private GetIndexInSegment ( long index ) : int
index long
return int
        public int GetIndexInSegment(long index)
        {
            return (int) (index & _indexInSegmentMask);
        }

Usage Example

示例#1
0
        private int ReadImpl(ref ByteSlice slice)
        {
            if (_position >= _length)
            {
                return(0);
            }

            var alreadyCopied = 0;
            var toCopy        = Math.Min(slice.Count, _length - _position);

            while (toCopy > 0)
            {
                var index          = Calculator.GetSegmentIndex(_position);
                var indexInSegment = Calculator.GetIndexInSegment(_position);

                var segment = FindSegment(index);

                var bytesToRead = Math.Min(segment->Length - indexInSegment, toCopy);
                if (bytesToRead > 0)
                {
                    var segmentBuffer = segment->Buffer;
                    slice.CopyFrom(alreadyCopied, segmentBuffer, indexInSegment, bytesToRead);
                    alreadyCopied += bytesToRead;
                    toCopy        -= bytesToRead;
                    _position     += bytesToRead;
                }
            }

            return(alreadyCopied);
        }
All Usage Examples Of RampUp.Buffers.IndexCalculator::GetIndexInSegment