Esempio n. 1
0
        internal RowSetMetadata(FrameReader reader, bool parsePartitionKeys = false)
        {
            if (reader == null)
            {
                //Allow to be created for unit tests
                return;
            }
            var coldat = new List<ColumnDesc>();
            var flags = (RowSetMetadataFlags) reader.ReadInt32();
            var numberOfcolumns = 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();
            }

            for (var i = 0; i < numberOfcolumns; i++)
            {
                var col = new ColumnDesc();
                if ((flags & RowSetMetadataFlags.GlobalTablesSpec) != RowSetMetadataFlags.GlobalTablesSpec)
                {
                    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);
                coldat.Add(col);
            }
            var rawColumns = coldat.ToArray();

            Columns = new CqlColumn[rawColumns.Length];
            ColumnIndexes = new Dictionary<string, int>();
            for (var i = 0; i < rawColumns.Length; i++)
            {
                Columns[i] = new CqlColumn
                {
                    Name = rawColumns[i].Name,
                    Keyspace = rawColumns[i].Keyspace,
                    Table = rawColumns[i].Table,
                    Type = reader.Serializer.GetClrType(
                        rawColumns[i].TypeCode,
                        rawColumns[i].TypeInfo),
                    TypeCode = rawColumns[i].TypeCode,
                    TypeInfo = rawColumns[i].TypeInfo,
                    Index = i
                };

                ColumnIndexes[rawColumns[i].Name] = i;
            }
        }
Esempio n. 2
0
        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);
        }
        internal RowSetMetadata(FrameReader reader, bool parsePartitionKeys = false)
        {
            if (reader == null)
            {
                //Allow to be created for unit tests
                return;
            }
            var coldat          = new List <ColumnDesc>();
            var flags           = (RowSetMetadataFlags)reader.ReadInt32();
            var numberOfcolumns = 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();
            }

            for (var i = 0; i < numberOfcolumns; i++)
            {
                var col = new ColumnDesc();
                if ((flags & RowSetMetadataFlags.GlobalTablesSpec) != RowSetMetadataFlags.GlobalTablesSpec)
                {
                    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);
                coldat.Add(col);
            }
            var rawColumns = coldat.ToArray();

            Columns       = new CqlColumn[rawColumns.Length];
            ColumnIndexes = new Dictionary <string, int>();
            for (var i = 0; i < rawColumns.Length; i++)
            {
                Columns[i] = new CqlColumn
                {
                    Name     = rawColumns[i].Name,
                    Keyspace = rawColumns[i].Keyspace,
                    Table    = rawColumns[i].Table,
                    Type     = reader.Serializer.GetClrType(
                        rawColumns[i].TypeCode,
                        rawColumns[i].TypeInfo),
                    TypeCode = rawColumns[i].TypeCode,
                    TypeInfo = rawColumns[i].TypeInfo,
                    Index    = i
                };

                ColumnIndexes[rawColumns[i].Name] = i;
            }
        }