@Override public Pair<ILogicalOperator, LogicalVariable> visit(WhereClause w, Mutable<ILogicalOperator> tupSource) throws CompilationException { Pair<ILogicalExpression, Mutable<ILogicalOperator>> p = langExprToAlgExpression(w.getWhereExpr(), tupSource); SelectOperator s = new SelectOperator(new MutableObject<>(p.first), false, null); s.getInputs().add(p.second); s.setSourceLocation(w.getSourceLocation()); return new Pair<>(s, null); }
ILogicalExpression cond = select.getCondition().getValue(); SourceLocation sourceLoc = select.getSourceLocation(); Mutable<ILogicalOperator> childOfSelect = select.getInputs().get(0); boolean fst = true; ILogicalOperator botOp = select; firstExpr = e; } else { SelectOperator newSelect = new SelectOperator(new MutableObject<ILogicalExpression>(e), select.getRetainMissing(), select.getMissingPlaceholderVariable()); newSelect.setSourceLocation(sourceLoc); List<Mutable<ILogicalOperator>> botInpList = botOp.getInputs(); botInpList.clear(); select.getCondition().setValue(firstExpr); context.computeAndSetTypeEnvironmentForOperator(botOp); context.computeAndSetTypeEnvironmentForOperator(select);
@Override public ILogicalOperator visitSelectOperator(SelectOperator op, Void arg) throws AlgebricksException { return new SelectOperator(deepCopyExpressionRef(op.getCondition()), op.getRetainMissing(), op.getMissingPlaceholderVariable()); }
@Override public Pair<ILogicalOperator, LogicalVariable> visit(HavingClause havingClause, Mutable<ILogicalOperator> tupSource) throws CompilationException { Pair<ILogicalExpression, Mutable<ILogicalOperator>> p = langExprToAlgExpression(havingClause.getFilterExpression(), tupSource); SelectOperator s = new SelectOperator(new MutableObject<>(p.first), false, null); s.getInputs().add(p.second); return new Pair<>(s, null); }
new SelectOperator(new MutableObject<ILogicalExpression>(isFilterableExpr), false, null); isFilterableSelectOp.setSourceLocation(sourceLoc); isFilterableSelectOp.getInputs().add(new MutableObject<ILogicalOperator>(inputOp)); isFilterableSelectOp.setExecutionMode(ExecutionMode.LOCAL); context.computeAndSetTypeEnvironmentForOperator(isFilterableSelectOp); isNotFilterableExpr.setSourceLocation(sourceLoc); SelectOperator isNotFilterableSelectOp = new SelectOperator(new MutableObject<ILogicalExpression>(isNotFilterableExpr), false, null); isNotFilterableSelectOp.setSourceLocation(sourceLoc); isNotFilterableSelectOp.getInputs().add(new MutableObject<ILogicalOperator>(inputOp)); isNotFilterableSelectOp.setExecutionMode(ExecutionMode.LOCAL); context.computeAndSetTypeEnvironmentForOperator(isNotFilterableSelectOp);
@Override public Void visitSelectOperator(SelectOperator op, IOptimizationContext ctx) throws AlgebricksException { ILogicalOperator childOp = op.getInputs().get(0).getValue(); Map<LogicalVariable, EquivalenceClass> equivalenceClasses = getOrComputeEqClasses(childOp, ctx); ctx.putEquivalenceClassMap(op, equivalenceClasses); List<FunctionalDependency> functionalDependencies = new ArrayList<FunctionalDependency>(); ctx.putFDList(op, functionalDependencies); functionalDependencies.addAll(getOrComputeFDs(childOp, ctx)); equivalenceClasses.putAll(getOrComputeEqClasses(childOp, ctx)); ILogicalExpression expr = op.getCondition().getValue(); expr.getConstraintsAndEquivClasses(functionalDependencies, equivalenceClasses); return null; }
@Override public void contributeRuntimeOperator(IHyracksJobBuilder builder, JobGenContext context, ILogicalOperator op, IOperatorSchema opSchema, IOperatorSchema[] inputSchemas, IOperatorSchema outerPlanSchema) throws AlgebricksException { SelectOperator select = (SelectOperator) op; IExpressionRuntimeProvider expressionRuntimeProvider = context.getExpressionRuntimeProvider(); IScalarEvaluatorFactory cond = expressionRuntimeProvider.createEvaluatorFactory( select.getCondition().getValue(), context.getTypeEnvironment(op), inputSchemas, context); StreamSelectRuntimeFactory runtime = new StreamSelectRuntimeFactory(cond, null, context.getBinaryBooleanInspectorFactory(), select.getRetainMissing(), inputSchemas[0].findVariable(select.getMissingPlaceholderVariable()), context.getMissingWriterFactory()); runtime.setSourceLocation(select.getSourceLocation()); // contribute one Asterix framewriter RecordDescriptor recDesc = JobGenHelper.mkRecordDescriptor(context.getTypeEnvironment(op), opSchema, context); builder.contributeMicroOperator(select, runtime, recDesc); // and contribute one edge from its child ILogicalOperator src = select.getInputs().get(0).getValue(); builder.contributeGraphEdge(src, 0, select, 0); }
@Override public Void visitSelectOperator(SelectOperator op, Pair<LogicalVariable, LogicalVariable> pair) { op.getCondition().getValue().substituteVar(pair.first, pair.second); return null; }
Mutable<ILogicalOperator> childOfSelect = selectOperator.getInputs().get(0); new AssignOperator(v, new MutableObject<ILogicalExpression>(selectOperator.getCondition().getValue())); assignOperator.setSourceLocation(selectOperator.getSourceLocation()); varRef.setSourceLocation(selectOperator.getSourceLocation()); selectOperator.getCondition().setValue(varRef);//scalarFunctionCallExpression); selectOperator.getInputs().set(0, new MutableObject<ILogicalOperator>(assignOperator));
conj.setSourceLocation(firstSelect.getSourceLocation()); conj.getArguments().add(new MutableObject<ILogicalExpression>(firstSelect.getCondition().getValue())); conj.getArguments().add(((SelectOperator) nextSelect).getCondition()); selectParent = nextSelect; nextSelect = (AbstractLogicalOperator) nextSelect.getInputs().get(0).getValue(); firstSelect.getCondition().setValue(conj); context.computeAndSetTypeEnvironmentForOperator(firstSelect); return true;
@Override public boolean rewritePost(Mutable<ILogicalOperator> opRef, IOptimizationContext context) throws AlgebricksException { AbstractLogicalOperator op = (AbstractLogicalOperator) opRef.getValue(); if (op.getOperatorTag() != LogicalOperatorTag.SELECT) { return false; } SelectOperator select = (SelectOperator) op; ILogicalExpression condition = select.getCondition().getValue(); IVariableTypeEnvironment env = select.computeOutputTypeEnvironment(context); IAType condType = (IAType) env.getType(condition); if (condType.getTypeTag() != ATypeTag.BOOLEAN && condType.getTypeTag() != ATypeTag.ANY && !isPossibleBoolean(condType)) { throw new CompilationException(ErrorCode.COMPILATION_ERROR, condition.getSourceLocation(), "The select condition " + LogRedactionUtil.userData(condition.toString()) + " should be of the " + "boolean type."); } return false; }
@Override public Long visitSelectOperator(SelectOperator op, Void arg) throws AlgebricksException { return adjustCardinalityForTupleReductionOperator(op.getInputs().get(0).getValue().accept(this, arg)); }
newSelectOpInLeftPath = new SelectOperator(new MutableObject<ILogicalExpression>(conditionRefExpr), retainMissing, newMissingPlaceHolderVar); newSelectOpInLeftPath.setSourceLocation(conditionRefExpr.getSourceLocation()); VariableUtilities.substituteVariables(newSelectOpInLeftPath, origVarToNewVarInLeftPathMap, context); newSelectOpInLeftPath.getInputs().clear(); newSelectOpInLeftPath.getInputs() .add(new MutableObject<ILogicalOperator>(assignsBeforeTopOpRef.get(0).getValue())); } else { newSelectOpInLeftPath.getInputs().add(new MutableObject<ILogicalOperator>(primaryIndexUnnestMapOp)); newSelectOpInLeftPath.setExecutionMode(ExecutionMode.PARTITIONED); context.computeAndSetTypeEnvironmentForOperator(newSelectOpInLeftPath); newSelectOpInRightPath = new SelectOperator(new MutableObject<ILogicalExpression>(conditionRefExpr2), retainMissing, newMissingPlaceHolderVar); newSelectOpInRightPath.setSourceLocation(conditionRefExpr2.getSourceLocation()); newSelectOpInRightPath.getInputs().add(new MutableObject<ILogicalOperator>(currentTopOpInRightPath)); VariableUtilities.substituteVariables(newSelectOpInRightPath, origVarToSIdxUnnestMapOpVarMap, context); VariableUtilities.substituteVariables(newSelectOpInRightPath, origSKFieldVarToNewSKFieldVarMap, context); newSelectOpInRightPath.setExecutionMode(ExecutionMode.PARTITIONED); context.computeAndSetTypeEnvironmentForOperator(newSelectOpInRightPath); currentTopOpInRightPath = newSelectOpInRightPath;
/** * Check that the given SELECT condition is a function call. * Call initSubTree() to initialize the optimizable subtree that collects information from * the operators below the given SELECT operator. * In order to transform the given plan, a datasource should be configured * since we are going to transform a datasource into an unnest-map operator. */ protected boolean checkSelectOpConditionAndInitSubTree(IOptimizationContext context) throws AlgebricksException { // Set and analyze select. ILogicalExpression condExpr = selectOp.getCondition().getValue(); typeEnvironment = context.getOutputTypeEnvironment(selectOp); if (condExpr.getExpressionTag() != LogicalExpressionTag.FUNCTION_CALL) { return false; } selectCond = (AbstractFunctionCallExpression) condExpr; // Initialize the subtree information. // Match and put assign, unnest, and datasource information. boolean res = subTree.initFromSubTree(selectOp.getInputs().get(0)); return res && subTree.hasDataSourceScan(); }
@Override public ILogicalOperator visitSelectOperator(SelectOperator op, ILogicalOperator arg) throws AlgebricksException { SelectOperator opCopy = new SelectOperator(exprDeepCopyVisitor.deepCopyExpressionReference(op.getCondition()), op.getRetainMissing(), deepCopyVariable(op.getMissingPlaceholderVariable())); deepCopyInputsAnnotationsAndExecutionMode(op, arg, opCopy); return opCopy; }
@Override public String visitSelectOperator(SelectOperator op, Boolean showDetails) { stringBuilder.setLength(0); stringBuilder.append("select (").append(op.getCondition().getValue().toString()).append(")"); appendSchema(op, showDetails); appendAnnotations(op, showDetails); appendPhysicalOperatorInfo(op, showDetails); return stringBuilder.toString(); }
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);
if ((condEx = asFunctionCallExpression(select.getCondition(), AlgebricksBuiltinFunctions.OR)) == null) { return false; SourceLocation sourceLoc = select.getSourceLocation(); jOp.setSourceLocation(sourceLoc); jOp.getInputs().add(new MutableObject<>(unn)); jOp.getInputs().add(select.getInputs().get(0));
new ScalarFunctionCallExpression(finfoNot, new MutableObject<>(isSystemNullTest)); nonSystemNullTest.setSourceLocation(sourceLoc); selectNonSystemNull = new SelectOperator(new MutableObject<>(nonSystemNullTest), false, null); selectNonSystemNull.setSourceLocation(sourceLoc); } else { List<Mutable<ILogicalExpression>> isSystemNullTestList = new ArrayList<>(); selectNonSystemNull = new SelectOperator( new MutableObject<>(new ScalarFunctionCallExpression(finfoAnd, isSystemNullTestList)), false, null); selectNonSystemNull.setSourceLocation(sourceLoc); selectNonSystemNull.getInputs().add(ntsBeforeNestedGby);
SelectOperator topSelectOp = new SelectOperator(conditionRef, isLeftOuterJoin, newNullPlaceHolderVar); topSelectOp.setSourceLocation(finalIndexSearchOp.getSourceLocation()); topSelectOp.getInputs().add(indexSubTree.getRootRef()); topSelectOp.setExecutionMode(ExecutionMode.LOCAL); context.computeAndSetTypeEnvironmentForOperator(topSelectOp); joinRef.setValue(topSelectOp);