Пример #1
0
        /// <summary>
        /// Read <param name="blockLength" /> bytes, starting from  <param name="offset" /> byte from 
        /// specified <param name="topic"/> and <param name="partition" />
        /// </summary>
        public MessagesBlock ReadMessagesBlock(Int32 offset, Int32 blockLength)
        {
            if (_readStream == null)
            {
                _readStream = File.Open(_segmentFilePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
            }

            _readStream.Seek(offset, SeekOrigin.Begin);

            var block = new MessagesBlock();
            block.Data = new byte[blockLength];
            block.Length = _readStream.Read(block.Data, 0, blockLength);
            return block;
        }