use of org.apache.cassandra.transport.messages.ResultMessage in project cassandra by apache.
the class QueryProcessor method executeInternalWithNow.
/**
* A special version of executeLocally that takes the time used as "now" for the query in argument.
* Note that this only make sense for Selects so this only accept SELECT statements and is only useful in rare
* cases.
*/
public static UntypedResultSet executeInternalWithNow(int nowInSec, long queryStartNanoTime, String query, Object... values) {
Prepared prepared = prepareInternal(query);
assert prepared.statement instanceof SelectStatement;
SelectStatement select = (SelectStatement) prepared.statement;
ResultMessage result = select.executeInternal(internalQueryState(), makeInternalOptions(prepared.statement, values), nowInSec, queryStartNanoTime);
assert result instanceof ResultMessage.Rows;
return UntypedResultSet.create(((ResultMessage.Rows) result).result);
}
use of org.apache.cassandra.transport.messages.ResultMessage in project cassandra by apache.
the class QueryProcessor method process.
public static UntypedResultSet process(String query, ConsistencyLevel cl, List<ByteBuffer> values) throws RequestExecutionException {
QueryState queryState = QueryState.forInternalCalls();
QueryOptions options = QueryOptions.forInternalCalls(cl, values);
CQLStatement statement = instance.parse(query, queryState, options);
ResultMessage result = instance.process(statement, queryState, options, nanoTime());
if (result instanceof ResultMessage.Rows)
return UntypedResultSet.create(((ResultMessage.Rows) result).result);
else
return null;
}
use of org.apache.cassandra.transport.messages.ResultMessage in project cassandra by apache.
the class QueryProcessor method executeOnceInternal.
private static UntypedResultSet executeOnceInternal(QueryState queryState, String query, Object... values) {
CQLStatement statement = parseStatement(query, queryState.getClientState());
statement.validate(queryState.getClientState());
ResultMessage result = statement.executeLocally(queryState, makeInternalOptions(statement, values));
if (result instanceof ResultMessage.Rows)
return UntypedResultSet.create(((ResultMessage.Rows) result).result);
else
return null;
}
use of org.apache.cassandra.transport.messages.ResultMessage in project cassandra by apache.
the class QueryProcessor method processStatement.
public ResultMessage processStatement(CQLStatement statement, QueryState queryState, QueryOptions options, long queryStartNanoTime) throws RequestExecutionException, RequestValidationException {
logger.trace("Process {} @CL.{}", statement, options.getConsistency());
ClientState clientState = queryState.getClientState();
statement.authorize(clientState);
statement.validate(clientState);
ResultMessage result = options.getConsistency() == ConsistencyLevel.NODE_LOCAL ? processNodeLocalStatement(statement, queryState, options) : statement.execute(queryState, options, queryStartNanoTime);
return result == null ? new ResultMessage.Void() : result;
}
use of org.apache.cassandra.transport.messages.ResultMessage in project cassandra by apache.
the class QueryProcessor method execute.
public static UntypedResultSet execute(String query, ConsistencyLevel cl, QueryState state, Object... values) throws RequestExecutionException {
try {
Prepared prepared = prepareInternal(query);
ResultMessage result = prepared.statement.execute(state, makeInternalOptions(prepared.statement, values, cl), nanoTime());
if (result instanceof ResultMessage.Rows)
return UntypedResultSet.create(((ResultMessage.Rows) result).result);
else
return null;
} catch (RequestValidationException e) {
throw new RuntimeException("Error validating " + query, e);
}
}
Aggregations