Example usage for org.apache.cassandra.cql3.statements SelectStatement getRowFilter

List of usage examples for org.apache.cassandra.cql3.statements SelectStatement getRowFilter

Introduction

In this page you can find the example usage for org.apache.cassandra.cql3.statements SelectStatement getRowFilter.

Prototype

public RowFilter getRowFilter(QueryOptions options) throws InvalidRequestException 

Source Link

Document

May be used by custom QueryHandler implementations

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);/* w ww . j  av  a 2 s  .c o m*/
    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);
}