Пример #1
0
        //Only for tests purpose:
        //private class InsertQuery : CqlCommand
        //{
        //    string Query;

        //    internal InsertQuery(string query)
        //    {
        //        this.Query = query;
        //    }

        //    public override string GetCql()
        //    {
        //        return Query;
        //    }
        //}
        protected void init(CCMBridge.CCMCluster c, int n, bool batch, ConsistencyLevel cl)
        {
            CassandraRoutingKey routingKey = new CassandraRoutingKey();

            routingKey.RawRoutingKey = Enumerable.Repeat((byte)0x00, 4).ToArray();


            // We don't use insert for our test because the resultSet don't ship the queriedHost
            // Also note that we don't use tracing because this would trigger requests that screw up the test'
            for (int i = 0; i < n; ++i)
            {
                if (batch)
                // BUG: WriteType == SIMPLE
                {
                    StringBuilder bth = new StringBuilder();
                    bth.AppendLine("BEGIN BATCH");
                    bth.AppendLine(String.Format("INSERT INTO {0}(k, i) VALUES (0, 0)", TestUtils.SIMPLE_TABLE));
                    bth.AppendLine("APPLY BATCH");

                    var qh = c.Session.Execute(new SimpleStatement(bth.ToString()).SetRoutingKey(routingKey).SetConsistencyLevel(cl)).QueriedHost;
                }
                else
                {
                    var qh = c.Session.Execute(new SimpleStatement(String.Format("INSERT INTO {0}(k, i) VALUES (0, 0)", TestUtils.SIMPLE_TABLE)).SetRoutingKey(routingKey).SetConsistencyLevel(cl)).QueriedHost;
                }
            }

            prepared = c.Session.Prepare("SELECT * FROM " + TestUtils.SIMPLE_TABLE + " WHERE k = ?").SetConsistencyLevel(cl);
        }
Пример #2
0
 protected void query(CCMBridge.CCMCluster c, int n, bool usePrepared, ConsistencyLevel cl)
 {
     if (usePrepared)
     {
         BoundStatement bs = prepared.Bind(0);
         for (int i = 0; i < n; ++i)
         {
             addCoordinator(c.Session.Execute(bs));
         }
     }
     else
     {
         CassandraRoutingKey routingKey = new CassandraRoutingKey();
         routingKey.RawRoutingKey = Enumerable.Repeat((byte)0x00, 4).ToArray();
         for (int i = 0; i < n; ++i)
         {
             addCoordinator(c.Session.Execute(new SimpleStatement(String.Format("SELECT * FROM {0} WHERE k = 0", TABLE)).SetRoutingKey(routingKey).SetConsistencyLevel(cl)));
         }
     }
 }
 protected void query(CCMBridge.CCMCluster c, int n, bool usePrepared, ConsistencyLevel cl)
 {
     if (usePrepared)
     {
         BoundStatement bs = prepared.Bind(0);
         for (int i = 0; i < n; ++i)
             addCoordinator(c.Session.Execute(bs));
     }
     else
     {
         CassandraRoutingKey routingKey = new CassandraRoutingKey();
         routingKey.RawRoutingKey = Enumerable.Repeat((byte)0x00, 4).ToArray();
         for (int i = 0; i < n; ++i)
             addCoordinator(c.Session.Execute(new SimpleStatement(String.Format("SELECT * FROM {0} WHERE k = 0", TABLE)).SetRoutingKey(routingKey).SetConsistencyLevel(cl)));
     }
 }
        //Only for tests purpose:
        //private class InsertQuery : CqlCommand
        //{
        //    string Query;
        //    internal InsertQuery(string query)
        //    {
        //        this.Query = query;
        //    }
        //    public override string GetCql()
        //    {
        //        return Query;
        //    }
        //}
        protected void init(CCMBridge.CCMCluster c, int n, bool batch, ConsistencyLevel cl)
        {
            CassandraRoutingKey routingKey = new CassandraRoutingKey();
            routingKey.RawRoutingKey = Enumerable.Repeat((byte)0x00, 4).ToArray();

            // We don't use insert for our test because the resultSet don't ship the queriedHost
            // Also note that we don't use tracing because this would trigger requests that screw up the test'
            for (int i = 0; i < n; ++i)
                if (batch)
                // BUG: WriteType == SIMPLE
                {
                    StringBuilder bth = new StringBuilder();
                    bth.AppendLine("BEGIN BATCH");
                    bth.AppendLine(String.Format("INSERT INTO {0}(k, i) VALUES (0, 0)", TestUtils.SIMPLE_TABLE));
                    bth.AppendLine("APPLY BATCH");

                    var qh = c.Session.Execute(new SimpleStatement(bth.ToString()).SetRoutingKey(routingKey).SetConsistencyLevel(cl)).QueriedHost;
                }
                else
                {
                    var qh = c.Session.Execute(new SimpleStatement(String.Format("INSERT INTO {0}(k, i) VALUES (0, 0)", TestUtils.SIMPLE_TABLE)).SetRoutingKey(routingKey).SetConsistencyLevel(cl)).QueriedHost;
                }

            prepared = c.Session.Prepare("SELECT * FROM " + TestUtils.SIMPLE_TABLE + " WHERE k = ?").SetConsistencyLevel(cl);
        }
Пример #5
0
 /// <summary>
 ///  Set the routing key for this query. <p> See
 ///  <link>#setRoutingKey(ByteBuffer)</link> for more information. This method is
 ///  a variant for when the query partition key is composite and thus the routing
 ///  key must be built from multiple values.</p>
 /// </summary>
 /// <param name="routingKeyComponents"> the raw (binary) values to compose to
 ///  obtain the routing key. </param>
 ///
 /// <returns>this <code>PreparedStatement</code> object.
 ///  <see>Query#GetRoutingKey</returns>
 public PreparedStatement SetRoutingKey(params CassandraRoutingKey[] routingKeyComponents)
 {
     this._routingKey = CassandraRoutingKey.Compose(routingKeyComponents); return(this);
 }
 /// <summary>
 ///  Set the routing key for this query. <p> See
 ///  <link>#setRoutingKey(ByteBuffer)</link> for more information. This method is
 ///  a variant for when the query partition key is composite and thus the routing
 ///  key must be built from multiple values.</p>
 /// </summary>
 /// <param name="routingKeyComponents"> the raw (binary) values to compose to
 ///  obtain the routing key. </param>
 /// 
 /// <returns>this <code>PreparedStatement</code> object.
 ///  <see>Query#GetRoutingKey</returns>
 public PreparedStatement SetRoutingKey(params CassandraRoutingKey[] routingKeyComponents)
 {
     this._routingKey = CassandraRoutingKey.Compose(routingKeyComponents); return this;
 }