Esempio n. 1
0
 internal OutputPrepared(byte protocolVersion, FrameReader reader)
 {
     var length = reader.ReadInt16();
     QueryId = new byte[length];
     reader.Read(QueryId, 0, length);
     Metadata = new RowSetMetadata(reader, protocolVersion >= 4);
 }
 internal OutputPrepared(BEBinaryReader reader)
 {
     var len = reader.ReadInt16();
     QueryID = new byte[len];
     reader.Read(QueryID, 0, len);
     Metadata = new RowSetMetadata(reader);
 }
Esempio n. 3
0
        public ExecuteRequest(int protocolVersion, byte[] id, RowSetMetadata metadata, bool tracingEnabled, QueryProtocolOptions queryOptions)
        {
            ProtocolVersion = protocolVersion;
            if (metadata != null && queryOptions.Values.Length != metadata.Columns.Length)
            {
                throw new ArgumentException("Number of values does not match with number of prepared statement markers(?).", "values");
            }
            _id = id;
            _metadata = metadata;
            _queryOptions = queryOptions;
            if (tracingEnabled)
            {
                _headerFlags = FrameHeader.HeaderFlag.Tracing;
            }

            if (Consistency.IsSerialConsistencyLevel())
            {
                throw new RequestInvalidException("Serial consistency specified as a non-serial one.");
            }
            if (queryOptions.SerialConsistency != ConsistencyLevel.Any && queryOptions.SerialConsistency.IsSerialConsistencyLevel() == false)
            {
                throw new RequestInvalidException("Non-serial consistency specified as a serial one.");
            }
            if (queryOptions.Timestamp != null && protocolVersion < 3)
            {
                throw new NotSupportedException("Timestamp for query is supported in Cassandra 2.1 or above.");
            }
        }
Esempio n. 4
0
 internal OutputPrepared(BEBinaryReader reader, bool readResultsMetadata)
 {
     short len = reader.ReadInt16();
     QueryId = new byte[len];
     reader.Read(QueryId, 0, len);
     Metadata = new RowSetMetadata(reader);
     if (readResultsMetadata)
         ResultMetadata = new RowSetMetadata(reader);
 }
Esempio n. 5
0
 public ExecuteRequest(int streamId, byte[] id, RowSetMetadata metadata, object[] values, ConsistencyLevel consistency, bool tracingEnabled)
 {
     this._streamId = streamId;
     this._values = values;
     this._id = id;
     this._metadata = metadata;
     this._consistency = consistency;
     if (tracingEnabled)
         this._flags = 0x02;
 }
Esempio n. 6
0
        public ExecuteRequest(int streamId, byte[] id, RowSetMetadata metadata, object[] values, ConsistencyLevel consistency, bool tracingEnabled)
        {
            if (values.Length != metadata.Columns.Length)
                throw new System.ArgumentException("Number of values does not match with number of prepared statement markers(?).", "values");

            this._streamId = streamId;
            this._values = values;
            this._id = id;
            this._metadata = metadata;
            this._consistency = consistency;
            if (tracingEnabled)
                this._flags = 0x02;
        }
Esempio n. 7
0
 private static PreparedStatement GetPrepared(string query = Query, RowSetMetadata metadata = null, int protocolVersion = 3)
 {
     return new PreparedStatement(metadata, new byte[0], query, null, null, protocolVersion);
 }
Esempio n. 8
0
 public void PreparedStatement_Bind_SetsRoutingKey_Multiple()
 {
     const int protocolVersion = 2;
     var metadata = new RowSetMetadata(null)
     {
         Columns = new[]
         {
             new CqlColumn { Name = "id2" },
             new CqlColumn { Name = "id1" }
         }
     };
     var ps = GetPrepared("SELECT * FROM tbl1 WHERE id2 = ? and id1", metadata, protocolVersion);
     ps.SetPartitionKeys(new[] { new TableColumn() { Name = "id1" }, new TableColumn() { Name = "id2" } });
     //The routing key is formed by the parameters at position 1 and 0
     CollectionAssert.AreEqual(new[] { 1, 0 }, ps.RoutingIndexes);
     Assert.Null(ps.RoutingKey);
     var bound = ps.Bind(2001, 1001);
     Assert.NotNull(bound.RoutingKey);
     var expectedRoutingKey = new byte[0]
         .Concat(new byte[] {0, 4})
         .Concat(TypeCodec.Encode(protocolVersion, 1001))
         .Concat(new byte[] {0})
         .Concat(new byte[] {0, 4})
         .Concat(TypeCodec.Encode(protocolVersion, 2001))
         .Concat(new byte[] {0});
     CollectionAssert.AreEqual(expectedRoutingKey, bound.RoutingKey.RawRoutingKey);
 }
Esempio n. 9
0
 public void PreparedStatement_Bind_SetsRoutingKey_Single()
 {
     const int protocolVersion = 2;
     var metadata = new RowSetMetadata(null)
     {
         Columns = new[]
         {
             new CqlColumn { Name = "name" }, 
             new CqlColumn { Name = "id" }
         }
     };
     var ps = GetPrepared("SELECT * FROM tbl1 WHERE name = ? and id = ?", metadata, protocolVersion);
     ps.SetPartitionKeys(new[] { new TableColumn() { Name = "id" } });
     //The routing key is at position 1
     CollectionAssert.AreEqual(new[] { 1 }, ps.RoutingIndexes);
     Assert.Null(ps.RoutingKey);
     var bound = ps.Bind("dummy name", 1000);
     Assert.NotNull(bound.RoutingKey);
     CollectionAssert.AreEqual(TypeCodec.Encode(protocolVersion, 1000), bound.RoutingKey.RawRoutingKey);
 }
 internal PreparedStatement(RowSetMetadata metadata, byte[] id)
 {
     this.Metadata = metadata;
     this.Id = id;
 }
Esempio n. 11
0
 internal PreparedStatement(RowSetMetadata metadata, byte[] id)
 {
     this.Metadata = metadata;
     this.Id       = id;
 }
Esempio n. 12
0
 // for testing
 internal OutputPrepared(byte[] queryId, RowSetMetadata rowSetMetadata)
 {
     QueryId  = queryId;
     Metadata = rowSetMetadata;
 }
Esempio n. 13
0
        internal OutputPrepared(ProtocolVersion protocolVersion, FrameReader reader)
        {
            QueryId = reader.ReadShortBytes();

            Metadata = new RowSetMetadata(reader, protocolVersion.SupportsPreparedPartitionKey());
        }
Esempio n. 14
0
 private static PreparedStatement GetPrepared(string query = Query, RowSetMetadata metadata = null, int protocolVersion = 3)
 {
     return(new PreparedStatement(metadata, new byte[0], query, null, protocolVersion));
 }
Esempio n. 15
0
 private static PreparedStatement GetPrepared(string query = Query, RowSetMetadata metadata = null)
 {
     return(new PreparedStatement(metadata, new byte[0], query, null, new Serializer(ProtocolVersion.MaxSupported)));
 }