internal OutputRows(FrameReader reader, Guid?traceId)
 {
     _metadata  = new RowSetMetadata(reader);
     _rowLength = reader.ReadInt32();
     TraceId    = traceId;
     RowSet     = new RowSet();
     ProcessRows(RowSet, reader);
 }
        internal virtual Row ProcessRowItem(FrameReader reader)
        {
            var rowValues = new object[_metadata.Columns.Length];

            for (var i = 0; i < _metadata.Columns.Length; i++)
            {
                var c      = _metadata.Columns[i];
                var length = reader.ReadInt32();
                if (length < 0)
                {
                    rowValues[i] = null;
                    continue;
                }
                var buffer = GetBuffer(length, c.TypeCode);
                rowValues[i] = reader.ReadFromBytes(buffer, 0, length, c.TypeCode, c.TypeInfo);
            }

            return(new Row(rowValues, _metadata.Columns, _metadata.ColumnIndexes));
        }
        internal RowSetMetadata(FrameReader reader, bool parsePartitionKeys = false)
        {
            if (reader == null)
            {
                //Allow to be created for unit tests
                return;
            }
            var flags        = (RowSetMetadataFlags)reader.ReadInt32();
            var columnLength = reader.ReadInt32();

            if (parsePartitionKeys)
            {
                PartitionKeys = new int[reader.ReadInt32()];
                for (var i = 0; i < PartitionKeys.Length; i++)
                {
                    PartitionKeys[i] = reader.ReadInt16();
                }
            }

            string gKsname    = null;
            string gTablename = null;

            if ((flags & RowSetMetadataFlags.HasMorePages) == RowSetMetadataFlags.HasMorePages)
            {
                PagingState = reader.ReadBytes();
            }
            if ((flags & RowSetMetadataFlags.NoMetadata) == RowSetMetadataFlags.NoMetadata)
            {
                return;
            }
            if ((flags & RowSetMetadataFlags.GlobalTablesSpec) == RowSetMetadataFlags.GlobalTablesSpec)
            {
                gKsname    = reader.ReadString();
                gTablename = reader.ReadString();
            }

            Columns       = new CqlColumn[columnLength];
            ColumnIndexes = new Dictionary <string, int>(columnLength);
            for (var i = 0; i < columnLength; i++)
            {
                var col = new CqlColumn {
                    Index = i
                };
                if ((flags & RowSetMetadataFlags.GlobalTablesSpec) == 0)
                {
                    col.Keyspace = reader.ReadString();
                    col.Table    = reader.ReadString();
                }
                else
                {
                    col.Keyspace = gKsname;
                    col.Table    = gTablename;
                }
                col.Name                = reader.ReadString();
                col.TypeCode            = (ColumnTypeCode)reader.ReadUInt16();
                col.TypeInfo            = GetColumnInfo(reader, col.TypeCode);
                col.Type                = reader.Serializer.GetClrType(col.TypeCode, col.TypeInfo);
                Columns[i]              = col;
                ColumnIndexes[col.Name] = i;
            }
            Keyspace = gKsname ?? (columnLength > 0 ? Columns[0].Keyspace : null);
        }