コード例 #1
0
        internal RowSetMetadata(BEBinaryReader reader)
        {
            if (reader == null)
            {
                //Allow to be created for unit tests
                return;
            }
            var coldat = new List<ColumnDesc>();
            var flags = (RowSetMetadataFlags) reader.ReadInt32();
            int numberOfcolumns = reader.ReadInt32();

            _rawColumns = new ColumnDesc[numberOfcolumns];
            string gKsname = null;
            string gTablename = null;

            if ((flags & RowSetMetadataFlags.HasMorePages) == RowSetMetadataFlags.HasMorePages)
                PagingState = reader.ReadBytes();
            else
                PagingState = null;

            if ((flags & RowSetMetadataFlags.NoMetadata) != RowSetMetadataFlags.NoMetadata)
            {
                if ((flags & RowSetMetadataFlags.GlobalTablesSpec) == RowSetMetadataFlags.GlobalTablesSpec)
                {
                    gKsname = reader.ReadString();
                    gTablename = reader.ReadString();
                }

                for (int 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);
                }
                _rawColumns = coldat.ToArray();

                _columns = new CqlColumn[_rawColumns.Length];
                ColumnIndexes = new Dictionary<string, int>();
                for (int i = 0; i < _rawColumns.Length; i++)
                {
                    _columns[i] = new CqlColumn
                    {
                        Name = _rawColumns[i].Name,
                        Keyspace = _rawColumns[i].Keyspace,
                        Table = _rawColumns[i].Table,
                        Type = TypeCodec.GetDefaultTypeFromCqlType(
                            _rawColumns[i].TypeCode,
                            _rawColumns[i].TypeInfo),
                        TypeCode = _rawColumns[i].TypeCode,
                        TypeInfo = _rawColumns[i].TypeInfo,
                        Index = i
                    };
                    //TODO: what with full long column names?
                    if (!ColumnIndexes.ContainsKey(_rawColumns[i].Name))
                        ColumnIndexes.Add(_rawColumns[i].Name, i);
                }
            }
        }
コード例 #2
0
        internal RowSetMetadata(BEBinaryReader 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 = TypeCodec.GetDefaultTypeFromCqlType(
                        rawColumns[i].TypeCode,
                        rawColumns[i].TypeInfo),
                    TypeCode = rawColumns[i].TypeCode,
                    TypeInfo = rawColumns[i].TypeInfo,
                    Index = i
                };

                ColumnIndexes[rawColumns[i].Name] = i;
            }
        }
コード例 #3
0
        internal RowSetMetadata(BEBinaryReader reader)
        {
            var coldat          = new List <ColumnDesc>();
            var flags           = (RowSetMetadataFlags)reader.ReadInt32();
            int numberOfcolumns = reader.ReadInt32();

            _rawColumns = new ColumnDesc[numberOfcolumns];
            string gKsname    = null;
            string gTablename = null;

            if ((flags & RowSetMetadataFlags.HasMorePages) == RowSetMetadataFlags.HasMorePages)
            {
                PagingState = reader.ReadBytes();
            }
            else
            {
                PagingState = null;
            }

            if ((flags & RowSetMetadataFlags.NoMetadata) != RowSetMetadataFlags.NoMetadata)
            {
                if ((flags & RowSetMetadataFlags.GlobalTablesSpec) == RowSetMetadataFlags.GlobalTablesSpec)
                {
                    gKsname    = reader.ReadString();
                    gTablename = reader.ReadString();
                }

                for (int 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);
                }
                _rawColumns = coldat.ToArray();

                _columns      = new CqlColumn[_rawColumns.Length];
                ColumnIndexes = new Dictionary <string, int>();
                for (int i = 0; i < _rawColumns.Length; i++)
                {
                    _columns[i] = new CqlColumn
                    {
                        Name     = _rawColumns[i].Name,
                        Keyspace = _rawColumns[i].Keyspace,
                        Table    = _rawColumns[i].Table,
                        Type     = TypeCodec.GetDefaultTypeFromCqlType(
                            _rawColumns[i].TypeCode,
                            _rawColumns[i].TypeInfo),
                        TypeCode = _rawColumns[i].TypeCode,
                        TypeInfo = _rawColumns[i].TypeInfo,
                        Index    = i
                    };
                    //TODO: what with full long column names?
                    if (!ColumnIndexes.ContainsKey(_rawColumns[i].Name))
                    {
                        ColumnIndexes.Add(_rawColumns[i].Name, i);
                    }
                }
            }
        }
コード例 #4
0
        internal RowSetMetadata(BEBinaryReader 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     = TypeCodec.GetDefaultTypeFromCqlType(
                        rawColumns[i].TypeCode,
                        rawColumns[i].TypeInfo),
                    TypeCode = rawColumns[i].TypeCode,
                    TypeInfo = rawColumns[i].TypeInfo,
                    Index    = i
                };

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