Examples of ILogicalExpression


Examples of edu.uci.ics.hyracks.algebricks.core.algebra.base.ILogicalExpression

        }
        AssignOperator assign = (AssignOperator) op;

        // Check to see if the expression is a function and
        // sort-distinct-nodes-asc-or-atomics.
        ILogicalExpression logicalExpression = (ILogicalExpression) assign.getExpressions().get(0).getValue();
        if (logicalExpression.getExpressionTag() != LogicalExpressionTag.FUNCTION_CALL) {
            return false;
        }
        AbstractFunctionCallExpression functionCall = (AbstractFunctionCallExpression) logicalExpression;
        if (!functionCall.getFunctionIdentifier().equals(
                BuiltinOperators.SORT_DISTINCT_NODES_ASC_OR_ATOMICS.getFunctionIdentifier())
                && !functionCall.getFunctionIdentifier().equals(
                        BuiltinOperators.DISTINCT_NODES_OR_ATOMICS.getFunctionIdentifier())
                && !functionCall.getFunctionIdentifier().equals(
                        BuiltinOperators.SORT_NODES_ASC_OR_ATOMICS.getFunctionIdentifier())) {
            return false;
        }

        // Build a subplan for replacing the sort distinct function with operators.
        // Nested tuple source.
        Mutable<ILogicalOperator> inputOperator = getInputOperator(assign.getInputs().get(0));
        NestedTupleSourceOperator ntsOperator = new NestedTupleSourceOperator(inputOperator);
        nextOperatorRef = new MutableObject<ILogicalOperator>(ntsOperator);

        // Get variable that is being used for sort and distinct operators.
        VariableReferenceExpression inputVariableRef = (VariableReferenceExpression) functionCall.getArguments().get(0)
                .getValue();
        LogicalVariable inputVariable = inputVariableRef.getVariableReference();

        // Unnest.
        LogicalVariable unnestVariable = context.newVar();
        UnnestOperator unnestOperator = getUnnestOperator(inputVariable, unnestVariable);
        unnestOperator.getInputs().add(nextOperatorRef);
        nextOperatorRef = new MutableObject<ILogicalOperator>(unnestOperator);

        // Assign Node ID key.
        LogicalVariable nodeIdKeyVariable = context.newVar();
        AssignOperator nodeIdAssignOp = getAssignOperator(unnestVariable, nodeIdKeyVariable,
                BuiltinOperators.ID_FROM_NODE);
        nodeIdAssignOp.getInputs().add(nextOperatorRef);
        nextOperatorRef = new MutableObject<ILogicalOperator>(nodeIdAssignOp);

        // Prepare for Order and Distinct.
        Mutable<ILogicalExpression> nodeIdKeyVariableRef = new MutableObject<ILogicalExpression>(
                new VariableReferenceExpression(nodeIdKeyVariable));

        // Distinct.
        if (functionCall.getFunctionIdentifier().equals(
                BuiltinOperators.SORT_DISTINCT_NODES_ASC_OR_ATOMICS.getFunctionIdentifier())
                || functionCall.getFunctionIdentifier().equals(
                        BuiltinOperators.DISTINCT_NODES_OR_ATOMICS.getFunctionIdentifier())) {
            LogicalVariable groupByVariable = context.newVar();
            ILogicalExpression nodeIdKeyVre = new VariableReferenceExpression(nodeIdKeyVariable);
            GroupByOperator groupByOperator = getGroupByOperator(groupByVariable, nodeIdKeyVre);
            groupByOperator.getInputs().add(nextOperatorRef);
            nextOperatorRef = new MutableObject<ILogicalOperator>(groupByOperator);
        }
View Full Code Here

Examples of edu.uci.ics.hyracks.algebricks.core.algebra.base.ILogicalExpression

        }
        UnnestOperator unnest2 = (UnnestOperator) op2;

        if (!usedVariables.contains(unnest2.getVariable())) {
            // Check to see if the unnest2 expression has a scalar implementation.
            ILogicalExpression logicalExpression2 = (ILogicalExpression) unnest2.getExpressionRef().getValue();
            if (logicalExpression2.getExpressionTag() != LogicalExpressionTag.FUNCTION_CALL) {
                return false;
            }
            AbstractFunctionCallExpression functionCall2 = (AbstractFunctionCallExpression) logicalExpression2;
            Function functionInfo2 = (Function) functionCall2.getFunctionInfo();
            if (!functionInfo2.hasScalarEvaluatorFactory()) {
View Full Code Here

Examples of edu.uci.ics.hyracks.algebricks.core.algebra.base.ILogicalExpression

        ExpressionToolbox.findAllFunctionExpressions(search, BuiltinFunctions.FN_BOOLEAN_1.getFunctionIdentifier(),
                functionList);
        for (Mutable<ILogicalExpression> searchM : functionList) {
            // Get input function
            AbstractFunctionCallExpression searchFunction = (AbstractFunctionCallExpression) searchM.getValue();
            ILogicalExpression argFirst = searchFunction.getArguments().get(0).getValue();
            if (argFirst.getExpressionTag() != LogicalExpressionTag.FUNCTION_CALL) {
                continue;
            }
            AbstractFunctionCallExpression functionCall = (AbstractFunctionCallExpression) argFirst;
            if (ALGEBRICKS_MAP.containsKey(functionCall.getFunctionIdentifier())) {
                FunctionIdentifier algebricksFid = ALGEBRICKS_MAP.get(functionCall.getFunctionIdentifier());
View Full Code Here

Examples of edu.uci.ics.hyracks.algebricks.core.algebra.base.ILogicalExpression

        if (variableId > 0) {
            // Find the function expression.
            // All the checks for these variable assigns and casting were done in the
            // getOperatorSortDistinctNodesAscOrAtomicsArgumentVariableId function.
            AssignOperator assign = (AssignOperator) op;
            ILogicalExpression logicalExpression = (ILogicalExpression) assign.getExpressions().get(0).getValue();
            AbstractFunctionCallExpression functionCall = (AbstractFunctionCallExpression) logicalExpression;

            if (uniqueNodesVariables.get(variableId) == UniqueNodes.YES) {
                // Only unique nodes.
                if (documentOrderVariables.get(variableId) == DocumentOrder.YES) {
View Full Code Here

Examples of edu.uci.ics.hyracks.algebricks.core.algebra.base.ILogicalExpression

        }
        AssignOperator assign = (AssignOperator) op;

        // Check to see if the expression is a function and
        // sort-distinct-nodes-asc-or-atomics.
        ILogicalExpression logicalExpression = (ILogicalExpression) assign.getExpressions().get(0).getValue();
        if (logicalExpression.getExpressionTag() != LogicalExpressionTag.FUNCTION_CALL) {
            return 0;
        }
        AbstractFunctionCallExpression functionCall = (AbstractFunctionCallExpression) logicalExpression;
        if (!functionCall.getFunctionIdentifier().equals(
                BuiltinOperators.SORT_DISTINCT_NODES_ASC_OR_ATOMICS.getFunctionIdentifier())) {
            return 0;
        }

        // Find the variable id used as the parameter.
        ILogicalExpression logicalExpression2 = (ILogicalExpression) functionCall.getArguments().get(0).getValue();
        if (logicalExpression2.getExpressionTag() != LogicalExpressionTag.VARIABLE) {
            return 0;
        }
        VariableReferenceExpression variableExpression = (VariableReferenceExpression) logicalExpression2;
        return variableExpression.getVariableReference().getId();
    }
View Full Code Here

Examples of edu.uci.ics.hyracks.algebricks.core.algebra.base.ILogicalExpression

        // Get the DocumentOrder from propagation.
        switch (op.getOperatorTag()) {
            case AGGREGATE:
                AggregateOperator aggregate = (AggregateOperator) op;
                for (int index = 0; index < aggregate.getExpressions().size(); index++) {
                    ILogicalExpression aggregateLogicalExpression = (ILogicalExpression) aggregate.getExpressions()
                            .get(index).getValue();
                    variableId = aggregate.getVariables().get(index).getId();
                    documentOrder = propagateDocumentOrder(aggregateLogicalExpression,
                            documentOrderVariablesForOperator);
                    uniqueNodes = propagateUniqueNodes(aggregateLogicalExpression, uniqueNodesVariablesForOperator);
                    documentOrderVariables.put(variableId, documentOrder);
                    uniqueNodesVariables.put(variableId, uniqueNodes);
                }
                break;
            case ASSIGN:
                AssignOperator assign = (AssignOperator) op;
                for (int index = 0; index < assign.getExpressions().size(); index++) {
                    ILogicalExpression assignLogicalExpression = (ILogicalExpression) assign.getExpressions()
                            .get(index).getValue();
                    variableId = assign.getVariables().get(index).getId();
                    documentOrder = propagateDocumentOrder(assignLogicalExpression, documentOrderVariablesForOperator);
                    uniqueNodes = propagateUniqueNodes(assignLogicalExpression, uniqueNodesVariablesForOperator);
                    documentOrderVariables.put(variableId, documentOrder);
                    uniqueNodesVariables.put(variableId, uniqueNodes);
                }
                break;
            case INNERJOIN:
            case LEFTOUTERJOIN:
                resetDocumentOrderVariables(documentOrderVariables, DocumentOrder.NO);
                resetUniqueNodesVariables(uniqueNodesVariables, UniqueNodes.NO);
                break;
            case ORDER:
                // Get order variable id that is altered.
                OrderOperator order = (OrderOperator) op;
                for (int index = 0; index < order.getOrderExpressions().size(); index++) {
                    ILogicalExpression orderLogicalExpression = order.getOrderExpressions().get(index).second
                            .getValue();
                    if (orderLogicalExpression.getExpressionTag() != LogicalExpressionTag.VARIABLE) {
                        throw new RuntimeException("Operator (" + op.getOperatorTag()
                                + ") has received unexpected input in rewrite rule.");
                    }
                    VariableReferenceExpression variableExpression = (VariableReferenceExpression) orderLogicalExpression;
                    variableId = variableExpression.getVariableReference().getId();

                    // Remove document order from variable used in order operator.
                    documentOrderVariables.put(variableId, DocumentOrder.NO);
                }
                break;
            case SUBPLAN:
                // Find the last operator to set a variable and call this function again.
                SubplanOperator subplan = (SubplanOperator) op;
                for (int index = 0; index < subplan.getNestedPlans().size(); index++) {
                    AbstractLogicalOperator lastOperator = (AbstractLogicalOperator) subplan.getNestedPlans().get(index)
                            .getRoots().get(0).getValue();
                    updateVariableMap(lastOperator, cardinalityVariable, documentOrderVariables, uniqueNodesVariables,
                            vxqueryContext);
                }
                break;
            case UNNEST:
                // Get unnest item property.
                UnnestOperator unnest = (UnnestOperator) op;
                ILogicalExpression unnestLogicalExpression = (ILogicalExpression) unnest.getExpressionRef().getValue();
                variableId = unnest.getVariables().get(0).getId();
                Cardinality inputCardinality = vxqueryContext.getCardinalityOperatorMap(op.getInputs().get(0)
                        .getValue());
                documentOrder = propagateDocumentOrder(unnestLogicalExpression, documentOrderVariablesForOperator);
                uniqueNodes = propagateUniqueNodes(unnestLogicalExpression, uniqueNodesVariablesForOperator);
View Full Code Here

Examples of edu.uci.ics.hyracks.algebricks.core.algebra.base.ILogicalExpression

            throws AlgebricksException {
        assert expr.getExpressionTag() == LogicalExpressionTag.FUNCTION_CALL;
        FunctionIdentifier fi = expr.getFunctionIdentifier();
        List<Mutable<ILogicalExpression>> args = expr.getArguments();
        if ((identifiesTypeOperator(fi) || identifiesPathStep(fi)) && args.size() > 1) {
            final ILogicalExpression typeEx = args.get(1).getValue();
            assert typeEx.getExpressionTag() == LogicalExpressionTag.CONSTANT;
            SequenceType type = getSequenceType((ConstantExpression) typeEx);
            sb.append(fi + " <" + type + ">, Args:");
            appendArgument(sb, args.get(0), indent + 2);
        } else {
            sb.append("function-call: " + fi + ", Args:");
View Full Code Here

Examples of edu.uci.ics.hyracks.algebricks.core.algebra.base.ILogicalExpression

            return null;
        }
        AssignOperator assign = (AssignOperator) op2;

        // Check to see if the expression is a function and fn:Collection.
        ILogicalExpression logicalExpression = (ILogicalExpression) assign.getExpressions().get(0).getValue();
        if (logicalExpression.getExpressionTag() != LogicalExpressionTag.FUNCTION_CALL) {
            return null;
        }
        AbstractFunctionCallExpression functionCall = (AbstractFunctionCallExpression) logicalExpression;
        if (!functionCall.getFunctionIdentifier().equals(BuiltinFunctions.FN_COLLECTION_1.getFunctionIdentifier())) {
            return null;
        }

        // Get the string assigned to the collection function.
        AbstractLogicalOperator op3 = (AbstractLogicalOperator) assign.getInputs().get(0).getValue();
        if (op3.getOperatorTag() == LogicalOperatorTag.ASSIGN) {
            AssignOperator assign2 = (AssignOperator) op3;

            // Check to see if the expression is a constant expression and type string.
            ILogicalExpression logicalExpression2 = (ILogicalExpression) assign2.getExpressions().get(0).getValue();
            if (logicalExpression2.getExpressionTag() != LogicalExpressionTag.CONSTANT) {
                return null;
            }
            ConstantExpression constantExpression = (ConstantExpression) logicalExpression2;
            constantValue = (VXQueryConstantValue) constantExpression.getValue();
            if (constantValue.getType() != SequenceType.create(BuiltinTypeRegistry.XS_STRING, Quantifier.QUANT_ONE)) {
                return null;
            }
        } else if (op3.getOperatorTag() == LogicalOperatorTag.EMPTYTUPLESOURCE) {
            ILogicalExpression logicalExpression2 = (ILogicalExpression) functionCall.getArguments().get(0).getValue();
            if (logicalExpression2.getExpressionTag() != LogicalExpressionTag.FUNCTION_CALL) {
                return null;
            }
            AbstractFunctionCallExpression functionCall2 = (AbstractFunctionCallExpression) logicalExpression2;
            if (!functionCall2.getFunctionIdentifier().equals(BuiltinOperators.PROMOTE.getFunctionIdentifier())) {
                return null;
            }

            ILogicalExpression logicalExpression3 = (ILogicalExpression) functionCall2.getArguments().get(0).getValue();
            if (logicalExpression3.getExpressionTag() != LogicalExpressionTag.FUNCTION_CALL) {
                return null;
            }
            AbstractFunctionCallExpression functionCall3 = (AbstractFunctionCallExpression) logicalExpression3;
            if (!functionCall3.getFunctionIdentifier().equals(BuiltinFunctions.FN_DATA_1.getFunctionIdentifier())) {
                return null;
            }

            ILogicalExpression logicalExpression4 = (ILogicalExpression) functionCall3.getArguments().get(0).getValue();
            if (logicalExpression4.getExpressionTag() != LogicalExpressionTag.CONSTANT) {
                return null;
            }
            ConstantExpression constantExpression = (ConstantExpression) logicalExpression4;
            constantValue = (VXQueryConstantValue) constantExpression.getValue();
            if (constantValue.getType() != SequenceType.create(BuiltinTypeRegistry.XS_STRING, Quantifier.QUANT_ONE)) {
View Full Code Here

Examples of edu.uci.ics.hyracks.algebricks.core.algebra.base.ILogicalExpression

            return false;
        }
        AssignOperator assign = (AssignOperator) op;

        Mutable<ILogicalExpression> mutableLogicalExpression = assign.getExpressions().get(0);
        ILogicalExpression logicalExpression = mutableLogicalExpression.getValue();
        if (logicalExpression.getExpressionTag() != LogicalExpressionTag.FUNCTION_CALL) {
            return false;
        }
        AbstractFunctionCallExpression functionCall = (AbstractFunctionCallExpression) logicalExpression;
        // TODO Use the function definition
        aggregateInfo = getAggregateFunction(functionCall);
        if (aggregateInfo == null) {
            return false;
        }
        mutableVariableExpresion = ExpressionToolbox.findVariableExpression(mutableLogicalExpression);
        if (mutableVariableExpresion == null) {
            return false;
        }
        Mutable<ILogicalExpression> finalFunctionCallM = ExpressionToolbox
                .findLastFunctionExpression(mutableLogicalExpression);
        finalFunctionCall = (AbstractFunctionCallExpression) finalFunctionCallM.getValue();

        // Variable details.
        VariableReferenceExpression variableReference = (VariableReferenceExpression) mutableVariableExpresion
                .getValue();
        int variableId = variableReference.getVariableReference().getId();

        // Search for variable see if it is a aggregate sequence.
        AbstractLogicalOperator opSearch = (AbstractLogicalOperator) op.getInputs().get(0).getValue();
        opSearch = findSequenceAggregateOperator(opSearch, variableId);
        if (opSearch == null) {
            return false;
        }

        AggregateOperator aggregate = (AggregateOperator) opSearch;

        // Check to see if the expression is a function and sort-distinct-nodes-asc-or-atomics.
        ILogicalExpression logicalExpressionSearch = (ILogicalExpression) aggregate.getExpressions().get(0).getValue();
        if (logicalExpressionSearch.getExpressionTag() != LogicalExpressionTag.FUNCTION_CALL) {
            return false;
        }
        AbstractFunctionCallExpression functionCallSearch = (AbstractFunctionCallExpression) logicalExpressionSearch;
        if (!functionCallSearch.getFunctionIdentifier().equals(BuiltinOperators.SEQUENCE.getFunctionIdentifier())) {
            return false;
View Full Code Here

Examples of edu.uci.ics.hyracks.algebricks.core.algebra.base.ILogicalExpression

            if (opSearch.getOperatorTag() == LogicalOperatorTag.AGGREGATE) {
                // Check for variable assignment and sequence.
                AggregateOperator aggregate = (AggregateOperator) opSearch;

                // Check to see if the expression is a function and sort-distinct-nodes-asc-or-atomics.
                ILogicalExpression logicalExpressionSearch = (ILogicalExpression) aggregate.getExpressions().get(0)
                        .getValue();
                if (logicalExpressionSearch.getExpressionTag() != LogicalExpressionTag.FUNCTION_CALL) {
                    opSearch = (AbstractLogicalOperator) opSearch.getInputs().get(0).getValue();
                    continue;
                }
                AbstractFunctionCallExpression functionCallSearch = (AbstractFunctionCallExpression) logicalExpressionSearch;
                if (!functionCallSearch.getFunctionIdentifier().equals(
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.