@Override public Pair<ILangExpression, VariableSubstitutionEnvironment> visit(OrderbyClause oc, VariableSubstitutionEnvironment env) throws CompilationException { List<Expression> exprList = VariableCloneAndSubstitutionUtil.visitAndCloneExprList(oc.getOrderbyList(), env, this); OrderbyClause oc2 = new OrderbyClause(exprList, new ArrayList<>(oc.getModifierList())); oc2.setNumFrames(oc.getNumFrames()); oc2.setNumTuples(oc.getNumTuples()); oc2.setRangeMap(oc.getRangeMap()); oc2.setSourceLocation(oc.getSourceLocation()); return new Pair<>(oc2, env); }
@Override public Pair<ILogicalOperator, LogicalVariable> visit(OrderbyClause oc, Mutable<ILogicalOperator> tupSource) throws CompilationException { SourceLocation sourceLoc = oc.getSourceLocation(); OrderOperator ord = new OrderOperator(); ord.setSourceLocation(sourceLoc); Iterator<OrderModifier> modifIter = oc.getModifierList().iterator(); Mutable<ILogicalOperator> topOp = tupSource; for (Expression e : oc.getOrderbyList()) { Pair<ILogicalExpression, Mutable<ILogicalOperator>> p = langExprToAlgExpression(e, topOp); OrderModifier m = modifIter.next(); OrderOperator.IOrder comp = translateOrderModifier(m); ord.getOrderExpressions().add(new Pair<>(comp, new MutableObject<>(p.first))); topOp = p.second; } ord.getInputs().add(topOp); if (oc.getNumTuples() > 0) { ord.getAnnotations().put(OperatorAnnotations.CARDINALITY, oc.getNumTuples()); } if (oc.getNumFrames() > 0) { ord.getAnnotations().put(OperatorAnnotations.MAX_NUMBER_FRAMES, oc.getNumFrames()); } if (oc.getRangeMap() != null) { Iterator<OrderModifier> orderModifIter = oc.getModifierList().iterator(); boolean ascending = orderModifIter.next() == OrderModifier.ASC; RangeMapBuilder.verifyRangeOrder(oc.getRangeMap(), ascending); ord.getAnnotations().put(OperatorAnnotations.USE_STATIC_RANGE, oc.getRangeMap()); } return new Pair<>(ord, null); }