@Override public Void visit(ListConstructor lc, Void arg) throws CompilationException { for (Expression e : lc.getExprList()) { e.accept(this, arg); } return null; }
@Override public Void visit(ListConstructor lc, Collection<VariableExpr> freeVars) throws CompilationException { visit(lc.getExprList(), freeVars); return null; }
@Override public Boolean visit(ListConstructor lc, ILangExpression arg) throws CompilationException { return visitExprList(lc.getExprList(), arg); }
@Override public Boolean visit(ListConstructor lc, ILangExpression parentSelectBlock) throws CompilationException { return visitExprList(lc.getExprList(), parentSelectBlock); }
private static IAdmNode toNode(ListConstructor listConstructor) throws CompilationException { final List<Expression> exprList = listConstructor.getExprList(); AdmArrayNode array = new AdmArrayNode(exprList.size()); for (int i = 0; i < exprList.size(); i++) { array.add(ExpressionUtils.toNode(exprList.get(i))); } return array; }
@Override public Expression visit(ListConstructor lc, ILangExpression arg) throws CompilationException { lc.setExprList(visit(lc.getExprList(), arg)); return lc; }
@Override public Void visit(ListConstructor lc, Integer step) throws CompilationException { boolean ordered = false; if (lc.getType().equals(ListConstructor.Type.ORDERED_LIST_CONSTRUCTOR)) { ordered = true; } out.print(ordered ? "[" : "{{"); printDelimitedExpressions(lc.getExprList(), COMMA, step + 2); out.print(ordered ? "]" : "}}"); return null; }
@Override public Expression visit(ListConstructor lc, ILangExpression arg) throws CompilationException { lc.setExprList(visit(lc.getExprList(), arg)); return lc; }
@Override public Boolean visit(ListConstructor lc, List<FunctionDecl> arg) throws CompilationException { Pair<Boolean, List<Expression>> p = inlineUdfsInExprList(lc.getExprList(), arg); lc.setExprList(p.second); return p.first; }
@Override public Void visit(ListConstructor lc, Integer step) throws CompilationException { boolean ordered = false; if (lc.getType().equals(ListConstructor.Type.ORDERED_LIST_CONSTRUCTOR)) { ordered = true; } out.println(skip(step) + (ordered ? "OrderedListConstructor " : "UnorderedListConstructor ") + "["); for (Expression e : lc.getExprList()) { e.accept(this, step + 1); } out.println(skip(step) + "]"); return null; }
private static AdmArrayNode parseList(ListConstructor valueExpr) throws CompilationException, 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()); } List<Expression> exprs = valueExpr.getExprList(); AdmArrayNode list = new AdmArrayNode(exprs.size()); for (Expression expr : exprs) { list.add(parseExpression(expr)); } return list; }
public static RangeMap parseHint(IParser parser) throws CompilationException { ArrayBackedValueStorage abvs = new ArrayBackedValueStorage(); DataOutput out = abvs.getDataOutput(); abvs.reset(); List<Statement> hintStatements = parser.parse(); if (hintStatements.size() != 1) { throw new CompilationException("Only one range statement is allowed for the range hint."); } // Translate the query into a Range Map if (hintStatements.get(0).getKind() != Statement.Kind.QUERY) { throw new CompilationException("Not a proper query for the range hint."); } Query q = (Query) hintStatements.get(0); if (q.getBody().getKind() != Kind.LIST_CONSTRUCTOR_EXPRESSION) { throw new CompilationException("The range hint must be a list."); } List<Expression> el = ((ListConstructor) q.getBody()).getExprList(); int[] offsets = new int[el.size()]; // Loop over list of literals for (int i = 0; i < el.size(); ++i) { Expression item = el.get(i); if (item.getKind() == Kind.LITERAL_EXPRESSION) { parseLiteralToBytes(item, out); offsets[i] = abvs.getLength(); } // TODO Add support for composite fields. } return new RangeMap(1, abvs.getByteArray(), offsets); }
@Override public ListConstructor visit(ListConstructor lc, Void arg) throws CompilationException { ListConstructor copy = new ListConstructor(lc.getType(), copyExprList(lc.getExprList(), arg)); copy.setSourceLocation(lc.getSourceLocation()); copy.addHints(lc.getHints()); return copy; }
@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); c.setSourceLocation(lc.getSourceLocation()); c.addHints(lc.getHints()); return new Pair<>(c, env); }
case LIST_CONSTRUCTOR_EXPRESSION: ListConstructor listExpr = (ListConstructor) inExpr; List<Expression> itemExprs = listExpr.getExprList(); if (itemExprs.isEmpty()) { return false;
@Override public Pair<ILogicalOperator, LogicalVariable> visit(ListConstructor lc, Mutable<ILogicalOperator> tupSource) throws CompilationException { SourceLocation sourceLoc = lc.getSourceLocation(); FunctionIdentifier fid = (lc.getType() == ListConstructor.Type.ORDERED_LIST_CONSTRUCTOR) ? BuiltinFunctions.ORDERED_LIST_CONSTRUCTOR : BuiltinFunctions.UNORDERED_LIST_CONSTRUCTOR; AbstractFunctionCallExpression f = new ScalarFunctionCallExpression(FunctionUtil.getFunctionInfo(fid)); f.setSourceLocation(sourceLoc); LogicalVariable v1 = context.newVar(); AssignOperator a = new AssignOperator(v1, new MutableObject<>(f)); a.setSourceLocation(sourceLoc); Mutable<ILogicalOperator> topOp = tupSource; for (Expression expr : lc.getExprList()) { Pair<ILogicalExpression, Mutable<ILogicalOperator>> eo = langExprToAlgExpression(expr, topOp); f.getArguments().add(new MutableObject<>(eo.first)); topOp = eo.second; } a.getInputs().add(topOp); return new Pair<>(a, v1); }
case LIST_CONSTRUCTOR_EXPRESSION: ListConstructor listExpr = (ListConstructor) inExpr; for (Expression itemExpr : listExpr.getExprList()) { IAObject inValue; switch (itemExpr.getKind()) {