Search in sources :

Example 1 with ComparisonKind

use of org.apache.hyracks.algebricks.core.algebra.functions.AlgebricksBuiltinFunctions.ComparisonKind in project asterixdb by apache.

the class IntroduceLSMComponentFilterRule method createAssignOperator.

private AssignOperator createAssignOperator(List<IOptimizableFuncExpr> optFuncExprs, List<LogicalVariable> minFilterVars, List<LogicalVariable> maxFilterVars, IOptimizationContext context) {
    List<LogicalVariable> assignKeyVarList = new ArrayList<>();
    List<Mutable<ILogicalExpression>> assignKeyExprList = new ArrayList<>();
    for (IOptimizableFuncExpr optFuncExpr : optFuncExprs) {
        ComparisonKind ck = AlgebricksBuiltinFunctions.getComparisonType(optFuncExpr.getFuncExpr().getFunctionIdentifier());
        ILogicalExpression searchKeyExpr = optFuncExpr.getConstantExpr(0);
        LogicalVariable var = context.newVar();
        assignKeyExprList.add(new MutableObject<>(searchKeyExpr));
        assignKeyVarList.add(var);
        if (ck == ComparisonKind.GE || ck == ComparisonKind.GT) {
            minFilterVars.add(var);
        } else if (ck == ComparisonKind.LE || ck == ComparisonKind.LT) {
            maxFilterVars.add(var);
        } else if (ck == ComparisonKind.EQ) {
            minFilterVars.add(var);
            maxFilterVars.add(var);
        }
    }
    return new AssignOperator(assignKeyVarList, assignKeyExprList);
}
Also used : LogicalVariable(org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable) Mutable(org.apache.commons.lang3.mutable.Mutable) ILogicalExpression(org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression) ComparisonKind(org.apache.hyracks.algebricks.core.algebra.functions.AlgebricksBuiltinFunctions.ComparisonKind) ArrayList(java.util.ArrayList) AssignOperator(org.apache.hyracks.algebricks.core.algebra.operators.logical.AssignOperator)

Example 2 with ComparisonKind

use of org.apache.hyracks.algebricks.core.algebra.functions.AlgebricksBuiltinFunctions.ComparisonKind in project asterixdb by apache.

the class BTreeAccessMethod method getLimitType.

private LimitType getLimitType(IOptimizableFuncExpr optFuncExpr, OptimizableOperatorSubTree probeSubTree) {
    ComparisonKind ck = AlgebricksBuiltinFunctions.getComparisonType(optFuncExpr.getFuncExpr().getFunctionIdentifier());
    LimitType limit = null;
    switch(ck) {
        case EQ:
            {
                limit = LimitType.EQUAL;
                break;
            }
        case GE:
            {
                limit = probeIsOnLhs(optFuncExpr, probeSubTree) ? LimitType.HIGH_INCLUSIVE : LimitType.LOW_INCLUSIVE;
                break;
            }
        case GT:
            {
                limit = probeIsOnLhs(optFuncExpr, probeSubTree) ? LimitType.HIGH_EXCLUSIVE : LimitType.LOW_EXCLUSIVE;
                break;
            }
        case LE:
            {
                limit = probeIsOnLhs(optFuncExpr, probeSubTree) ? LimitType.LOW_INCLUSIVE : LimitType.HIGH_INCLUSIVE;
                break;
            }
        case LT:
            {
                limit = probeIsOnLhs(optFuncExpr, probeSubTree) ? LimitType.LOW_EXCLUSIVE : LimitType.HIGH_EXCLUSIVE;
                break;
            }
        case NEQ:
            {
                limit = null;
                break;
            }
        default:
            {
                throw new IllegalStateException();
            }
    }
    return limit;
}
Also used : ComparisonKind(org.apache.hyracks.algebricks.core.algebra.functions.AlgebricksBuiltinFunctions.ComparisonKind)

Aggregations

ComparisonKind (org.apache.hyracks.algebricks.core.algebra.functions.AlgebricksBuiltinFunctions.ComparisonKind)2 ArrayList (java.util.ArrayList)1 Mutable (org.apache.commons.lang3.mutable.Mutable)1 ILogicalExpression (org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression)1 LogicalVariable (org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable)1 AssignOperator (org.apache.hyracks.algebricks.core.algebra.operators.logical.AssignOperator)1