示例#1
0
        public OffsetResponse(byte[] data)
        {
            var dataOffset = BufferReader.Read(data, 0, out correlationId);

            int numTopics;

            dataOffset = BufferReader.Read(data, dataOffset, out numTopics);

            for (int topicIndex = 0; topicIndex < numTopics; topicIndex++)
            {
                String topicName;
                dataOffset = BufferReader.Read(data, dataOffset, out topicName);

                int partitionCount;
                dataOffset = BufferReader.Read(data, dataOffset, out partitionCount);
                var offsetPartitionList = new List <OffsetPartition>(partitionCount);

                for (var i = 0; i < partitionCount; i++)
                {
                    int partitionId;
                    dataOffset = BufferReader.Read(data, dataOffset, out partitionId);

                    short errorCode;
                    dataOffset = BufferReader.Read(data, dataOffset, out errorCode);

                    int offsetCount;
                    dataOffset = BufferReader.Read(data, dataOffset, out offsetCount);
                    var partition = new OffsetPartition(errorCode, partitionId);
                    for (var offsetIndex = 0; offsetIndex < offsetCount; offsetIndex++)
                    {
                        long offset;
                        dataOffset = BufferReader.Read(data, dataOffset, out offset);
                        partition.Add(offset);
                    }
                    offsetPartitionList.Add(partition);
                }
                offsetPartitions.Add(topicName, offsetPartitionList);
            }
        }
示例#2
0
        public OffsetResponse(byte[] data)
        {
            var dataOffset = BufferReader.Read(data, 0, out correlationId);

            int numTopics;
            dataOffset = BufferReader.Read(data, dataOffset, out numTopics);

            for (int topicIndex = 0; topicIndex < numTopics; topicIndex++)
            {
                String topicName;
                dataOffset = BufferReader.Read(data, dataOffset, out topicName);

                int partitionCount;
                dataOffset = BufferReader.Read(data, dataOffset, out partitionCount);
                var offsetPartitionList = new List<OffsetPartition>(partitionCount);

                for (var i = 0; i < partitionCount; i++)
                {
                    int partitionId;
                    dataOffset = BufferReader.Read(data, dataOffset, out partitionId);

                    short errorCode;
                    dataOffset = BufferReader.Read(data, dataOffset, out errorCode);

                    int offsetCount;
                    dataOffset = BufferReader.Read(data, dataOffset, out offsetCount);
                    var partition = new OffsetPartition(errorCode, partitionId);
                    for (var offsetIndex = 0; offsetIndex < offsetCount; offsetIndex++)
                    {
                        long offset;
                        dataOffset = BufferReader.Read(data, dataOffset, out offset);
                        partition.Add(offset);
                    }
                    offsetPartitionList.Add(partition);
                }
                offsetPartitions.Add(topicName, offsetPartitionList);
            }
        }