@Override public String visitLimitOperator(LimitOperator op, Boolean showDetails) throws AlgebricksException { stringBuilder.setLength(0); stringBuilder.append("limit ").append(op.getMaxObjects().getValue().toString()); ILogicalExpression offset = op.getOffset().getValue(); if (offset != null) { stringBuilder.append(", ").append(offset.toString()); } appendSchema(op, showDetails); appendAnnotations(op, showDetails); appendPhysicalOperatorInfo(op, showDetails); return stringBuilder.toString(); }
@Override public Boolean visitLimitOperator(LimitOperator op, ILogicalOperator arg) throws AlgebricksException { AbstractLogicalOperator aop = (AbstractLogicalOperator) arg; if (aop.getOperatorTag() != LogicalOperatorTag.LIMIT) { return Boolean.FALSE; } LimitOperator limitOpArg = (LimitOperator) copyAndSubstituteVar(op, arg); if (!Objects.equals(op.getOffset().getValue(), limitOpArg.getOffset().getValue())) { return Boolean.FALSE; } boolean isomorphic = op.getMaxObjects().getValue().equals(limitOpArg.getMaxObjects().getValue()); return isomorphic; }
@Override public Void visitLimitOperator(LimitOperator op, Integer indent) throws AlgebricksException { addIndent(indent).append("limit " + op.getMaxObjects().getValue().accept(exprVisitor, indent)); ILogicalExpression offset = op.getOffset().getValue(); if (offset != null) { buffer.append(", " + offset.accept(exprVisitor, indent)); } return null; }
@Override public Void visitLimitOperator(LimitOperator op, Void arg) { op.getMaxObjects().getValue().getUsedVariables(usedVariables); ILogicalExpression offsetExpr = op.getOffset().getValue(); if (offsetExpr != null) { offsetExpr.getUsedVariables(usedVariables); } return null; }
@Override public Void visitLimitOperator(LimitOperator op, Integer indent) throws AlgebricksException { addIndent(indent).append("\"operator\": \"limit\",\n"); addIndent(indent).append("\"value\": \"" + op.getMaxObjects().getValue().accept(exprVisitor, indent) + "\""); ILogicalExpression offset = op.getOffset().getValue(); if (offset != null) { buffer.append(",\n"); addIndent(indent).append("\"offset\": \"" + offset.accept(exprVisitor, indent) + "\""); } return null; }
@Override public Void visitLimitOperator(LimitOperator op, Pair<LogicalVariable, LogicalVariable> pair) throws AlgebricksException { op.getMaxObjects().getValue().substituteVar(pair.first, pair.second); ILogicalExpression offset = op.getOffset().getValue(); if (offset != null) { offset.substituteVar(pair.first, pair.second); } substVarTypes(op, pair); return null; }
@Override public ILogicalOperator visitLimitOperator(LimitOperator op, Void arg) throws AlgebricksException { return new LimitOperator(deepCopyExpressionRef(op.getMaxObjects()).getValue(), deepCopyExpressionRef(op.getOffset()).getValue(), op.isTopmostLimitOp()); }
@Override public ILogicalOperator visitLimitOperator(LimitOperator op, ILogicalOperator arg) throws AlgebricksException { LimitOperator opCopy = new LimitOperator(exprDeepCopyVisitor.deepCopy(op.getMaxObjects().getValue()), exprDeepCopyVisitor.deepCopy(op.getOffset().getValue()), op.isTopmostLimitOp()); deepCopyInputsAnnotationsAndExecutionMode(op, arg, opCopy); return opCopy; }
ILogicalExpression offsetExpr = limitOp.getOffset().getValue(); if (offsetExpr != null) { IAObject offsetValue = ConstantExpressionUtil.getConstantIaObject(offsetExpr, ATypeTag.INTEGER);
SourceLocation sourceLoc = limitOp.getSourceLocation(); LimitOperator limitCloneOp = null; if (limitOp.getOffset().getValue() == null) { limitCloneOp = new LimitOperator(limitOp.getMaxObjects().getValue(), false); limitCloneOp.setSourceLocation(sourceLoc); addArgs.add( new MutableObject<ILogicalExpression>(limitOp.getMaxObjects().getValue().cloneExpression())); addArgs.add(new MutableObject<ILogicalExpression>(limitOp.getOffset().getValue().cloneExpression())); ScalarFunctionCallExpression maxPlusOffset = new ScalarFunctionCallExpression(finfoAdd, addArgs); maxPlusOffset.setSourceLocation(sourceLoc);
@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); }