Search in sources :

Example 1 with ExprNode

use of com.questdb.griffin.common.ExprNode in project questdb by bluestreak01.

the class SqlLexerOptimiser method optimiseBooleanNot.

private void optimiseBooleanNot(QueryModel model) throws ParserException {
    ExprNode where = model.getWhereClause();
    if (where != null) {
        model.setWhereClause(optimiseBooleanNot(where, false));
    }
    if (model.getNestedModel() != null) {
        optimiseBooleanNot(model.getNestedModel());
    }
    ObjList<QueryModel> joinModels = model.getJoinModels();
    for (int i = 1, n = joinModels.size(); i < n; i++) {
        optimiseBooleanNot(joinModels.getQuick(i));
    }
}
Also used : ExprNode(com.questdb.griffin.common.ExprNode)

Example 2 with ExprNode

use of com.questdb.griffin.common.ExprNode in project questdb by bluestreak01.

the class SqlLexerOptimiser method addFilterOrEmitJoin.

private void addFilterOrEmitJoin(QueryModel parent, int idx, int ai, CharSequence an, ExprNode ao, int bi, CharSequence bn, ExprNode bo) {
    if (ai == bi && Chars.equals(an, bn)) {
        deletedContexts.add(idx);
        return;
    }
    if (ai == bi) {
        // (same table)
        ExprNode node = exprNodePool.next().of(ExprNode.OPERATION, "=", 0, 0);
        node.paramCount = 2;
        node.lhs = ao;
        node.rhs = bo;
        addWhereNode(parent, ai, node);
    } else {
        // (different tables)
        JoinContext jc = contextPool.next();
        jc.aIndexes.add(ai);
        jc.aNames.add(an);
        jc.aNodes.add(ao);
        jc.bIndexes.add(bi);
        jc.bNames.add(bn);
        jc.bNodes.add(bo);
        jc.slaveIndex = ai > bi ? ai : bi;
        jc.parents.add(ai < bi ? ai : bi);
        emittedJoinClauses.add(jc);
    }
    deletedContexts.add(idx);
}
Also used : ExprNode(com.questdb.griffin.common.ExprNode)

Example 3 with ExprNode

use of com.questdb.griffin.common.ExprNode in project questdb by bluestreak01.

the class SqlLexerOptimiser method parseTimestamp.

private ExprNode parseTimestamp(CharSequence tok) throws ParserException {
    if (Chars.equalsNc("timestamp", tok)) {
        expectTok('(');
        final ExprNode result = expectLiteral();
        expectTok(')');
        return result;
    }
    return null;
}
Also used : ExprNode(com.questdb.griffin.common.ExprNode)

Example 4 with ExprNode

use of com.questdb.griffin.common.ExprNode in project questdb by bluestreak01.

the class SqlLexerOptimiser method concatFilters.

private ExprNode concatFilters(ExprNode old, ExprNode filter) {
    if (old == null) {
        return filter;
    } else {
        ExprNode n = exprNodePool.next().of(ExprNode.OPERATION, "and", 0, 0);
        n.paramCount = 2;
        n.lhs = old;
        n.rhs = filter;
        return n;
    }
}
Also used : ExprNode(com.questdb.griffin.common.ExprNode)

Example 5 with ExprNode

use of com.questdb.griffin.common.ExprNode in project questdb by bluestreak01.

the class SqlLexerOptimiser method makeOperation.

private ExprNode makeOperation(CharSequence token, ExprNode lhs, ExprNode rhs) {
    ExprNode expr = exprNodePool.next().of(ExprNode.OPERATION, token, 0, 0);
    expr.paramCount = 2;
    expr.lhs = lhs;
    expr.rhs = rhs;
    return expr;
}
Also used : ExprNode(com.questdb.griffin.common.ExprNode)

Aggregations

ExprNode (com.questdb.griffin.common.ExprNode)40 FlyweightCharSequence (com.questdb.std.str.FlyweightCharSequence)14 NumericException (com.questdb.common.NumericException)2 CairoException (com.questdb.cairo.CairoException)1 TableReader (com.questdb.cairo.TableReader)1 EntryLockedException (com.questdb.cairo.pool.ex.EntryLockedException)1 RecordColumnMetadata (com.questdb.common.RecordColumnMetadata)1 RecordMetadata (com.questdb.common.RecordMetadata)1 IntrinsicModel (com.questdb.griffin.lexer.model.IntrinsicModel)1 NotNull (org.jetbrains.annotations.NotNull)1