org.apache.jena.query.Query.allocAggregate()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(6.8k)|赞(0)|评价(0)|浏览(171)

本文整理了Java中org.apache.jena.query.Query.allocAggregate方法的一些代码示例,展示了Query.allocAggregate的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.allocAggregate方法的具体详情如下:
包路径:org.apache.jena.query.Query
类名称:Query
方法名:allocAggregate

Query.allocAggregate介绍

暂无

代码示例

代码示例来源:origin: apache/jena

  1. /**
  2. * Add and expression aggregator and variable to the mapping.
  3. *
  4. * if the expr parameter is not an instance of ExprAggregator then no action is taken.
  5. *
  6. * @param expr The expression to add.
  7. * @param var The variable that it is bound to.
  8. */
  9. public void add(Expr expr, Var var) {
  10. if (expr instanceof ExprAggregator)
  11. {
  12. ExprAggregator eAgg = (ExprAggregator)expr;
  13. Expr expr2 = query.allocAggregate( eAgg.getAggregator() );
  14. aggMap.put(var, (ExprAggregator)expr2);
  15. }
  16. }

代码示例来源:origin: org.apache.jena/jena-querybuilder

  1. /**
  2. * Add and expression aggregator and variable to the mapping.
  3. *
  4. * if the expr parameter is not an instance of ExprAggregator then no action is taken.
  5. *
  6. * @param expr The expression to add.
  7. * @param var The variable that it is bound to.
  8. */
  9. public void add(Expr expr, Var var) {
  10. if (expr instanceof ExprAggregator)
  11. {
  12. ExprAggregator eAgg = (ExprAggregator)expr;
  13. Expr expr2 = query.allocAggregate( eAgg.getAggregator() );
  14. aggMap.put(var, (ExprAggregator)expr2);
  15. }
  16. }

代码示例来源:origin: apache/jena

  1. /**
  2. * Add all the aggregations from the other handler.
  3. * @param handler The other handler.
  4. * @return This handler for chaining.
  5. */
  6. public AggregationHandler addAll(AggregationHandler handler)
  7. {
  8. for (ExprAggregator agg : handler.query.getAggregators())
  9. {
  10. query.allocAggregate(agg.getAggregator());
  11. }
  12. for (Map.Entry<Var, ExprAggregator> entry : handler.aggMap.entrySet())
  13. {
  14. aggMap.put( entry.getKey(), entry.getValue());
  15. }
  16. return this;
  17. }

代码示例来源:origin: org.apache.jena/jena-querybuilder

  1. /**
  2. * Add all the aggregations from the other handler.
  3. * @param handler The other handler.
  4. * @return This handler for chaining.
  5. */
  6. public AggregationHandler addAll(AggregationHandler handler)
  7. {
  8. for (ExprAggregator agg : handler.query.getAggregators())
  9. {
  10. query.allocAggregate(agg.getAggregator());
  11. }
  12. for (Map.Entry<Var, ExprAggregator> entry : handler.aggMap.entrySet())
  13. {
  14. aggMap.put( entry.getKey(), entry.getValue());
  15. }
  16. return this;
  17. }

代码示例来源:origin: apache/jena

  1. final public Expr FunctionCall() throws ParseException {
  2. String fname ; Args a ;
  3. fname = iri();
  4. a = ArgList();
  5. if ( AggregateRegistry.isRegistered(fname) ) {
  6. if ( ! getAllowAggregatesInExpressions() )
  7. throwParseException("Aggregate expression not legal at this point : "+fname, -1, -1) ;
  8. Aggregator agg = AggregatorFactory.createCustom(fname, a) ;
  9. Expr exprAgg = getQuery().allocAggregate(agg) ;
  10. {if (true) return exprAgg ;}
  11. }
  12. {if (true) return new E_Function(fname, a) ;}
  13. throw new Error("Missing return statement in function");
  14. }

代码示例来源:origin: apache/jena

  1. final public Expr FunctionCall() throws ParseException {
  2. String fname ; Args a ;
  3. fname = iri();
  4. a = ArgList();
  5. if ( AggregateRegistry.isRegistered(fname) ) {
  6. if ( ! getAllowAggregatesInExpressions() )
  7. throwParseException("Aggregate expression not legal at this point : "+fname, -1, -1) ;
  8. Aggregator agg = AggregatorFactory.createCustom(fname, a) ;
  9. Expr exprAgg = getQuery().allocAggregate(agg) ;
  10. {if (true) return exprAgg ;}
  11. }
  12. {if (true) return new E_Function(fname, a) ;}
  13. throw new Error("Missing return statement in function");
  14. }

代码示例来源:origin: org.aksw.jena-sparql-api/jena-sparql-api-mapper

  1. expr = query.allocAggregate(agg);

代码示例来源:origin: SmartDataAnalytics/jena-sparql-api

  1. expr = query.allocAggregate(agg);

代码示例来源:origin: SmartDataAnalytics/jena-sparql-api

  1. @Override
  2. public void visit(OpGroup opGroup) {
  3. List<ExprAggregator> a = opGroup.getAggregators();
  4. // Aggregators are broken up in the algebra, split between a
  5. // group and an assignment (extend or assign) using a generated var.
  6. // We record them here and insert later.
  7. for (ExprAggregator ea : a) {
  8. // Substitute generated var for actual
  9. Var givenVar = ea.getAggVar().asVar();
  10. // Copy aggregator across (?)
  11. Expr myAggr = query.allocAggregate(ea.getAggregator());
  12. varExpression.put(givenVar, myAggr);
  13. }
  14. VarExprList b = opGroup.getGroupVars();
  15. for (Var v : b.getVars()) {
  16. Expr e = b.getExpr(v);
  17. if (e != null) {
  18. query.addGroupBy(v, e);
  19. } else {
  20. query.addGroupBy(v);
  21. }
  22. }
  23. opGroup.getSubOp().visit(this);
  24. }

代码示例来源:origin: apache/jena

  1. final public Expr iriOrFunction() throws ParseException {
  2. String iri ; Args a = null ;
  3. iri = iri();
  4. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  5. case LPAREN:
  6. case NIL:
  7. a = ArgList();
  8. break;
  9. default:
  10. jj_la1[153] = jj_gen;
  11. ;
  12. }
  13. if ( a == null )
  14. {if (true) return asExpr(createNode(iri)) ;}
  15. if ( AggregateRegistry.isRegistered(iri) ) {
  16. if ( ! getAllowAggregatesInExpressions() )
  17. throwParseException("Aggregate expression not legal at this point : "+iri, -1, -1) ;
  18. Aggregator agg = AggregatorFactory.createCustom(iri, a) ;
  19. Expr exprAgg = getQuery().allocAggregate(agg) ;
  20. {if (true) return exprAgg ;}
  21. }
  22. {if (true) return new E_Function(iri, a) ;}
  23. throw new Error("Missing return statement in function");
  24. }

代码示例来源:origin: apache/jena

  1. final public Expr iriOrFunction() throws ParseException {
  2. String iri ; Args a = null ;
  3. iri = iri();
  4. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  5. case LPAREN:
  6. case NIL:
  7. a = ArgList();
  8. break;
  9. default:
  10. jj_la1[173] = jj_gen;
  11. ;
  12. }
  13. if ( a == null )
  14. {if (true) return asExpr(createNode(iri)) ;}
  15. if ( AggregateRegistry.isRegistered(iri) ) {
  16. if ( ! getAllowAggregatesInExpressions() )
  17. throwParseException("Aggregate expression not legal at this point : "+iri, -1, -1) ;
  18. Aggregator agg = AggregatorFactory.createCustom(iri, a) ;
  19. Expr exprAgg = getQuery().allocAggregate(agg) ;
  20. {if (true) return exprAgg ;}
  21. }
  22. {if (true) return new E_Function(iri, a) ;}
  23. throw new Error("Missing return statement in function");
  24. }

代码示例来源:origin: SmartDataAnalytics/jena-sparql-api

  1. public static Query createQueryCount(Query query, Var outputVar, Long itemLimit, Long rowLimit) {
  2. Query subQuery = query.cloneQuery();
  3. if(rowLimit != null) {
  4. subQuery.setDistinct(false);
  5. subQuery.setLimit(rowLimit);
  6. subQuery = QueryGenerationUtils.wrapAsSubQuery(subQuery);
  7. subQuery.setDistinct(true);
  8. }
  9. if(itemLimit != null) {
  10. subQuery.setLimit(itemLimit);
  11. }
  12. Element esq = new ElementSubQuery(subQuery);
  13. Query result = new Query();
  14. Expr aggCount = result.allocAggregate(new AggCount());
  15. result.setQuerySelectType();
  16. result.getProject().add(outputVar, aggCount);
  17. result.setQueryPattern(esq);
  18. return result;
  19. }

代码示例来源:origin: SmartDataAnalytics/jena-sparql-api

  1. public static Query spoCountTemplate(Node s, Node p, Node o)
  2. {
  3. Query query = QueryFactory.create();
  4. query.setQuerySelectType();
  5. Triple triple = new Triple(s, p, o);
  6. ElementGroup group = new ElementGroup();
  7. group.addTriplePattern(triple);
  8. query.setQueryPattern(group);
  9. if(s.isVariable()) {
  10. query.getProject().add(Var.alloc(s.getName()));
  11. }
  12. if(p.isVariable()) {
  13. query.getProject().add(Var.alloc(p.getName()));
  14. }
  15. if(o.isVariable()) {
  16. query.getProject().add(Var.alloc(o.getName()));
  17. }
  18. query.allocAggregate(new AggCount());
  19. return query;
  20. }

代码示例来源:origin: apache/jena

  1. throwParseException("Aggregate expression not legal at this point",
  2. t.beginLine, t.beginColumn) ;
  3. Expr exprAgg = getQuery().allocAggregate(agg) ;
  4. {if (true) return exprAgg ;}
  5. throw new Error("Missing return statement in function");

代码示例来源:origin: apache/jena

  1. throwParseException("Aggregate expression not legal at this point",
  2. t.beginLine, t.beginColumn) ;
  3. Expr exprAgg = getQuery().allocAggregate(agg) ;
  4. {if (true) return exprAgg ;}
  5. throw new Error("Missing return statement in function");

相关文章