Example usage for org.apache.cassandra.cql3 QueryOptions getConsistency

List of usage examples for org.apache.cassandra.cql3 QueryOptions getConsistency

Introduction

In this page you can find the example usage for org.apache.cassandra.cql3 QueryOptions getConsistency.

Prototype

public abstract ConsistencyLevel getConsistency();

Source Link

Usage

From source file:com.stratio.cassandra.lucene.IndexQueryHandler.java

License:Apache License

public ResultMessage processStatement(CQLStatement statement, QueryState state, QueryOptions options) {

    logger.trace("Process {} @CL.{}", statement, options.getConsistency());
    ClientState clientState = state.getClientState();
    statement.checkAccess(clientState);/*from  w ww  .  j a  va  2s.  com*/
    statement.validate(clientState);

    // Intercept Lucene index searches
    if (statement instanceof SelectStatement) {
        SelectStatement select = (SelectStatement) statement;
        List<RowFilter.Expression> expressions = select.getRowFilter(options).getExpressions();
        for (RowFilter.Expression expression : expressions) {
            if (expression.isCustom()) {
                RowFilter.CustomExpression customExpression = (RowFilter.CustomExpression) expression;
                String clazz = customExpression.getTargetIndex().options
                        .get(IndexTarget.CUSTOM_INDEX_OPTION_NAME);
                if (clazz.equals(Index.class.getCanonicalName())) {
                    TimeCounter time = TimeCounter.create().start();
                    try {
                        return process(select, state, options, customExpression);
                    } catch (ReflectiveOperationException e) {
                        throw new IndexException(e);
                    } finally {
                        logger.debug("Lucene search total time: {}\n", time.stop());
                    }
                }
            }
        }
    }

    return execute(statement, state, options);
}

From source file:com.stratio.cassandra.lucene.IndexQueryHandler.java

License:Apache License

public ResultMessage.Rows executeWithoutPaging(SelectStatement select, QueryState state, QueryOptions options)
        throws ReflectiveOperationException {

    ConsistencyLevel cl = options.getConsistency();
    checkNotNull(cl, "Invalid empty consistency level");

    cl.validateForRead(select.keyspace());

    int nowInSec = FBUtilities.nowInSeconds();
    int userLimit = select.getLimit(options);
    ReadQuery query = select.getQuery(options, nowInSec, userLimit);

    Method method = select.getClass().getDeclaredMethod("execute", ReadQuery.class, QueryOptions.class,
            QueryState.class, int.class, int.class);
    method.setAccessible(true);/*from w ww  . j  a  v  a2 s .c  o  m*/
    return (ResultMessage.Rows) method.invoke(select, query, options, state, nowInSec, userLimit);
}