Ejemplo n.º 1
0
 internal OutputRows(FrameReader reader, Guid?traceId)
 {
     _metadata  = new RowSetMetadata(reader);
     _rowLength = reader.ReadInt32();
     TraceId    = traceId;
     RowSet     = new RowSet();
     ProcessRows(RowSet, reader);
 }
Ejemplo n.º 2
0
 protected override void Load(FrameReader reader)
 {
     _exception = new FunctionFailureException(Message)
     {
         Keyspace      = reader.ReadString(),
         Name          = reader.ReadString(),
         ArgumentTypes = reader.ReadStringList()
     };
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Process rows and sets the paging event handler
 /// </summary>
 internal void ProcessRows(RowSet rs, FrameReader reader)
 {
     if (_metadata != null)
     {
         rs.Columns     = _metadata.Columns;
         rs.PagingState = _metadata.PagingState;
     }
     for (var i = 0; i < _rowLength; i++)
     {
         rs.AddRow(ProcessRowItem(reader));
     }
 }
        internal OutputOptions(FrameReader reader)
        {
            _options = new Dictionary <string, string[]>();
            int n = reader.ReadUInt16();

            for (var i = 0; i < n; i++)
            {
                var k = reader.ReadString();
                var v = reader.ReadStringList();
                _options.Add(k, v);
            }
        }
Ejemplo n.º 5
0
        internal static OutputError CreateOutputError(int code, string message, FrameReader cb)
        {
            Func <OutputError> factoryMethod;

            if (OutputErrorFactoryMethods.TryGetValue(code, out factoryMethod) == false)
            {
                throw new DriverInternalError(string.Format("Received unknown error with code {0} and message {1}", code, message));
            }

            var error = factoryMethod();

            error.Message = message;
            error.Code    = code;
            error.Load(cb);
            return(error);
        }
Ejemplo n.º 6
0
        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));
        }
        private IColumnInfo GetColumnInfo(FrameReader 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);
            }
        }
        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);
        }
Ejemplo n.º 9
0
 protected abstract void Load(FrameReader reader);