Search in sources :

Example 1 with ResultMessage

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);
}
Also used : ResultMessage(org.apache.cassandra.transport.messages.ResultMessage)

Example 2 with ResultMessage

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;
}
Also used : ResultMessage(org.apache.cassandra.transport.messages.ResultMessage)

Example 3 with ResultMessage

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;
}
Also used : ResultMessage(org.apache.cassandra.transport.messages.ResultMessage)

Example 4 with ResultMessage

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;
}
Also used : ResultMessage(org.apache.cassandra.transport.messages.ResultMessage)

Example 5 with ResultMessage

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);
    }
}
Also used : ResultMessage(org.apache.cassandra.transport.messages.ResultMessage)

Aggregations

ResultMessage (org.apache.cassandra.transport.messages.ResultMessage)20 ClientState (org.apache.cassandra.service.ClientState)4 ByteBuffer (java.nio.ByteBuffer)3 CQLStatement (org.apache.cassandra.cql3.CQLStatement)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 AuthenticatedUser (org.apache.cassandra.auth.AuthenticatedUser)2 DatabaseDescriptor (org.apache.cassandra.config.DatabaseDescriptor)2 InvalidRequestException (org.apache.cassandra.exceptions.InvalidRequestException)2 org.apache.cassandra.schema (org.apache.cassandra.schema)2 QueryState (org.apache.cassandra.service.QueryState)2 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 String.format (java.lang.String.format)1 BindException (java.net.BindException)1 java.util (java.util)1 Set (java.util.Set)1 TimeoutException (java.util.concurrent.TimeoutException)1 BiFunction (java.util.function.BiFunction)1 Collectors (java.util.stream.Collectors)1