org.apache.jena.sparql.algebra.Algebra.compile()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(5.8k)|赞(0)|评价(0)|浏览(89)

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

Algebra.compile介绍

[英]Compile a query - pattern and modifiers.
[中]

代码示例

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

private GraphTraversal<Vertex, ?> compile(final Query query) {
  final Op op = Algebra.compile(query);
  OpWalker.walk(op, new GremlinOpVisitor());

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

private static void outputAlgebra(ServletOutputStream outStream, final Query query, boolean lineNumbers) throws IOException
{
  outStream.println("<p>Algebra structure:</p>") ;
  final Op op = Algebra.compile(query) ;   // No optimization
  outputQueryOp(outStream, query, op, lineNumbers) ;
}

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

private static void outputAlgebra(ServletOutputStream outStream, final Query query, boolean lineNumbers) throws IOException
{
  outStream.println("<p>Algebra structure:</p>") ;
  final Op op = Algebra.compile(query) ;   // No optimization
  outputQueryOp(outStream, query, op, lineNumbers) ;
}

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

public static Op toOp(String queryStr) {
  Query query = QueryFactory.create(queryStr, Syntax.syntaxSPARQL_11);
  Op result = Algebra.compile(query);
  return result;
}

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

private static void outputAlgebraOpt(ServletOutputStream outStream, final Query query, boolean lineNumbers) throws IOException
{
  outStream.println("<p>Alebgra, with general triple optimizations:</p>") ;
  final Op op = Algebra.optimize(Algebra.compile(query)) ;
  outputQueryOp(outStream, query, op, lineNumbers) ;
}

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

public static SparqlView create(String name, QuadPattern quadPattern, Element element) {
  Op tmp = Algebra.compile(element);
  Op op = Algebra.toQuadForm(tmp);
  SparqlView result = create(name, quadPattern, op);
  return result;
}

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

public static void printOp(IndentedWriter out, Query query, boolean printOptimized)
{
  Op op = Algebra.compile(query) ;
  if ( printOptimized )
    op =  Algebra.optimize(op) ;
  WriterSSE.out(out, op, query) ;
  out.flush();
}

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

public void test_roundTripAlegbra(String query) {
  Query[] r = roundTripQuery(query);
  // Even if the strings come out as non-equal because of the translation from algebra to query
  // the algebras should be equal
  // i.e. the queries should remain semantically equivalent
  Op a1 = Algebra.compile(r[0]);
  Op a2 = Algebra.compile(r[1]);
  Assert.assertEquals(a1, a2);
}

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

public static void check(String queryString, String opExpectedString) {
  queryString = "PREFIX : <http://example/>\n" + queryString ;
  Query query = QueryFactory.create(queryString) ;
  Op opQuery = Algebra.compile(query) ;
  Op op1 = Algebra.compile(query) ;   // Safe copy
  check(opQuery, opExpectedString) ;
  assertEquals("Modification of input during optimization", op1, opQuery) ;
}

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

private static void algebraQuads(JsonBuilder obj, Query query) {
  Op op = Algebra.compile(query) ;
  op = Algebra.toQuadForm(op) ;
  obj.key(jAlgebraQuads).value(string(query, op)) ;
}

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

/** query->algebra->OpAsQuery->query **/
private static Query[] roundTripQuery(String query) {
  Query orig = QueryFactory.create(query, Syntax.syntaxSPARQL_11);
  Op toReconstruct = Algebra.compile(orig);
  Query got = OpAsQuery.asQuery(toReconstruct);
  Query[] r = { orig, got };
  return r;
}

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

private static void algebraOptQuads(JsonBuilder obj, Query query) {
  Op op = Algebra.compile(query) ;
  op = Algebra.toQuadForm(op) ;
  op = Algebra.optimize(op) ;
  obj.key(jAlgebraOptQuads).value(string(query, op)) ;
}

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

public void testOptimize(String input, String... output) {
  Query q = QueryFactory.create(input) ;
  Op op = Algebra.compile(q) ;
  check(op, StrUtils.strjoinNL(output)) ;
}

代码示例来源: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: apache/jena

/** query->algebra/quads->OpAsQuery->query */
private static Query[] roundTripQueryQuad(String query) {
  Query orig = QueryFactory.create(query, Syntax.syntaxSPARQL_11);
  Op toReconstruct = Algebra.compile(orig);
  toReconstruct = Algebra.toQuadForm(toReconstruct);
  Query got = OpAsQuery.asQuery(toReconstruct);
  Query[] r = { orig, got };
  return r;
}

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

@Test
public void testTable2() {
  // JENA-1468 : op to string and back.
  String qs = "SELECT * WHERE { ?x ?p ?z . VALUES ?y { } }" ;
  Query query = QueryFactory.create(qs); 
  Op op = Algebra.compile(query);
  String x = op.toString();
  Op op1 = SSE.parseOp(x);
  Query query2 = OpAsQuery.asQuery(op1);
  assertEquals(query, query2);
}

代码示例来源: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

private void checkRename(String queryString, String opExpectedString)
{
  Op opExpected = SSE.parseOp(opExpectedString) ;
  queryString = "PREFIX : <http://example/>\n"+queryString ;
  Query query = QueryFactory.create(queryString) ;
  Op op = Algebra.compile(query) ;
  Op opRenamed = TransformScopeRename.transform(op) ;
  assertEquals(opExpected, opRenamed) ;
}

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

private static void test(String patternString, boolean optimize, String... strExpected)
  {
    Query q = QueryFactory.create("SELECT * WHERE "+patternString) ;
    Op op = Algebra.compile(q) ;
    if ( optimize )
      op = Algebra.optimize(op) ;
    op = Algebra.toQuadForm(op) ;
    Op op2 = SSE.parseOp(StrUtils.strjoinNL(strExpected)) ;
    assertEquals(op2, op) ;
  }
}

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

@Test public void bNodeSPARQL_Query_2() {
  String qs = "SELECT * { ?s ?p <_:BCD>}";
  Query query = QueryFactory.create(qs);
  Op op = Algebra.compile(query);
  BasicPattern bp = ((OpBGP)op).getPattern();
  Triple t = bp.get(0);
  assertEquals("BCD", t.getObject().getBlankNodeLabel());  
}

相关文章