Search in sources :

Example 16 with FunctionIdentifier

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

the class FunctionManagerImpl method unregisterFunction.

@Override
public synchronized void unregisterFunction(IFunctionDescriptorFactory descriptorFactory) throws AlgebricksException {
    FunctionIdentifier fid = descriptorFactory.createFunctionDescriptor().getIdentifier();
    Pair<FunctionIdentifier, Integer> key = new Pair<>(fid, fid.getArity());
    functions.remove(key);
}
Also used : FunctionIdentifier(org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier) Pair(org.apache.hyracks.algebricks.common.utils.Pair)

Example 17 with FunctionIdentifier

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

the class PullSelectOutOfEqJoin method rewritePost.

@Override
public boolean rewritePost(Mutable<ILogicalOperator> opRef, IOptimizationContext context) throws AlgebricksException {
    AbstractLogicalOperator op = (AbstractLogicalOperator) opRef.getValue();
    if (op.getOperatorTag() != LogicalOperatorTag.INNERJOIN) {
        return false;
    }
    AbstractBinaryJoinOperator join = (AbstractBinaryJoinOperator) op;
    ILogicalExpression expr = join.getCondition().getValue();
    if (expr.getExpressionTag() != LogicalExpressionTag.FUNCTION_CALL) {
        return false;
    }
    AbstractFunctionCallExpression fexp = (AbstractFunctionCallExpression) expr;
    FunctionIdentifier fi = fexp.getFunctionIdentifier();
    if (!fi.equals(AlgebricksBuiltinFunctions.AND)) {
        return false;
    }
    List<Mutable<ILogicalExpression>> eqVarVarComps = new ArrayList<Mutable<ILogicalExpression>>();
    List<Mutable<ILogicalExpression>> otherPredicates = new ArrayList<Mutable<ILogicalExpression>>();
    for (Mutable<ILogicalExpression> arg : fexp.getArguments()) {
        if (isEqVarVar(arg.getValue())) {
            eqVarVarComps.add(arg);
        } else {
            otherPredicates.add(arg);
        }
    }
    if (eqVarVarComps.isEmpty() || otherPredicates.isEmpty()) {
        return false;
    }
    // pull up
    ILogicalExpression pulledCond = makeCondition(otherPredicates, context);
    SelectOperator select = new SelectOperator(new MutableObject<ILogicalExpression>(pulledCond), false, null);
    ILogicalExpression newJoinCond = makeCondition(eqVarVarComps, context);
    join.getCondition().setValue(newJoinCond);
    select.getInputs().add(new MutableObject<ILogicalOperator>(join));
    opRef.setValue(select);
    context.computeAndSetTypeEnvironmentForOperator(select);
    return true;
}
Also used : AbstractLogicalOperator(org.apache.hyracks.algebricks.core.algebra.operators.logical.AbstractLogicalOperator) AbstractFunctionCallExpression(org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression) ILogicalOperator(org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator) ArrayList(java.util.ArrayList) AbstractBinaryJoinOperator(org.apache.hyracks.algebricks.core.algebra.operators.logical.AbstractBinaryJoinOperator) FunctionIdentifier(org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier) Mutable(org.apache.commons.lang3.mutable.Mutable) ILogicalExpression(org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression) SelectOperator(org.apache.hyracks.algebricks.core.algebra.operators.logical.SelectOperator)

Example 18 with FunctionIdentifier

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

the class AddEquivalenceClassForRecordConstructorRule method addEquivalenceClassesForRecordConstructor.

private boolean addEquivalenceClassesForRecordConstructor(List<LogicalVariable> vars, List<Mutable<ILogicalExpression>> exprRefs, AssignOperator assignOp, IOptimizationContext context) {
    boolean changed = false;
    for (int exprIndex = 0; exprIndex < exprRefs.size(); ++exprIndex) {
        ILogicalExpression expr = exprRefs.get(exprIndex).getValue();
        if (expr.getExpressionTag() == LogicalExpressionTag.FUNCTION_CALL) {
            AbstractFunctionCallExpression funcExpr = (AbstractFunctionCallExpression) expr;
            FunctionIdentifier fid = funcExpr.getFunctionIdentifier();
            if (fid == BuiltinFunctions.CLOSED_RECORD_CONSTRUCTOR || fid == BuiltinFunctions.OPEN_RECORD_CONSTRUCTOR) {
                changed |= propagateEquivalenceClassesForRecordConstructor(vars.get(exprIndex), funcExpr, assignOp, context);
            }
        }
    }
    return changed;
}
Also used : FunctionIdentifier(org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier) ILogicalExpression(org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression) AbstractFunctionCallExpression(org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression)

Example 19 with FunctionIdentifier

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

the class AnalysisUtil method isAccessToFieldRecord.

public static boolean isAccessToFieldRecord(ILogicalExpression expr) {
    if (expr.getExpressionTag() == LogicalExpressionTag.FUNCTION_CALL) {
        AbstractFunctionCallExpression fc = (AbstractFunctionCallExpression) expr;
        FunctionIdentifier fid = fc.getFunctionIdentifier();
        if (fid.equals(BuiltinFunctions.FIELD_ACCESS_BY_INDEX) || fid.equals(BuiltinFunctions.FIELD_ACCESS_BY_NAME) || fid.equals(BuiltinFunctions.FIELD_ACCESS_NESTED)) {
            return true;
        }
    }
    return false;
}
Also used : FunctionIdentifier(org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier) AbstractFunctionCallExpression(org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression)

Example 20 with FunctionIdentifier

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

the class AnalysisUtil method isRunnableAccessToFieldRecord.

public static boolean isRunnableAccessToFieldRecord(ILogicalExpression expr) {
    if (expr.getExpressionTag() == LogicalExpressionTag.FUNCTION_CALL) {
        AbstractFunctionCallExpression fc = (AbstractFunctionCallExpression) expr;
        FunctionIdentifier fid = fc.getFunctionIdentifier();
        if (AnalysisUtil.isRunnableFieldAccessFunction(fid)) {
            return true;
        }
    }
    return false;
}
Also used : FunctionIdentifier(org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier) AbstractFunctionCallExpression(org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression)

Aggregations

FunctionIdentifier (org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier)50 AbstractFunctionCallExpression (org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression)33 ILogicalExpression (org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression)31 ArrayList (java.util.ArrayList)15 Mutable (org.apache.commons.lang3.mutable.Mutable)14 LogicalVariable (org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable)13 AbstractLogicalOperator (org.apache.hyracks.algebricks.core.algebra.operators.logical.AbstractLogicalOperator)11 AlgebricksException (org.apache.hyracks.algebricks.common.exceptions.AlgebricksException)10 ILogicalOperator (org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator)10 VariableReferenceExpression (org.apache.hyracks.algebricks.core.algebra.expressions.VariableReferenceExpression)10 MetadataProvider (org.apache.asterix.metadata.declared.MetadataProvider)7 IAType (org.apache.asterix.om.types.IAType)7 AssignOperator (org.apache.hyracks.algebricks.core.algebra.operators.logical.AssignOperator)7 List (java.util.List)6 MutableObject (org.apache.commons.lang3.mutable.MutableObject)6 AggregateFunctionCallExpression (org.apache.hyracks.algebricks.core.algebra.expressions.AggregateFunctionCallExpression)6 ConstantExpression (org.apache.hyracks.algebricks.core.algebra.expressions.ConstantExpression)6 ScalarFunctionCallExpression (org.apache.hyracks.algebricks.core.algebra.expressions.ScalarFunctionCallExpression)6 AString (org.apache.asterix.om.base.AString)5 Pair (org.apache.hyracks.algebricks.common.utils.Pair)5