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

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

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

Query.hasGroupBy介绍

暂无

代码示例

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

if (!query.isQueryResultStar() && !query.hasGroupBy()) {
  final String[] all = new String[vars.size()];
  vars.toArray(all);
if (query.hasGroupBy()) {
  final VarExprList lstExpr = query.getGroupBy();
  String grpVar = "";
if (query.hasOrderBy() && query.hasGroupBy())
  orderingIndex.forEach((k, v) -> traversal = traversal.order().by(__.select(k), v));
    offset = query.getOffset();
  if (query.hasGroupBy() && query.hasOrderBy())
    traversal = traversal.range(Scope.local, offset, offset + limit);
  else

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

@Override
public void visitGroupBy(Query query)
{
  if ( query.hasGroupBy() )
    x ^= query.getGroupBy().hashCode() ;
}

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

private void findAndAddNamedVars()
  {
    Iterator<Var> varIter = null ;
    if ( hasGroupBy() )
      varIter = groupVars.getVars().iterator() ;
    else
    {
      // Binding variables -- in patterns, not in filters and not in EXISTS
      LinkedHashSet<Var> queryVars = new LinkedHashSet<>() ;
      PatternVars.vars(queryVars, this.getQueryPattern()) ;
      if ( this.hasValues() )
        queryVars.addAll(getValuesVariables()) ;
//            if ( this.hasValues() )
//                queryVars.addAll(getValuesVariables()) ;
      varIter = queryVars.iterator() ;
    }
    
    // All query variables, including ones from bNodes in the query.
    
    for ( ; varIter.hasNext() ; )
    {
      Object obj = varIter.next() ;
      //Var var = (Var)iter.next() ;
      Var var = (Var)obj ;
      if ( var.isNamedVar() )
        addResultVar(var) ;
    }
  }

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

@Override
public void visitGroupBy(Query query) {
  if (query.hasGroupBy()) {
    VarExprList x = query.getGroupBy();
    for (Var v : x.getVars()) {
      Expr expr = x.getExpr(v);
      if (expr == null)
        newQuery.addGroupBy(v);
      else
        newQuery.addGroupBy(v, expr);
    }
  }
}

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

private static void checkExprVarUse(Query query)
  if ( query.hasGroupBy() )

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

@Override
public void visitGroupBy(Query query) {
  if ( query.hasGroupBy() ) {
    VarExprList x = query.getGroupBy() ;
    for (Var v : x.getVars()) {
      Expr expr = x.getExpr(v) ;
      if ( expr == null )
        newQuery.addGroupBy(v) ;
      else
        newQuery.addGroupBy(v, expr) ;
    }
  }
}

代码示例来源:origin: org.aksw.rdfunit/rdfunit-core

@Override
  public Query getSparqlQuery(TestCase testCase) {
    String sparqlQuery = getPrefixDeclarations(testCase) +
        SELECT_CLAUSE_SIMPLE + testCase.getSparqlWhere();

    try {
      Query query = QueryFactory.create(sparqlQuery);
      if (!query.hasGroupBy()) {
        return query;
      }
    } catch (QueryParseException e) {
      throw new IllegalArgumentException("Illegal query: \n" + sparqlQuery, e);
    }

    // When we have HAVING the aggregate is calculated against the HAVING expression
    // This way we enclose the query in a sub-select and calculate the count () correctly
    // See https://issues.apache.org/jira/browse/JENA-766
    Query query = QueryFactory.create(getPrefixDeclarations(testCase) +
        SELECT_CLAUSE_GROUP_START
            + testCase.getSparqlWhere() +
        SELECT_CLAUSE_GROUP_END
    );

    return query;
  }
}

代码示例来源:origin: AKSW/RDFUnit

@Override
  public Query getSparqlQuery(TestCase testCase) {
    String sparqlQuery = getPrefixDeclarations(testCase) +
        SELECT_CLAUSE_SIMPLE + testCase.getSparqlWhere();

    try {
      Query query = QueryFactory.create(sparqlQuery);
      if (!query.hasGroupBy()) {
        return query;
      }
    } catch (QueryParseException e) {
      throw new IllegalArgumentException("Illegal query: \n" + sparqlQuery, e);
    }

    // When we have HAVING the aggregate is calculated against the HAVING expression
    // This way we enclose the query in a sub-select and calculate the count () correctly
    // See https://issues.apache.org/jira/browse/JENA-766
    Query query = QueryFactory.create(getPrefixDeclarations(testCase) +
        SELECT_CLAUSE_GROUP_START
            + testCase.getSparqlWhere() +
        SELECT_CLAUSE_GROUP_END
    );

    return query;
  }
}

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

@Override
public void visitGroupBy(Query query)
{
  if ( query.hasGroupBy() )
  {
    // Can have an empty GROUP BY list if the groupin gis implicit
    // by use of an aggregate in the SELECT clause.
    if ( ! query.getGroupBy().isEmpty() )
    {
      out.print("GROUP BY ") ;
      appendNamedExprList(query, out, query.getGroupBy()) ;
      out.println();
    }
  }
}

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

private static void check(Query query, Collection<Var> vars)
{
  // Check any expressions are assigned to fresh variables.
  checkExprListAssignment(vars, query.getProject()) ;
  
  // Check for SELECT * GROUP BY
  // Legal in ARQ, not in SPARQL 1.1
  if ( ! Syntax.syntaxARQ.equals(query.getSyntax()) )
  {
    if ( query.isQueryResultStar() && query.hasGroupBy() )
      throw new QueryParseException("SELECT * not legal with GROUP BY", -1 , -1) ;
  }
  
  // Check any variable in an expression is in scope (if GROUP BY) 
  checkExprVarUse(query) ;
  
  // Check GROUP BY AS 
  // ENABLE
  if ( false && query.hasGroupBy() )
  {
    VarExprList exprList2 = query.getGroupBy() ;
    checkExprListAssignment(vars, exprList2) ;
  // CHECK 
  }
  
}

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

if ( query.hasGroupBy() )

相关文章