private IScalarEvaluatorFactory[] createEvaluatorFactories(List<Mutable<ILogicalExpression>> exprList, IOperatorSchema[] inputSchemas, IVariableTypeEnvironment inputTypeEnv, IExpressionRuntimeProvider exprRuntimeProvider, JobGenContext context) throws AlgebricksException { if (exprList.isEmpty()) { return null; } int ln = exprList.size(); IScalarEvaluatorFactory[] evals = new IScalarEvaluatorFactory[ln]; for (int i = 0; i < ln; i++) { ILogicalExpression expr = exprList.get(i).getValue(); evals[i] = exprRuntimeProvider.createEvaluatorFactory(expr, inputTypeEnv, inputSchemas, context); } return evals; }
@Override public AsterixTupleFilterFactory createTupleFilterFactory(IOperatorSchema[] inputSchemas, IVariableTypeEnvironment typeEnv, ILogicalExpression filterExpr, JobGenContext context) throws AlgebricksException { // No filtering condition. if (filterExpr == null) { return null; } IExpressionRuntimeProvider expressionRuntimeProvider = context.getExpressionRuntimeProvider(); IScalarEvaluatorFactory filterEvalFactory = expressionRuntimeProvider.createEvaluatorFactory(filterExpr, typeEnv, inputSchemas, context); return new AsterixTupleFilterFactory(filterEvalFactory, context.getBinaryBooleanInspectorFactory()); }
private <T> Pair<IScalarEvaluatorFactory[], IBinaryComparatorFactory[]> createEvaluatorAndComparatorFactories( List<T> exprList, Function<T, Mutable<ILogicalExpression>> exprGetter, Function<T, OrderOperator.IOrder> orderGetter, IOperatorSchema[] inputSchemas, IVariableTypeEnvironment inputTypeEnv, IExpressionRuntimeProvider exprRuntimeProvider, IBinaryComparatorFactoryProvider binaryComparatorFactoryProvider, JobGenContext context) throws AlgebricksException { if (exprList.isEmpty()) { return new Pair<>(null, null); } int ln = exprList.size(); IScalarEvaluatorFactory[] evals = new IScalarEvaluatorFactory[ln]; IBinaryComparatorFactory[] comparators = new IBinaryComparatorFactory[ln]; for (int i = 0; i < ln; i++) { T exprObj = exprList.get(i); ILogicalExpression expr = exprGetter.apply(exprObj).getValue(); OrderOperator.IOrder order = orderGetter.apply(exprObj); evals[i] = exprRuntimeProvider.createEvaluatorFactory(expr, inputTypeEnv, inputSchemas, context); comparators[i] = binaryComparatorFactoryProvider.getBinaryComparatorFactory(inputTypeEnv.getType(expr), order.getKind() == OrderOperator.IOrder.OrderKind.ASC); } return new Pair<>(evals, comparators); }
@Override public void contributeRuntimeOperator(IHyracksJobBuilder builder, JobGenContext context, ILogicalOperator op, IOperatorSchema propagatedSchema, IOperatorSchema[] inputSchemas, IOperatorSchema outerPlanSchema) throws AlgebricksException { LimitOperator limit = (LimitOperator) op; IExpressionRuntimeProvider expressionRuntimeProvider = context.getExpressionRuntimeProvider(); IVariableTypeEnvironment env = context.getTypeEnvironment(op); IScalarEvaluatorFactory maxObjectsFact = expressionRuntimeProvider .createEvaluatorFactory(limit.getMaxObjects().getValue(), env, inputSchemas, context); ILogicalExpression offsetExpr = limit.getOffset().getValue(); IScalarEvaluatorFactory offsetFact = (offsetExpr == null) ? null : expressionRuntimeProvider.createEvaluatorFactory(offsetExpr, env, inputSchemas, context); RecordDescriptor recDesc = JobGenHelper.mkRecordDescriptor(context.getTypeEnvironment(op), propagatedSchema, context); StreamLimitRuntimeFactory runtime = new StreamLimitRuntimeFactory(maxObjectsFact, offsetFact, null, context.getBinaryIntegerInspectorFactory()); runtime.setSourceLocation(limit.getSourceLocation()); builder.contributeMicroOperator(limit, runtime, recDesc); // and contribute one edge from its child ILogicalOperator src = limit.getInputs().get(0).getValue(); builder.contributeGraphEdge(src, 0, limit, 0); }
IExpressionRuntimeProvider expressionRuntimeProvider = context.getExpressionRuntimeProvider(); for (int i = 0; i < evalFactories.length; i++) { evalFactories[i] = expressionRuntimeProvider.createEvaluatorFactory(expressions.get(i).getValue(), context.getTypeEnvironment(op.getInputs().get(0).getValue()), inputSchemas, context);
@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 contributeRuntimeOperator(IHyracksJobBuilder builder, JobGenContext context, ILogicalOperator op, IOperatorSchema propagatedSchema, IOperatorSchema[] inputSchemas, IOperatorSchema outerPlanSchema) throws AlgebricksException { SplitOperator sop = (SplitOperator) op; int outputArity = sop.getOutputArity(); int defaultBranch = sop.getDefaultBranch(); boolean propageToAllBranchAsDefault = sop.getPropageToAllBranchAsDefault(); IOperatorDescriptorRegistry spec = builder.getJobSpec(); RecordDescriptor recDescriptor = JobGenHelper.mkRecordDescriptor(context.getTypeEnvironment(op), propagatedSchema, context); IExpressionRuntimeProvider expressionRuntimeProvider = context.getExpressionRuntimeProvider(); IScalarEvaluatorFactory brachingExprEvalFactory = expressionRuntimeProvider.createEvaluatorFactory( sop.getBranchingExpression().getValue(), context.getTypeEnvironment(op), inputSchemas, context); IBinaryIntegerInspectorFactory intInsepctorFactory = context.getBinaryIntegerInspectorFactory(); SplitOperatorDescriptor sopDesc = new SplitOperatorDescriptor(spec, recDescriptor, outputArity, brachingExprEvalFactory, intInsepctorFactory, defaultBranch, propageToAllBranchAsDefault); sopDesc.setSourceLocation(sop.getSourceLocation()); contributeOpDesc(builder, sop, sopDesc); ILogicalOperator src = op.getInputs().get(0).getValue(); builder.contributeGraphEdge(src, 0, op, 0); } }
conditionInputSchemas[0] = propagatedSchema; IExpressionRuntimeProvider expressionRuntimeProvider = context.getExpressionRuntimeProvider(); IScalarEvaluatorFactory cond = expressionRuntimeProvider.createEvaluatorFactory(join.getCondition().getValue(), context.getTypeEnvironment(op), conditionInputSchemas, context); ITuplePairComparatorFactory comparatorFactory =
if (frameOffsetExpr != null) { frameOffsetExprEval = exprRuntimeProvider.createEvaluatorFactory(frameOffsetExpr, inputTypeEnv, inputSchemas, context);
IScalarEvaluatorFactory fact = jobGenCtx.getExpressionRuntimeProvider().createEvaluatorFactory(expr, _emptyTypeEnv, _emptySchemas, jobGenCtx);