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

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

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

Query.getQueryPattern介绍

暂无

代码示例

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

/**
 * Get the query pattern from this where handler.
 * @return the query pattern
 */
public Element getQueryPattern()
{
   return query.getQueryPattern();
}

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

/**
 * Get the query pattern from this where handler.
 * @return the query pattern
 */
public Element getQueryPattern()
{
   return query.getQueryPattern();
}

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

@Override
public void visitQueryPattern(Query query)
{
  if ( query.getQueryPattern() != null )
    x ^= query.getQueryPattern().hashCode() ;
}

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

public static boolean tryMatchOld(Query viewQuery, Query userQuery) {
  Element viewEl = viewQuery.getQueryPattern();
  Element userEl = userQuery.getQueryPattern();
  boolean result = tryMatch(viewEl, userEl);
  return result;
}

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

@Override
public void visitQueryPattern(Query query1)
{
  if ( query1.getQueryPattern() == null &&
     query2.getQueryPattern() == null )
    return ;
  
  if ( query1.getQueryPattern() == null ) throw new ComparisonException("Missing pattern") ;
  if ( query2.getQueryPattern() == null ) throw new ComparisonException("Missing pattern") ;
  
  // The checking for patterns (elements) involves a potential
  // remapping of system-allocated variable names.
  // Assumes blank node variables only appear in patterns.
  check("Pattern", query1.getQueryPattern().equalTo(query2.getQueryPattern(), new NodeIsomorphismMap())) ;
}

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

public static Map<Var, Var> createRandomVarMap(Query query, String base) {
  Collection<Var> vars = PatternVars.vars(query.getQueryPattern());
  Generator<Var> gen = VarGeneratorBlacklist.create(base, vars);
  Map<Var, Var> varMap = vars.stream()
      .collect(Collectors.toMap(
          v -> v,
          v -> gen.next()));
  return varMap;
}

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

public static void check(Query query)
{
  if ( query.getQueryPattern() == null )
    // DESCRIBE may not have a pattern
    return ;
  check(query.getQueryPattern()) ;
  // Check this level.
  checkQueryScope(query) ;
  // Other checks.
  Collection<Var> vars = varsOfQuery(query) ;
  check(query, vars) ;
}

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

@Override
public void visit(ElementSubQuery el) {
  final Query q = el.getQuery();
  q.getQueryPattern().visit( this );
}

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

private static Collection<Var> varsOfQuery(Query query)
{
  Collection<Var> vars = PatternVars.vars(query.getQueryPattern()) ;
  if ( query.hasValues() )
    vars.addAll(query.getValuesVariables()) ;
  return vars ;
}

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

@Override
public ExtendedIterator<Quad> getQuads() {
  Query q = qb.build();
  QuadIteratorBuilder builder = new QuadIteratorBuilder(defaultGraphName);
  q.getQueryPattern().visit(builder);
  return builder.iter;
}

代码示例来源:origin: stackoverflow.com

Query query = QueryFactory.create(queryString);
query.isSelectType() && query.isQueryResultStar(); // of the form SELECT *?
query.getDatasetDescription(); // FROM / FROM NAMED bits
query.getQueryPattern(); // The meat of the query, the WHERE bit
...etc etc..
Op op = Algebra.compile(query); // Get the algebra for the query

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

public static Query transform(Query query, Map<Node, BinaryRelation> virtualPredicates, boolean cloneOnChange) {
  Element oldQueryPattern = query.getQueryPattern();
  Element newQueryPattern = transform(oldQueryPattern, virtualPredicates);
  Query result;
  if(oldQueryPattern == newQueryPattern) {
    result = query;
  } else {
    result = cloneOnChange ? query.cloneQuery() : query;
    result.setQueryPattern(newQueryPattern);
  }
  return result;
}

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

@Override
public ExtendedIterator<Quad> getQuads() {
  Query q = qb.build();
  QuadIteratorBuilder builder = new QuadIteratorBuilder(defaultGraphName);
  q.getQueryPattern().visit(builder);
  return builder.iter;
}

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

@Override
public void setVars(Map<Var, Node> values) {
  if (values.isEmpty()) {
    return;
  }
  Element e = query.getQueryPattern();
  if (e != null) {
    ElementRewriter r = new ElementRewriter(values);
    e.visit(r);
    query.setQueryPattern(r.getResult());
  }
  valuesHandler.setVars(values);
}

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

@Override
public void visit(ElementSubQuery el) {
  WhereHandler other = new WhereHandler( el.getQuery() );
  other.build();
  if (other.getElement() != el.getQuery().getQueryPattern())
  {
    el.getQuery().setQueryPattern( other.getQuery().getQueryPattern() );
  }
  result = el;
}

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

@Override
public void visit(ElementSubQuery el) {
  WhereHandler other = new WhereHandler( el.getQuery() );
  other.build();
  if (other.getElement() != el.getQuery().getQueryPattern())
  {
    el.getQuery().setQueryPattern( other.getQuery().getQueryPattern() );
  }
  result = el;
}

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

private static void test3(String pattern, String... joinForm)
{
  Query q = QueryFactory.create("PREFIX : <http://example/> SELECT * "+pattern) ;
  Op op = Algebra.compile(q.getQueryPattern()) ;
  test(op, joinForm) ;
}

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

public static Element toElement(Quad quad, Set<Set<Expr>> cnf) {
  ExprList exprs = CnfUtils.toExprList(cnf);
  BasicPattern bp = new BasicPattern();
  bp.add(quad.asTriple());
  OpQuadPattern opA = new OpQuadPattern(quad.getGraph(), bp);
  Op opB = OpFilter.filterBy(exprs, opA);
  Query query = OpAsQuery.asQuery(opB);
  Element result = query.getQueryPattern();
  return result;
}

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

private static void test4(String pattern, String... joinForm)
{
  Query q = QueryFactory.create("PREFIX : <http://example/> SELECT * "+pattern) ;
  Op op = Algebra.compile(q.getQueryPattern()) ;
  op = Algebra.toQuadForm(op) ;
  test(op, joinForm) ;
}

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

@Test public void bNodeSPARQL_Query_1() {
  String qs = "SELECT * { ?s ?p <_:ABC>}";
  Query query = QueryFactory.create(qs);
  Element el = ((ElementGroup)query.getQueryPattern()).get(0);
  ElementPathBlock epb = (ElementPathBlock)el;
  TriplePath tp = epb.getPattern().get(0);
  Triple t = tp.asTriple();
  assertEquals("ABC", t.getObject().getBlankNodeLabel());  
}

相关文章