Example usage for org.apache.cassandra.cql3 CQLStatement validate

List of usage examples for org.apache.cassandra.cql3 CQLStatement validate

Introduction

In this page you can find the example usage for org.apache.cassandra.cql3 CQLStatement validate.

Prototype

public void validate(ClientState state);

Source Link

Document

Perform additional validation required by the statment.

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);//  ww  w .  j  av a2 s  .  c om
    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);
}