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

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

本文整理了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

/**
 * 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);
  }
}

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

/**
 * 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);
  }
}

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

/**
 * 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;
}

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

/**
 * 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;
}

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

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");
}

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

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");
}

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

expr = query.allocAggregate(agg);

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

expr = query.allocAggregate(agg);

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

@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);
}

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

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");
}

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

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");
}

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

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;
}

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

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;
}

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

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");

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

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");

相关文章