Esempio n. 1
0
        public IQuery <T> Execute(object dataSource)
        {
            var         coninfo        = getconn();
            var         cl             = _consistencyLevel ?? coninfo.connection.DefaultConsistencyLevel;
            var         executionFlags = _executionFlags ?? coninfo.connection.DefaultExecutionFlags;
            IDataMapper mapperIn       = _factoryIn.Create(dataSource.GetType());
            IDataMapper mapperOut      = _factoryOut.Create <T>();
            var         futQuery       = new ExecuteQuery <T>(coninfo.connection, cl, executionFlags, _cql, coninfo.id, coninfo.columnSpecs, dataSource, mapperIn, mapperOut);

            return(futQuery);
        }
Esempio n. 2
0
        public IQuery <T> Execute <T>(string cql, object dataSource, PartitionKey partitionKey)
        {
            if (null != dataSource)
            {
                throw new ArgumentException("Binary protocol v2 is not implemented");
            }

            // grab a connection
            BigInteger? token      = partitionKey == null ? null : _cluster.Partitioner.ComputeToken(partitionKey);
            IConnection connection = _cluster.GetConnection(token);

            // define execution context
            ConsistencyLevel cl             = _consistencyLevel ?? connection.DefaultConsistencyLevel;
            ExecutionFlags   executionFlags = _executionFlags ?? connection.DefaultExecutionFlags;

            // out to spit out results
            IDataMapper factoryOut = _factoryOut.Create <T>();

            IQuery <T> query = new CqlQuery <T>(connection, cl, executionFlags, cql, factoryOut);

            return(query);
        }
Esempio n. 3
0
        public IQuery <T> Execute(object dataSource)
        {
            ConsistencyLevel cl;
            ExecutionFlags   executionFlags;
            IConnection      connection;

            if (null == (connection = _connection))
            {
                lock (_lock)
                {
                    if (null == (connection = _connection))
                    {
                        connection            = _cluster.GetConnection();
                        connection.OnFailure += ConnectionOnOnFailure;

                        cl             = _consistencyLevel ?? connection.DefaultConsistencyLevel;
                        executionFlags = _executionFlags ?? connection.DefaultExecutionFlags;

                        var futPrepare = new PrepareQuery(connection, cl, executionFlags, _cql).AsFuture();
                        futPrepare.Wait();
                        Tuple <byte[], IColumnSpec[]> preparedInfo = futPrepare.Result.Single();

                        _id          = preparedInfo.Item1;
                        _columnSpecs = preparedInfo.Item2;
                        _connection  = connection;
                    }
                }
            }

            cl             = _consistencyLevel ?? connection.DefaultConsistencyLevel;
            executionFlags = _executionFlags ?? connection.DefaultExecutionFlags;
            IDataMapper mapperIn  = _factoryIn.Create(dataSource.GetType());
            IDataMapper mapperOut = _factoryOut.Create <T>();
            var         futQuery  = new ExecuteQuery <T>(connection, cl, executionFlags, _cql, _id, _columnSpecs, dataSource, mapperIn, mapperOut);

            return(futQuery);
        }