/// <inheritdoc/> public byte ReadByte(long index) { streamsLock.EnterReadLock(); try { IDataStreamHelpers.ReadByteArgsCheck(this, index); int i = 0; while (index >= 0) { var stream = streams[i++]; if (index >= stream.Length) { index -= stream.Length; } else { return(stream.ReadByte(index)); } } // unreachable code throw new ArgumentOutOfRangeException(); } finally { streamsLock.ExitReadLock(); } }
/// <inheritdoc /> /// <remarks>Assumes nearly sequential access.</remarks> public byte ReadByte(long index) { IDataStreamHelpers.ReadByteArgsCheck(this, index); byte ret; lock (cacheLock) { if (!cache.TryReadByte(index, out ret)) { ByteCache.FillCache callback = delegate(byte[] buffer, out long cacheStart, out int cacheLength) { using (var reader = log.ReaderPool.Get()) { // the file is more likely to be read from the beginning to the end cacheStart = Math.Max(0, index - 32); cacheLength = (int)Math.Min(buffer.Length, Math.Min(int.MaxValue, length - cacheStart)); reader.ReadFileDataToBuffer(hint, buffer, cacheStart, cacheLength, 0); ret = buffer[index - cacheStart]; } }; cache.Cache(callback); } } return(ret); }
/// <inheritdoc/> public byte ReadByte(long index) { IDataStreamHelpers.ReadByteArgsCheck(this, index); lock (streamLock) { stream.Position = index; return((byte)stream.ReadByte()); } }
/// <inheritdoc/> public byte ReadByte(long index) { IDataStreamHelpers.ReadByteArgsCheck(this, index); byte ret; lock (dataLock) { if (cache.TryReadByte(index, out ret)) { return(ret); } seekToPosition(index); cache.TryReadByte(index, out ret); return(ret); } }
/// <inheritdoc/> public byte ReadByte(long index) { IDataStreamHelpers.ReadByteArgsCheck(this, index); return(stream.ReadByte(offset + index)); }
/// <inheritdoc/> public byte ReadByte(long index) { IDataStreamHelpers.ReadByteArgsCheck(this, index); return arr[index]; }