@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 Expression visit(OrderbyClause oc, ILangExpression arg) throws CompilationException { oc.setOrderbyList(visit(oc.getOrderbyList(), arg)); return null; }
@Override public OrderbyClause visit(OrderbyClause oc, Void arg) throws CompilationException { List<Expression> newOrderbyList = new ArrayList<>(); for (Expression orderExpr : oc.getOrderbyList()) { newOrderbyList.add((Expression) orderExpr.accept(this, arg)); } OrderbyClause copy = new OrderbyClause(newOrderbyList, new ArrayList<>(oc.getModifierList())); copy.setSourceLocation(oc.getSourceLocation()); return copy; }
final public Clause OrderbyClause() throws ParseException, ParseException { OrderbyClause oc = new OrderbyClause(); Expression orderbyExpr; List<Expression> orderbyList = new ArrayList<Expression>(); int numFrames = Integer.parseInt(splits[1]); int numTuples = Integer.parseInt(splits[2]); oc.setNumFrames(numFrames); oc.setNumTuples(numTuples); oc.setRangeMap(RangeMapBuilder.parseHint(createNewParser(hint.substring(RANGE_HINT.length())))); } catch (CompilationException e) { {if (true) throw new ParseException(e.getMessage());} oc.setModifierList(modifierList); oc.setOrderbyList(orderbyList); {if (true) return oc;} throw new Error("Missing return statement in function");
@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); }
@Override public Void visit(OrderbyClause oc, Integer step) throws CompilationException { out.print(skip(step) + "order by "); printDelimitedObyExpressions(oc.getOrderbyList(), oc.getModifierList(), step); out.println(); return null; }
@Override public Void visit(OrderbyClause oc, Void arg) throws CompilationException { for (Expression e : oc.getOrderbyList()) { e.accept(this, arg); } return null; }
@Override public Void visit(SelectExpression selectStatement, Void arg) throws CompilationException { selectStatement.getSelectSetOperation().accept(this, arg); if (selectStatement.hasOrderby()) { selectStatement.getOrderbyClause().accept(this, arg); } if (selectStatement.hasLimit()) { selectStatement.getLimitClause().accept(this, arg); } return null; }
final public Clause OrderbyClause() throws ParseException, ParseException { OrderbyClause oc = new OrderbyClause(); Expression orderbyExpr; List<Expression> orderbyList = new ArrayList<Expression>(); int numFrames = Integer.parseInt(splits[1]); int numTuples = Integer.parseInt(splits[2]); oc.setNumFrames(numFrames); oc.setNumTuples(numTuples); oc.setRangeMap(RangeMapBuilder.parseHint(createNewParser(hint.substring(RANGE_HINT.length())))); } catch (CompilationException e) { {if (true) throw new ParseException(e.getMessage());} oc.setModifierList(modifierList); oc.setOrderbyList(orderbyList); {if (true) return oc;} throw new Error("Missing return statement in function");
@Override public Void visit(OrderbyClause oc, Integer step) throws CompilationException { out.println(skip(step) + "Orderby"); List<OrderModifier> mlist = oc.getModifierList(); List<Expression> list = oc.getOrderbyList(); for (int i = 0; i < list.size(); i++) { list.get(i).accept(this, step + 1); out.println(skip(step + 1) + mlist.get(i).toString()); } out.println(); return null; }
@Override public Boolean visit(OrderbyClause oc, ILangExpression arg) throws CompilationException { return visitExprList(oc.getOrderbyList(), arg); }
selectExpression.getOrderbyClause().accept(visitor, arg);
final public OrderbyClause OrderbyClause() throws ParseException, ParseException { Token startToken = null; OrderbyClause oc = new OrderbyClause(); Expression orderbyExpr; List<Expression> orderbyList = new ArrayList<Expression>(); int numFrames = Integer.parseInt(splits[1]); int numTuples = Integer.parseInt(splits[2]); oc.setNumFrames(numFrames); oc.setNumTuples(numTuples); oc.setRangeMap(RangeMapBuilder.parseHint(createNewParser(hint.substring(RANGE_HINT.length())))); } catch (CompilationException e) { {if (true) throw new SqlppParseException(getSourceLocation(getHintToken(token)), e.getMessage());} oc.setModifierList(modifierList); oc.setOrderbyList(orderbyList); {if (true) return addSourceLocation(oc, startToken);} throw new Error("Missing return statement in function");
@Override public Expression visit(OrderbyClause oc, ILangExpression arg) throws CompilationException { oc.setOrderbyList(visit(oc.getOrderbyList(), arg)); return null; }
case ORDER: orderByClause = OrderbyClause(); orderbyList = orderByClause.getOrderbyList(); orderbyModifierList = orderByClause.getModifierList(); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case IDENTIFIER:
@Override public Void visit(OrderbyClause oc, Collection<VariableExpr> freeVars) throws CompilationException { visit(oc.getOrderbyList(), freeVars); return null; }
@Override public Void visit(SelectExpression selectStatement, Integer step) throws CompilationException { if (selectStatement.isSubquery()) { out.print("("); } int selectStep = selectStatement.isSubquery() ? step + 2 : step; if (selectStatement.hasLetClauses()) { for (LetClause letClause : selectStatement.getLetList()) { letClause.accept(this, selectStep); } } selectStatement.getSelectSetOperation().accept(this, selectStep); if (selectStatement.hasOrderby()) { selectStatement.getOrderbyClause().accept(this, selectStep); } if (selectStatement.hasLimit()) { selectStatement.getLimitClause().accept(this, selectStep); } if (selectStatement.isSubquery()) { out.print(skip(step) + " )"); } return null; }
@Override public Boolean visit(OrderbyClause oc, List<FunctionDecl> arg) throws CompilationException { Pair<Boolean, List<Expression>> p = inlineUdfsInExprList(oc.getOrderbyList(), arg); oc.setOrderbyList(p.second); return p.first; }
@Override public Void visit(SelectExpression selectExpression, Collection<VariableExpr> freeVars) throws CompilationException { Collection<VariableExpr> letsFreeVars = new HashSet<>(); Collection<VariableExpr> selectFreeVars = new HashSet<>(); visitLetWhereClauses(selectExpression.getLetList(), letsFreeVars); // visit order by if (selectExpression.hasOrderby()) { for (Expression orderExpr : selectExpression.getOrderbyClause().getOrderbyList()) { orderExpr.accept(this, selectFreeVars); } } // visit limit if (selectExpression.hasLimit()) { selectExpression.getLimitClause().accept(this, selectFreeVars); } // visit the main select selectExpression.getSelectSetOperation().accept(this, selectFreeVars); // Removed let binding variables. selectFreeVars.removeAll(SqlppVariableUtil.getLetBindingVariables(selectExpression.getLetList())); freeVars.addAll(letsFreeVars); freeVars.addAll(selectFreeVars); return null; }
@Override public SelectExpression visit(SelectExpression selectExpression, Void arg) throws CompilationException { List<LetClause> lets = new ArrayList<>(); SelectSetOperation select; OrderbyClause orderby = null; LimitClause limit = null; // visit let list if (selectExpression.hasLetClauses()) { for (LetClause letClause : selectExpression.getLetList()) { lets.add((LetClause) letClause.accept(this, arg)); } } // visit the main select. select = (SelectSetOperation) selectExpression.getSelectSetOperation().accept(this, arg); // visit order by if (selectExpression.hasOrderby()) { orderby = (OrderbyClause) selectExpression.getOrderbyClause().accept(this, arg); } // visit limit if (selectExpression.hasLimit()) { limit = (LimitClause) selectExpression.getLimitClause().accept(this, arg); } SelectExpression copy = new SelectExpression(lets, select, orderby, limit, selectExpression.isSubquery()); copy.addHints(selectExpression.getHints()); return copy; }