/** * Add and expression aggregator and variable to the mapping. * * if the expr parameter is not an instance of ExprAggregator then no action is taken. * * @param expr The expression to add. * @param var The variable that it is bound to. */ public void add(Expr expr, Var var) { if (expr instanceof ExprAggregator) { ExprAggregator eAgg = (ExprAggregator)expr; Expr expr2 = query.allocAggregate( eAgg.getAggregator() ); aggMap.put(var, (ExprAggregator)expr2); } }
/** * Add and expression aggregator and variable to the mapping. * * if the expr parameter is not an instance of ExprAggregator then no action is taken. * * @param expr The expression to add. * @param var The variable that it is bound to. */ public void add(Expr expr, Var var) { if (expr instanceof ExprAggregator) { ExprAggregator eAgg = (ExprAggregator)expr; Expr expr2 = query.allocAggregate( eAgg.getAggregator() ); aggMap.put(var, (ExprAggregator)expr2); } }
/** * Add all the aggregations from the other handler. * @param handler The other handler. * @return This handler for chaining. */ public AggregationHandler addAll(AggregationHandler handler) { for (ExprAggregator agg : handler.query.getAggregators()) { query.allocAggregate(agg.getAggregator()); } for (Map.Entry<Var, ExprAggregator> entry : handler.aggMap.entrySet()) { aggMap.put( entry.getKey(), entry.getValue()); } return this; }
/** * Add all the aggregations from the other handler. * @param handler The other handler. * @return This handler for chaining. */ public AggregationHandler addAll(AggregationHandler handler) { for (ExprAggregator agg : handler.query.getAggregators()) { query.allocAggregate(agg.getAggregator()); } for (Map.Entry<Var, ExprAggregator> entry : handler.aggMap.entrySet()) { aggMap.put( entry.getKey(), entry.getValue()); } return this; }
final public Expr FunctionCall() throws ParseException { String fname ; Args a ; fname = iri(); a = ArgList(); if ( AggregateRegistry.isRegistered(fname) ) { if ( ! getAllowAggregatesInExpressions() ) throwParseException("Aggregate expression not legal at this point : "+fname, -1, -1) ; Aggregator agg = AggregatorFactory.createCustom(fname, a) ; Expr exprAgg = getQuery().allocAggregate(agg) ; {if (true) return exprAgg ;} } {if (true) return new E_Function(fname, a) ;} throw new Error("Missing return statement in function"); }
final public Expr FunctionCall() throws ParseException { String fname ; Args a ; fname = iri(); a = ArgList(); if ( AggregateRegistry.isRegistered(fname) ) { if ( ! getAllowAggregatesInExpressions() ) throwParseException("Aggregate expression not legal at this point : "+fname, -1, -1) ; Aggregator agg = AggregatorFactory.createCustom(fname, a) ; Expr exprAgg = getQuery().allocAggregate(agg) ; {if (true) return exprAgg ;} } {if (true) return new E_Function(fname, a) ;} throw new Error("Missing return statement in function"); }
expr = query.allocAggregate(agg);
expr = query.allocAggregate(agg);
@Override public void visit(OpGroup opGroup) { List<ExprAggregator> a = opGroup.getAggregators(); // Aggregators are broken up in the algebra, split between a // group and an assignment (extend or assign) using a generated var. // We record them here and insert later. for (ExprAggregator ea : a) { // Substitute generated var for actual Var givenVar = ea.getAggVar().asVar(); // Copy aggregator across (?) Expr myAggr = query.allocAggregate(ea.getAggregator()); varExpression.put(givenVar, myAggr); } VarExprList b = opGroup.getGroupVars(); for (Var v : b.getVars()) { Expr e = b.getExpr(v); if (e != null) { query.addGroupBy(v, e); } else { query.addGroupBy(v); } } opGroup.getSubOp().visit(this); }
final public Expr iriOrFunction() throws ParseException { String iri ; Args a = null ; iri = iri(); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case LPAREN: case NIL: a = ArgList(); break; default: jj_la1[153] = jj_gen; ; } if ( a == null ) {if (true) return asExpr(createNode(iri)) ;} if ( AggregateRegistry.isRegistered(iri) ) { if ( ! getAllowAggregatesInExpressions() ) throwParseException("Aggregate expression not legal at this point : "+iri, -1, -1) ; Aggregator agg = AggregatorFactory.createCustom(iri, a) ; Expr exprAgg = getQuery().allocAggregate(agg) ; {if (true) return exprAgg ;} } {if (true) return new E_Function(iri, a) ;} throw new Error("Missing return statement in function"); }
final public Expr iriOrFunction() throws ParseException { String iri ; Args a = null ; iri = iri(); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case LPAREN: case NIL: a = ArgList(); break; default: jj_la1[173] = jj_gen; ; } if ( a == null ) {if (true) return asExpr(createNode(iri)) ;} if ( AggregateRegistry.isRegistered(iri) ) { if ( ! getAllowAggregatesInExpressions() ) throwParseException("Aggregate expression not legal at this point : "+iri, -1, -1) ; Aggregator agg = AggregatorFactory.createCustom(iri, a) ; Expr exprAgg = getQuery().allocAggregate(agg) ; {if (true) return exprAgg ;} } {if (true) return new E_Function(iri, a) ;} throw new Error("Missing return statement in function"); }
public static Query createQueryCount(Query query, Var outputVar, Long itemLimit, Long rowLimit) { Query subQuery = query.cloneQuery(); if(rowLimit != null) { subQuery.setDistinct(false); subQuery.setLimit(rowLimit); subQuery = QueryGenerationUtils.wrapAsSubQuery(subQuery); subQuery.setDistinct(true); } if(itemLimit != null) { subQuery.setLimit(itemLimit); } Element esq = new ElementSubQuery(subQuery); Query result = new Query(); Expr aggCount = result.allocAggregate(new AggCount()); result.setQuerySelectType(); result.getProject().add(outputVar, aggCount); result.setQueryPattern(esq); return result; }
public static Query spoCountTemplate(Node s, Node p, Node o) { Query query = QueryFactory.create(); query.setQuerySelectType(); Triple triple = new Triple(s, p, o); ElementGroup group = new ElementGroup(); group.addTriplePattern(triple); query.setQueryPattern(group); if(s.isVariable()) { query.getProject().add(Var.alloc(s.getName())); } if(p.isVariable()) { query.getProject().add(Var.alloc(p.getName())); } if(o.isVariable()) { query.getProject().add(Var.alloc(o.getName())); } query.allocAggregate(new AggCount()); return query; }
throwParseException("Aggregate expression not legal at this point", t.beginLine, t.beginColumn) ; Expr exprAgg = getQuery().allocAggregate(agg) ; {if (true) return exprAgg ;} throw new Error("Missing return statement in function");
throwParseException("Aggregate expression not legal at this point", t.beginLine, t.beginColumn) ; Expr exprAgg = getQuery().allocAggregate(agg) ; {if (true) return exprAgg ;} throw new Error("Missing return statement in function");