use of org.apache.asterix.lang.common.base.Expression in project asterixdb by apache.
the class CloneAndSubstituteVariablesVisitor method visit.
@Override
public Pair<ILangExpression, VariableSubstitutionEnvironment> visit(ListConstructor lc, VariableSubstitutionEnvironment env) throws CompilationException {
List<Expression> oldExprList = lc.getExprList();
List<Expression> exprs = VariableCloneAndSubstitutionUtil.visitAndCloneExprList(oldExprList, env, this);
ListConstructor c = new ListConstructor(lc.getType(), exprs);
return new Pair<>(c, env);
}
use of org.apache.asterix.lang.common.base.Expression in project asterixdb by apache.
the class CloneAndSubstituteVariablesVisitor method visit.
@Override
public Pair<ILangExpression, VariableSubstitutionEnvironment> visit(OperatorExpr op, VariableSubstitutionEnvironment env) throws CompilationException {
List<Expression> oldExprList = op.getExprList();
List<Expression> exprs = new ArrayList<>(oldExprList.size());
for (Expression e : oldExprList) {
Pair<ILangExpression, VariableSubstitutionEnvironment> p1 = e.accept(this, env);
exprs.add((Expression) p1.first);
}
OperatorExpr oe = new OperatorExpr(exprs, op.getExprBroadcastIdx(), op.getOpList(), op.isCurrentop());
return new Pair<>(oe, env);
}
use of org.apache.asterix.lang.common.base.Expression in project asterixdb by apache.
the class FormatPrintVisitor method visit.
@Override
public Void visit(OperatorExpr operatorExpr, Integer step) throws CompilationException {
List<Expression> exprList = operatorExpr.getExprList();
List<OperatorType> opList = operatorExpr.getOpList();
if (operatorExpr.isCurrentop()) {
out.print("(");
exprList.get(0).accept(this, step + 1);
for (int i = 1; i < exprList.size(); i++) {
OperatorType opType = opList.get(i - 1);
;
if (i == 1) {
printHints(operatorExpr.getHints(), step + 1);
}
out.print(" " + opType + " ");
exprList.get(i).accept(this, step + 1);
}
out.print(")");
} else {
exprList.get(0).accept(this, step);
}
return null;
}
use of org.apache.asterix.lang.common.base.Expression in project asterixdb by apache.
the class FormatPrintVisitor method visit.
@Override
public Void visit(GroupbyClause gc, Integer step) throws CompilationException {
if (gc.hasHashGroupByHint()) {
out.println(skip(step) + "/* +hash */");
}
out.print(skip(step) + "group by ");
printDelimitedGbyExpressions(gc.getGbyPairList(), step + 2);
if (gc.hasDecorList()) {
out.print(" decor ");
printDelimitedGbyExpressions(gc.getDecorPairList(), step + 2);
}
if (gc.hasWithMap()) {
out.print(" with ");
Map<Expression, VariableExpr> withVarMap = gc.getWithVarMap();
int index = 0;
int size = withVarMap.size();
for (Entry<Expression, VariableExpr> entry : withVarMap.entrySet()) {
Expression key = entry.getKey();
VariableExpr value = entry.getValue();
key.accept(this, step + 2);
if (!key.equals(value)) {
out.print(" as ");
value.accept(this, step + 2);
}
if (++index < size) {
out.print(COMMA);
}
}
}
out.println();
return null;
}
use of org.apache.asterix.lang.common.base.Expression in project asterixdb by apache.
the class LangRecordParseUtil method parseList.
private static void parseList(ListConstructor valueExpr, ArrayBackedValueStorage serialized) throws HyracksDataException {
if (valueExpr.getType() != ListConstructor.Type.ORDERED_LIST_CONSTRUCTOR) {
throw new HyracksDataException(ErrorCode.ASTERIX, ErrorCode.PARSE_ERROR, "JSON List can't be of type %1$s", valueExpr.getType());
}
ArrayBackedValueStorage serializedValue = new ArrayBackedValueStorage();
OrderedListBuilder listBuilder = new OrderedListBuilder();
listBuilder.reset(null);
for (Expression expr : valueExpr.getExprList()) {
serializedValue.reset();
parseExpression(expr, serializedValue);
listBuilder.addItem(serializedValue);
}
listBuilder.write(serialized.getDataOutput(), true);
}
Aggregations