Ejemplo n.º 1
0
        public void FetchFrom(KafkaReader reader)
        {
            if (_messageSetSize == 0)
            {
                Items = new MessageSetDetail[0];
                return;
            }
            var previousPosition = reader.PositionProceeded;
            var items            = new List <MessageSetDetail>(32);

            while (reader.PositionProceeded - previousPosition < _messageSetSize)
            {
                //var item = new MessageSetDetail();
                //item.FetchFrom(reader);
                var maxBytes = _messageSetSize - (Int32)(reader.PositionProceeded - previousPosition);
                MessageSetDetail item;
                if (!MessageSetDetail.TryFetchFrom(reader, maxBytes, out item))
                {
                    break;
                }
                items.Add(item);
            }
            var restBytes = _messageSetSize - (Int32)(reader.PositionProceeded - previousPosition);

            if (restBytes > 0)
            {
                reader.DropBytes(restBytes);
            }
            Items = Decompress(items).ToArray();
        }