public SqlStatement translate(String _resultName, SqlStatement child) { resultName = subOp.getResultName(); String order = ""; resultSchema = subOp.getSchema(); List<SortCondition> conditions = opOrder.getConditions(); Iterator<SortCondition> iterator = conditions.iterator(); SortCondition current = iterator.next(); order += getOrderArg(current); while (iterator.hasNext()) { current = iterator.next(); order += ", " + getOrderArg(current); } child.addOrder(order); child.addLimit(Tags.LIMIT_LARGE_NUMBER); return child; }
@Override public String translate(String _resultName) { resultName = _resultName; varsWithNulls.addAll(subOp.getVarsWithNulls()); String order = "-- " + Tags.ORDER + "\n"; order += resultName + " = ORDER " + subOp.getResultName() + " BY "; List<SortCondition> conditions = opOrder.getConditions(); Iterator<SortCondition> iterator = conditions.iterator(); SortCondition current = iterator.next(); order += getOrderArg(current); while (iterator.hasNext()) { current = iterator.next(); order += ", " + getOrderArg(current); } order += " PARALLEL $reducerNum ;\n"; resultSchema.addAll(subOp.getSchema()); return order; }
private String getOrderArg(SortCondition condition) { String orderArg = condition.getExpression().getVarName(); int direction = condition.getDirection(); switch(direction) { case Query.ORDER_ASCENDING: { orderArg += " ASC"; break; } case Query.ORDER_DESCENDING: { orderArg += " DESC"; break; } case Query.ORDER_DEFAULT: { break; } } return orderArg; }
@Override public SQLStatement translate(String _resultName, SQLStatement child) { resultName = subOp.getResultName(); String order = ""; resultSchema = subOp.getSchema(); List<SortCondition> conditions = opOrder.getConditions(); Iterator<SortCondition> iterator = conditions.iterator(); SortCondition current = iterator.next(); order += getOrderArg(current); while (iterator.hasNext()) { current = iterator.next(); order += ", " + getOrderArg(current); } child.addOrder(order); child.addLimit(Tags.LIMIT_LARGE_NUMBER); return child; }
private String getOrderArg(SortCondition condition) { Expr expr = condition.getExpression(); String orderArg =""; if(expr instanceof E_Function){ ExprTranslator translator = new ExprTranslator(prefixes); orderArg = translator.translate(expr, expandPrefixes,resultSchema); }else{ orderArg = expr.getVarName(); } int direction = condition.getDirection(); switch (direction) { case Query.ORDER_ASCENDING: { orderArg += " ASC"; break; } case Query.ORDER_DESCENDING: { orderArg += " DESC"; break; } case Query.ORDER_DEFAULT: { break; } } return orderArg; }
@Override public Table order(Table table, List<SortCondition> conditions) { QueryIterator qIter = table.iterator(getExecContext()) ; qIter = new QueryIterSort(qIter, conditions, getExecContext()) ; return new TableN(qIter) ; }
public Table order(Table table, List<SortCondition> conditions) ;