internal OutputSchemaChange(BEBinaryReader reader, Guid? traceId)
 {
     _traceId = traceId;
     Change = reader.ReadString();
     Keyspace = reader.ReadString();
     Table = reader.ReadString();
 }
        internal TableMetadata(BEBinaryReader reader)
        {
            List<TableColumn> coldat = new List<TableColumn>();
            var flags = (FlagBits)reader.ReadInt32();
            var numberOfcolumns = reader.ReadInt32();
            this.TableColumns = new TableColumn[numberOfcolumns];
            string gKsname = null;
            string gTablename = null;

            if ((flags & FlagBits.GlobalTablesSpec) == FlagBits.GlobalTablesSpec)
            {
                gKsname = reader.ReadString();
                gTablename = reader.ReadString();
            }
            for (int i = 0; i < numberOfcolumns; i++)
            {
                var col = new TableColumn();
                if ((flags & FlagBits.GlobalTablesSpec) != FlagBits.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);
            }
            TableColumns = coldat.ToArray();
        }
 internal OutputSchemaChange(BEBinaryReader reader, Guid? traceID)
 {
     _traceID = traceID;
     this.Change = reader.ReadString();
     this.Keyspace= reader.ReadString();
     this.Table = reader.ReadString();
 }
Esempio n. 4
0
 internal void Load(CassandraErrorType code, string message, BEBinaryReader cb)
 {
     _info.ConsistencyLevel = (ConsistencyLevel)cb.ReadInt16();
     _info.Received         = cb.ReadInt32();
     _info.BlockFor         = cb.ReadInt32();
     _info.WriteType        = cb.ReadString();
 }
 internal OutputSchemaChange(BEBinaryReader reader, Guid?traceId)
 {
     _traceId = traceId;
     Change   = reader.ReadString();
     Keyspace = reader.ReadString();
     Table    = reader.ReadString();
 }
Esempio n. 6
0
 internal OutputRows(byte protocolVersion, BEBinaryReader reader, bool buffered, Guid? traceId)
 {
     _protocolVersion = protocolVersion;
     _metadata = new RowSetMetadata(reader);
     RowLength = reader.ReadInt32();
     _traceId = traceId;
     RowSet = new RowSet();
     ProcessRows(RowSet, reader);
 }
Esempio n. 7
0
 internal OutputRows(BEBinaryReader reader, bool buffered, Guid?traceID)
 {
     this._buffered = buffered;
     this._reader   = reader;
     Metadata       = new RowSetMetadata(reader);
     Rows           = reader.ReadInt32();
     _disposedEvent = new ManualResetEvent(buffered);
     _traceID       = traceID;
 }
Esempio n. 8
0
 internal OutputRows(byte protocolVersion, BEBinaryReader reader, bool buffered, Guid?traceId)
 {
     _protocolVersion = protocolVersion;
     _metadata        = new RowSetMetadata(reader);
     RowLength        = reader.ReadInt32();
     _traceId         = traceId;
     RowSet           = new RowSet();
     ProcessRows(RowSet, reader);
 }
Esempio n. 9
0
        internal RowSetMetadata(BEBinaryReader reader)
        {
            var coldat          = new List <ColumnDesc>();
            var flags           = (FlagBits)reader.ReadInt32();
            var numberOfcolumns = reader.ReadInt32();

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

            if ((flags & FlagBits.GlobalTablesSpec) == FlagBits.GlobalTablesSpec)
            {
                gKsname    = reader.ReadString();
                gTablename = reader.ReadString();
            }
            for (int i = 0; i < numberOfcolumns; i++)
            {
                var col = new ColumnDesc();
                if ((flags & FlagBits.GlobalTablesSpec) != FlagBits.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];
            _columnIdxes = 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     = TypeInterpreter.GetDefaultTypeFromCqlType(
                        _rawColumns[i].TypeCode,
                        _rawColumns[i].TypeInfo),
                    TypeCode = _rawColumns[i].TypeCode,
                    TypeInfo = _rawColumns[i].TypeInfo
                };
                //TODO: what with full long column names?
                if (!_columnIdxes.ContainsKey(_rawColumns[i].Name))
                {
                    _columnIdxes.Add(_rawColumns[i].Name, i);
                }
            }
        }
 protected override void Load(BEBinaryReader reader)
 {
     _exception = new FunctionFailureException(Message)
     {
         Keyspace      = reader.ReadString(),
         Name          = reader.ReadString(),
         ArgumentTypes = reader.ReadStringList()
     };
 }
 protected override void Load(BEBinaryReader reader)
 {
     _exception = new FunctionFailureException(Message)
     {
         Keyspace = reader.ReadString(),
         Name = reader.ReadString(),
         ArgumentTypes = reader.ReadStringList()
     };
 }
Esempio n. 12
0
 internal OutputRows(BEBinaryReader reader, bool buffered, Guid? traceID)
 {
     this._buffered = buffered;
     this._reader = reader;
     Metadata = new RowSetMetadata(reader);
     Rows = reader.ReadInt32();
     _disposedEvent = new ManualResetEvent(buffered);
     _traceID = traceID;
 }
Esempio n. 13
0
 internal AbstractResponse(ResponseFrame frame)
 {
     BEBinaryReader = new BEBinaryReader(frame);
     if ((frame.FrameHeader.Flags & 0x02) == 0x02)
     {
         var buffer = new byte[16];
         BEBinaryReader.Read(buffer, 0, 16);
         TraceID = new Guid(TypeInterpreter.GuidShuffle(buffer));
     }
 }
Esempio n. 14
0
 internal AbstractResponse(ResponseFrame frame)
 {
     BEBinaryReader = new BEBinaryReader(frame);
     if ((frame.FrameHeader.Flags & 0x02) == 0x02)
     {
         var buffer = new byte[16];
         BEBinaryReader.Read(buffer, 0, 16);
         TraceID = new Guid(TypeInterpreter.GuidShuffle(buffer));
     }
 }
Esempio n. 15
0
        internal AbstractResponse(ResponseFrame frame)
        {
            BeBinaryReader = new BEBinaryReader(frame.Body);

            if ((frame.Header.Flags & 0x02) == 0x02)
            {
                var buffer = new byte[16];
                BeBinaryReader.Read(buffer, 0, 16);
                TraceId = new Guid(TypeCodec.GuidShuffle(buffer));
            }
        }
Esempio n. 16
0
 internal OutputOptions(BEBinaryReader reader)
 {
     _options = new Dictionary<string, string[]>();
     int n = reader.ReadUInt16();
     for (int i = 0; i < n; i++)
     {
         var k = reader.ReadString();
         var v = reader.ReadStringList().ToArray();
         _options.Add(k, v);
     }
 }
Esempio n. 17
0
        internal static OutputError CreateOutputError(int code, string message, BEBinaryReader cb)
        {
            var factoryMethod = OutputErrorFactoryMethods[code];
            if (factoryMethod == null)
                throw new DriverInternalError("unknown error" + code);

            OutputError error = factoryMethod();
            error.Message = message;
            error.Load(cb);
            return error;
        }
Esempio n. 18
0
        internal AbstractResponse(ResponseFrame frame)
        {
            BeBinaryReader = new BEBinaryReader(frame.Body);

            if ((frame.Header.Flags & 0x02) == 0x02)
            {
                var buffer = new byte[16];
                BeBinaryReader.Read(buffer, 0, 16);
                TraceId = new Guid(TypeCodec.GuidShuffle(buffer));
            }
        }
Esempio n. 19
0
 internal OutputRows(BEBinaryReader reader, bool buffered, Guid?traceId)
 {
     _buffered = buffered;
     _reader   = reader;
     Metadata  = new RowSetMetadata(reader);
     Rows      = reader.ReadInt32();
     if (!buffered)
     {
         _disposedEvent = new ManualResetEventSlim(buffered);
     }
     _traceId = traceId;
 }
        internal OutputOptions(BEBinaryReader reader)
        {
            _options = new Dictionary <string, string[]>();
            int n = reader.ReadUInt16();

            for (int i = 0; i < n; i++)
            {
                var k = reader.ReadString();
                var v = reader.ReadStringList().ToArray();
                _options.Add(k, v);
            }
        }
Esempio n. 21
0
 /// <summary>
 /// Process rows and sets the paging event handler
 /// </summary>
 internal void ProcessRows(RowSet rs, BEBinaryReader reader)
 {
     if (_metadata != null)
     {
         rs.Columns = _metadata.Columns;
         rs.PagingState = _metadata.PagingState;
     }
     for (var i = 0; i < this.RowLength; i++)
     {
         rs.AddRow(ProcessRowItem(reader));
     }
 }
Esempio n. 22
0
 /// <summary>
 /// Process rows and sets the paging event handler
 /// </summary>
 internal virtual void ProcessRows(RowSet rs, BEBinaryReader reader)
 {
     if (this._metadata != null)
     {
         rs.Columns     = _metadata.Columns;
         rs.PagingState = _metadata.PagingState;
     }
     for (var i = 0; i < this.RowLength; i++)
     {
         rs.AddRow(ProcessRowItem(reader));
     }
 }
Esempio n. 23
0
        internal AbstractResponse(ResponseFrame frame)
        {
            BEBinaryReader = new BEBinaryReader(frame);
            if (frame.FrameHeader.Version != ResponseFrame.ProtocolResponseVersionByte)
                throw new ProtocolErrorException("Invalid protocol version");

            if ((frame.FrameHeader.Flags & 0x02) == 0x02)
            {
                var buffer = new byte[16];
                BEBinaryReader.Read(buffer, 0, 16);
                TraceID = new Guid(TypeInterpreter.GuidShuffle(buffer));
            }
        }
Esempio n. 24
0
        internal static OutputError CreateOutputError(int code, string message, BEBinaryReader cb)
        {
            var factoryMethod = OutputErrorFactoryMethods[code];

            if (factoryMethod == null)
            {
                throw new DriverInternalError("unknown error" + code);
            }
            var error = factoryMethod();

            error.Message = message;
            error.Code    = code;
            error.Load(cb);
            return(error);
        }
Esempio n. 25
0
        internal AbstractResponse(ResponseFrame frame)
        {
            BEBinaryReader = new BEBinaryReader(frame);
            if (frame.FrameHeader.Version != ResponseFrame.ProtocolResponseVersionByte)
            {
                throw new ProtocolErrorException("Invalid protocol version");
            }

            if ((frame.FrameHeader.Flags & 0x02) == 0x02)
            {
                var buffer = new byte[16];
                BEBinaryReader.Read(buffer, 0, 16);
                TraceID = new Guid(TypeInterpreter.GuidShuffle(buffer));
            }
        }
        internal AbstractResponse(ResponseFrame frame)
        {
            if (frame == null) throw new ArgumentNullException("frame");
            if (frame.Body == null) throw new InvalidOperationException("Response body of the received frame was null");

            BeBinaryReader = new BEBinaryReader(frame.Body);

            // If a response frame has the tracing flag set, its body contains a tracing ID.
            // the frame body. 
            if ((frame.Header.Flags & FrameHeader.HeaderFlag.Tracing) != 0)
            {
                var buffer = new byte[16];
                BeBinaryReader.Read(buffer, 0, 16);
                TraceId = new Guid(TypeCodec.GuidShuffle(buffer));
            }
        }
Esempio n. 27
0
        private IColumnInfo GetColumnInfo(BEBinaryReader reader, ColumnTypeCode code)
        {
            ColumnTypeCode innercode;
            ColumnTypeCode vinnercode;

            switch (code)
            {
            case ColumnTypeCode.Custom:
                return(new CustomColumnInfo()
                {
                    CustomTypeName = reader.ReadString()
                });

            case ColumnTypeCode.List:
                innercode = (ColumnTypeCode)reader.ReadUInt16();
                return(new ListColumnInfo()
                {
                    ValueTypeCode = innercode,
                    ValueTypeInfo = GetColumnInfo(reader, innercode)
                });

            case ColumnTypeCode.Map:
                innercode = (ColumnTypeCode)reader.ReadUInt16();
                var kci = GetColumnInfo(reader, innercode);
                vinnercode = (ColumnTypeCode)reader.ReadUInt16();
                var vci = GetColumnInfo(reader, vinnercode);
                return(new MapColumnInfo()
                {
                    KeyTypeCode = innercode,
                    KeyTypeInfo = kci,
                    ValueTypeCode = vinnercode,
                    ValueTypeInfo = vci
                });

            case ColumnTypeCode.Set:
                innercode = (ColumnTypeCode)reader.ReadUInt16();
                return(new SetColumnInfo()
                {
                    KeyTypeCode = innercode,
                    KeyTypeInfo = GetColumnInfo(reader, innercode)
                });

            default:
                return(null);
            }
        }
Esempio n. 28
0
        internal virtual Row ProcessRowItem(BEBinaryReader reader)
        {
            var valuesList = new List<byte[]>();
            for (var i = 0; i < _metadata.Columns.Length; i++ )
            {
                int length = reader.ReadInt32();
                if (length < 0)
                {
                    valuesList.Add(null);
                }
                else
                {
                    var buffer = new byte[length];
                    reader.Read(buffer, 0, length);
                    valuesList.Add(buffer);
                }
            }

            return new Row(_protocolVersion, valuesList.ToArray(), _metadata.Columns, _metadata.ColumnIndexes);
        }
Esempio n. 29
0
        internal virtual Row ProcessRowItem(BEBinaryReader reader)
        {
            var valuesList = new List <byte[]>();

            for (var i = 0; i < _metadata.Columns.Length; i++)
            {
                int length = reader.ReadInt32();
                if (length < 0)
                {
                    valuesList.Add(null);
                }
                else
                {
                    var buffer = new byte[length];
                    reader.Read(buffer, 0, length);
                    valuesList.Add(buffer);
                }
            }

            return(new Row(_protocolVersion, valuesList.ToArray(), _metadata.Columns, _metadata.ColumnIndexes));
        }
Esempio n. 30
0
        internal AbstractResponse(ResponseFrame frame)
        {
            if (frame == null)
            {
                throw new ArgumentNullException("frame");
            }
            if (frame.Body == null)
            {
                throw new InvalidOperationException("Response body of the received frame was null");
            }

            BeBinaryReader = new BEBinaryReader(frame.Body);

            // If a response frame has the tracing flag set, its body contains a tracing ID.
            // the frame body.
            if ((frame.Header.Flags & FrameHeader.HeaderFlag.Tracing) != 0)
            {
                var buffer = new byte[16];
                BeBinaryReader.Read(buffer, 0, 16);
                TraceId = new Guid(TypeCodec.GuidShuffle(buffer));
            }
        }
Esempio n. 31
0
 protected abstract void Load(BEBinaryReader reader);
        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;
            }
        }
Esempio n. 33
0
        internal static OutputError CreateOutputError(CassandraErrorType code, string message, BEBinaryReader cb)
        {
            var tpy = Assembly.GetExecutingAssembly().GetType("Cassandra.Output" + code.ToString());

            if (tpy == null)
            {
                throw new DriverInternalError("unknown error" + code.ToString());
            }
            var cnstr = tpy.GetConstructor(new Type[] { });
            var outp  = (OutputError)cnstr.Invoke(new object[] { });

            tpy.GetField("CassandraErrorType").SetValue(outp, code);
            tpy.GetField("Message").SetValue(outp, message);
            var loadM = tpy.GetMethod("Load", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance, null, new Type[] { typeof(CassandraErrorType), typeof(string), typeof(BEBinaryReader) }, null);

            if (loadM != null)
            {
                loadM.Invoke(outp, new object[] { code, message, cb });
            }
            return(outp);
        }
Esempio n. 34
0
 internal void Load(CassandraErrorType code, string message, BEBinaryReader cb)
 {
     _info.Ks    = cb.ReadString();
     _info.Table = cb.ReadString();
 }
Esempio n. 35
0
 internal void Load(CassandraErrorType code, string message, BEBinaryReader cb)
 {
     _info.ConsistencyLevel = (ConsistencyLevel)cb.ReadInt16();
     _info.Required         = cb.ReadInt32();
     _info.Alive            = cb.ReadInt32();
 }
Esempio n. 36
0
        private IColumnInfo GetColumnInfo(BEBinaryReader reader, ColumnTypeCode code)
        {
            ColumnTypeCode innercode;
            switch (code)
            {
                case ColumnTypeCode.List:
                    innercode = (ColumnTypeCode) reader.ReadUInt16();
                    return new ListColumnInfo
                    {
                        ValueTypeCode = innercode,
                        ValueTypeInfo = GetColumnInfo(reader, innercode)
                    };
                case ColumnTypeCode.Map:
                    innercode = (ColumnTypeCode) reader.ReadUInt16();
                    IColumnInfo kci = GetColumnInfo(reader, innercode);
                    var vinnercode = (ColumnTypeCode) reader.ReadUInt16();
                    IColumnInfo vci = GetColumnInfo(reader, vinnercode);
                    return new MapColumnInfo
                    {
                        KeyTypeCode = innercode,
                        KeyTypeInfo = kci,
                        ValueTypeCode = vinnercode,
                        ValueTypeInfo = vci
                    };
                case ColumnTypeCode.Set:
                    innercode = (ColumnTypeCode) reader.ReadUInt16();
                    return new SetColumnInfo
                    {
                        KeyTypeCode = innercode,
                        KeyTypeInfo = GetColumnInfo(reader, innercode)
                    };
                case ColumnTypeCode.Custom:
                    return new CustomColumnInfo { CustomTypeName = reader.ReadString() };
                case ColumnTypeCode.Udt:
                    var udtInfo = new UdtColumnInfo(reader.ReadString() + "." + reader.ReadString());
                    var fieldLength = reader.ReadInt16();
                    for (var i = 0; i < fieldLength; i++)
                    {
                        var dataType = new ColumnDesc
                        {
                            Name = reader.ReadString(),
                            TypeCode = (ColumnTypeCode) reader.ReadUInt16(),
                        };

                        dataType.TypeInfo = GetColumnInfo(reader, dataType.TypeCode);
                        udtInfo.Fields.Add(dataType);
                    }
                    return udtInfo;
                case ColumnTypeCode.Tuple:
                {
                    var tupleInfo = new TupleColumnInfo();
                    var elementLength = reader.ReadInt16();
                    for (var i = 0; i < elementLength; i++)
                    {
                        var dataType = new ColumnDesc
                        {
                            TypeCode = (ColumnTypeCode) reader.ReadUInt16(),
                        };
                        dataType.TypeInfo = GetColumnInfo(reader, dataType.TypeCode);
                        tupleInfo.Elements.Add(dataType);
                    }
                    return tupleInfo;
                }
                default:
                    return null;
            }
        }
Esempio n. 37
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);
                }
            }
        }
        private IColumnInfo GetColumnInfo(BEBinaryReader reader, ColumnTypeCode code)
        {
            ColumnTypeCode innercode;

            switch (code)
            {
            case ColumnTypeCode.List:
                innercode = (ColumnTypeCode)reader.ReadUInt16();
                return(new ListColumnInfo
                {
                    ValueTypeCode = innercode,
                    ValueTypeInfo = GetColumnInfo(reader, innercode)
                });

            case ColumnTypeCode.Map:
                innercode = (ColumnTypeCode)reader.ReadUInt16();
                IColumnInfo kci        = GetColumnInfo(reader, innercode);
                var         vinnercode = (ColumnTypeCode)reader.ReadUInt16();
                IColumnInfo vci        = GetColumnInfo(reader, vinnercode);
                return(new MapColumnInfo
                {
                    KeyTypeCode = innercode,
                    KeyTypeInfo = kci,
                    ValueTypeCode = vinnercode,
                    ValueTypeInfo = vci
                });

            case ColumnTypeCode.Set:
                innercode = (ColumnTypeCode)reader.ReadUInt16();
                return(new SetColumnInfo
                {
                    KeyTypeCode = innercode,
                    KeyTypeInfo = GetColumnInfo(reader, innercode)
                });

            case ColumnTypeCode.Custom:
                return(new CustomColumnInfo {
                    CustomTypeName = reader.ReadString()
                });

            case ColumnTypeCode.Udt:
                var udtInfo     = new UdtColumnInfo(reader.ReadString() + "." + reader.ReadString());
                var fieldLength = reader.ReadInt16();
                for (var i = 0; i < fieldLength; i++)
                {
                    var dataType = new ColumnDesc
                    {
                        Name     = reader.ReadString(),
                        TypeCode = (ColumnTypeCode)reader.ReadUInt16(),
                    };

                    dataType.TypeInfo = GetColumnInfo(reader, dataType.TypeCode);
                    udtInfo.Fields.Add(dataType);
                }
                return(udtInfo);

            case ColumnTypeCode.Tuple:
            {
                var tupleInfo     = new TupleColumnInfo();
                var elementLength = reader.ReadInt16();
                for (var i = 0; i < elementLength; i++)
                {
                    var dataType = new ColumnDesc
                    {
                        TypeCode = (ColumnTypeCode)reader.ReadUInt16(),
                    };
                    dataType.TypeInfo = GetColumnInfo(reader, dataType.TypeCode);
                    tupleInfo.Elements.Add(dataType);
                }
                return(tupleInfo);
            }

            default:
                return(null);
            }
        }
 private IColumnInfo GetColumnInfo(BEBinaryReader reader, ColumnTypeCode code)
 {
     ColumnTypeCode innercode;
     ColumnTypeCode vinnercode;
     switch (code)
     {
         case ColumnTypeCode.Custom:
             return new CustomColumnInfo() { CustomTypeName = reader.ReadString() };
         case ColumnTypeCode.List:
             innercode = (ColumnTypeCode)reader.ReadUInt16();
             return new ListColumnInfo()
             {
                 ValueTypeCode = innercode,
                 ValueTypeInfo = GetColumnInfo(reader, innercode)
             };
         case ColumnTypeCode.Map:
             innercode = (ColumnTypeCode)reader.ReadUInt16();
             var kci = GetColumnInfo(reader, innercode);
             vinnercode = (ColumnTypeCode)reader.ReadUInt16();
             var vci = GetColumnInfo(reader, vinnercode);
             return new MapColumnInfo()
             {
                 KeyTypeCode = innercode,
                 KeyTypeInfo = kci,
                 ValueTypeCode = vinnercode,
                 ValueTypeInfo = vci
             };
         case ColumnTypeCode.Set:
             innercode = (ColumnTypeCode)reader.ReadUInt16();
             return new SetColumnInfo()
             {
                 KeyTypeCode = innercode,
                 KeyTypeInfo = GetColumnInfo(reader, innercode)
             };
         default:
             return null;
     }
 }
        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);
                    }
                }
            }
        }
Esempio n. 41
0
        internal RowSetMetadata(BEBinaryReader reader)
        {
            var coldat = new List<ColumnDesc>();
            var flags = (FlagBits)reader.ReadInt32();
            var numberOfcolumns = reader.ReadInt32();
            this._rawColumns = new ColumnDesc[numberOfcolumns];
            string gKsname = null;
            string gTablename = null;

            if ((flags & FlagBits.GlobalTablesSpec) == FlagBits.GlobalTablesSpec)
            {
                gKsname = reader.ReadString();
                gTablename = reader.ReadString();
            }
            for (int i = 0; i < numberOfcolumns; i++)
            {
                var col = new ColumnDesc();
                if ((flags & FlagBits.GlobalTablesSpec) != FlagBits.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];
            _columnIdxes = 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 = TypeInterpreter.GetDefaultTypeFromCqlType(
                            _rawColumns[i].TypeCode,
                            _rawColumns[i].TypeInfo),
                        TypeCode = _rawColumns[i].TypeCode,
                        TypeInfo = _rawColumns[i].TypeInfo
                    };
                //TODO: what with full long column names?
                if (!_columnIdxes.ContainsKey(_rawColumns[i].Name))
                    _columnIdxes.Add(_rawColumns[i].Name, i);
            }
        }
Esempio n. 42
0
 protected abstract void Load(BEBinaryReader reader);
Esempio n. 43
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;
            }
        }