/** * {@inheritDoc} * <p> * The use of the alternative {@link #parseQuery2(String, String)} is * strongly encouraged. * * @return An object which aligns the {@link ASTContainer} with the * {@link ParsedQuery} interface. */ @Override public BigdataParsedQuery parseQuery(final String queryStr, final String baseURI) throws MalformedQueryException { return new BigdataParsedQuery(parseQuery2(queryStr, baseURI)); }
/** * {@inheritDoc} * <p> * The use of the alternative {@link #parseQuery2(String, String)} is * strongly encouraged. * * @return An object which aligns the {@link ASTContainer} with the * {@link ParsedQuery} interface. */ @Override public BigdataParsedQuery parseQuery(final String queryStr, final String baseURI) throws MalformedQueryException { return new BigdataParsedQuery(parseQuery2(queryStr, baseURI)); }
/** * Applies the {@link Bigdata2ASTSPARQLParser}. */ public QueryRoot parse(final String queryStr, final String baseURI) throws MalformedQueryException { final Bigdata2ASTSPARQLParser parser = new Bigdata2ASTSPARQLParser(); final ASTContainer astContainer = parser.parseQuery2(queryStr, baseURI); ASTDeferredIVResolution.resolveQuery(tripleStore, astContainer); final QueryRoot ast = astContainer.getOriginalAST(); final Collection<ValueExpressionNode> nodes = new LinkedList<ValueExpressionNode>(); final Iterator<ValueExpressionNode> itr = BOpUtility.visitAll( ast, ValueExpressionNode.class); while (itr.hasNext()) { final ValueExpressionNode node = itr.next(); nodes.add(node); } for (ValueExpressionNode node : nodes) { node.invalidate(); } return ast; }
/** * Applies the {@link Bigdata2ASTSPARQLParser}. */ public QueryRoot parse(final String queryStr, final String baseURI) throws MalformedQueryException { final Bigdata2ASTSPARQLParser parser = new Bigdata2ASTSPARQLParser(); final ASTContainer astContainer = parser.parseQuery2(queryStr, baseURI); ASTDeferredIVResolution.resolveQuery(tripleStore, astContainer); final QueryRoot ast = astContainer.getOriginalAST(); final Collection<ValueExpressionNode> nodes = new LinkedList<ValueExpressionNode>(); final Iterator<ValueExpressionNode> itr = BOpUtility.visitAll( ast, ValueExpressionNode.class); while (itr.hasNext()) { final ValueExpressionNode node = itr.next(); nodes.add(node); } for (ValueExpressionNode node : nodes) { node.invalidate(); } return ast; }
private TupleQueryResult executeSelect(String sparql) throws QueryEvaluationException, MalformedQueryException { String prefixes = sparqlPrefixes(); astContainer = new Bigdata2ASTSPARQLParser().parseQuery2(prefixes+sparql, FILL_IN_URI); return ASTEvalHelper.evaluateTupleQuery(store, astContainer, new QueryBindingSet(), null /* dataset */); }
private TupleQueryResult executeSelect(String sparql) throws QueryEvaluationException, MalformedQueryException { String prefixes = sparqlPrefixes(); astContainer = new Bigdata2ASTSPARQLParser().parseQuery2(prefixes+sparql, FILL_IN_URI); return ASTEvalHelper.evaluateTupleQuery(store, astContainer, new QueryBindingSet(), null /* dataset */); }
/** * Unit test of static analysis for variables which must be bound by a * query. This involves checking the WHERE clause and the projection for the * query. * * @throws MalformedQueryException */ public void test_static_analysis01() throws MalformedQueryException { final String queryStr = "" + "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n"+ "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n"+ "PREFIX foaf: <http://xmlns.com/foaf/0.1/> \n"+ "select ?x where { ?x rdf:type foaf:Person }"; final QueryRoot queryRoot = new Bigdata2ASTSPARQLParser() .parseQuery2(queryStr, baseURI).getOriginalAST(); final StaticAnalysis sa = new StaticAnalysis(queryRoot); final Set<IVariable<?>> expected = new LinkedHashSet<IVariable<?>>(); expected.add(Var.var("x")); assertEquals(expected, sa.getDefinitelyProducedBindings(queryRoot)); assertEquals( expected, sa.getDefinitelyProducedBindings(queryRoot.getWhereClause(), new LinkedHashSet<IVariable<?>>(), true/* recursive */)); }
/** * Unit test of static analysis for variables which must be bound by a * query. This involves checking the WHERE clause and the projection for the * query. * * @throws MalformedQueryException */ public void test_static_analysis01() throws MalformedQueryException { final String queryStr = "" + "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n"+ "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n"+ "PREFIX foaf: <http://xmlns.com/foaf/0.1/> \n"+ "select ?x where { ?x rdf:type foaf:Person }"; final QueryRoot queryRoot = new Bigdata2ASTSPARQLParser() .parseQuery2(queryStr, baseURI).getOriginalAST(); final StaticAnalysis sa = new StaticAnalysis(queryRoot); final Set<IVariable<?>> expected = new LinkedHashSet<IVariable<?>>(); expected.add(Var.var("x")); assertEquals(expected, sa.getDefinitelyProducedBindings(queryRoot)); assertEquals( expected, sa.getDefinitelyProducedBindings(queryRoot.getWhereClause(), new LinkedHashSet<IVariable<?>>(), true/* recursive */)); }
/** * Applies the {@link Bigdata2ASTSPARQLParser}. */ public QueryRoot parse(final String queryStr, final String baseURI) throws MalformedQueryException { final Bigdata2ASTSPARQLParser parser = new Bigdata2ASTSPARQLParser(); final ASTContainer astContainer = parser.parseQuery2(queryStr, baseURI); ASTDeferredIVResolution.resolveQuery(tripleStore, astContainer); final QueryRoot ast = astContainer.getOriginalAST(); final Collection<ValueExpressionNode> nodes = new LinkedList<ValueExpressionNode>(); final Iterator<ValueExpressionNode> itr = BOpUtility.visitAll( ast, ValueExpressionNode.class); while (itr.hasNext()) { final ValueExpressionNode node = itr.next(); nodes.add(node); } for (ValueExpressionNode node : nodes) { node.invalidate(); } return ast; }
private CloseableIteration<? extends BindingSet, QueryEvaluationException> evaluate(final String query, final SailConnection con, final BindingSet bs) throws Exception { // new pattern ((BigdataSailConnection) con).flush(); final AbstractTripleStore db = ((BigdataSailConnection) con).getTripleStore(); final ASTContainer astContainer = new Bigdata2ASTSPARQLParser().parseQuery2(query, null); final QueryRoot originalQuery = astContainer.getOriginalAST(); originalQuery.setIncludeInferred(false); final TupleQueryResult queryResult = ASTEvalHelper.evaluateTupleQuery( db, astContainer, new QueryBindingSet( bs), null /* dataset */); return queryResult; }
/** * A unit test where two nested graph groups have the same URI as their * context. This case is legal and there is nothing that needs to be changed * in the AST for enforce the graph context constraint. * * @throws MalformedQueryException */ public void test_graphContexts_constants_legal() throws MalformedQueryException { final String queryStr = ""// + "PREFIX : <http://example.org/>\n"// + "SELECT ?s\n"// + "WHERE {\n"// + " GRAPH :foo {\n"// + " ?s :p :o .\n"// + " GRAPH :foo { ?o :p2 ?s }\n"// + " }\n"// + "}"; final ASTContainer astContainer = new Bigdata2ASTSPARQLParser() .parseQuery2(queryStr, baseURI); final AST2BOpContext context = new AST2BOpContext(astContainer, store); new ASTGraphGroupOptimizer().optimize(context, new QueryNodeWithBindingSet(astContainer.getOriginalAST(), null)); }
/** * A unit test where two nested graph groups have the same URI as their * context. This case is legal and there is nothing that needs to be changed * in the AST for enforce the graph context constraint. * * @throws MalformedQueryException */ public void test_graphContexts_constants_legal() throws MalformedQueryException { final String queryStr = ""// + "PREFIX : <http://example.org/>\n"// + "SELECT ?s\n"// + "WHERE {\n"// + " GRAPH :foo {\n"// + " ?s :p :o .\n"// + " GRAPH :foo { ?o :p2 ?s }\n"// + " }\n"// + "}"; final ASTContainer astContainer = new Bigdata2ASTSPARQLParser() .parseQuery2(queryStr, baseURI); final AST2BOpContext context = new AST2BOpContext(astContainer, store); new ASTGraphGroupOptimizer().optimize(context, new QueryNodeWithBindingSet(astContainer.getOriginalAST(), null)); }
private TupleQueryResult executeSelect(String sparql) throws QueryEvaluationException, MalformedQueryException { String prefixes = sparqlPrefixes(); astContainer = new Bigdata2ASTSPARQLParser().parseQuery2(prefixes+sparql, FILL_IN_URI); return ASTEvalHelper.evaluateTupleQuery(store, astContainer, new QueryBindingSet(), null /* dataset */); }
.parseQuery2(queryStr, baseURI);
.parseQuery2(queryStr, baseURI);
.parseQuery2(queryStr, baseURI).getOriginalAST();
/** * Unit test of static analysis for variables which must be bound by a * query. This involves checking the WHERE clause and the projection for the * query. * * @throws MalformedQueryException */ public void test_static_analysis01() throws MalformedQueryException { final String queryStr = "" + "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n"+ "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n"+ "PREFIX foaf: <http://xmlns.com/foaf/0.1/> \n"+ "select ?x where { ?x rdf:type foaf:Person }"; final QueryRoot queryRoot = new Bigdata2ASTSPARQLParser() .parseQuery2(queryStr, baseURI).getOriginalAST(); final StaticAnalysis sa = new StaticAnalysis(queryRoot); final Set<IVariable<?>> expected = new LinkedHashSet<IVariable<?>>(); expected.add(Var.var("x")); assertEquals(expected, sa.getDefinitelyProducedBindings(queryRoot)); assertEquals( expected, sa.getDefinitelyProducedBindings(queryRoot.getWhereClause(), new LinkedHashSet<IVariable<?>>(), true/* recursive */)); }
private CloseableIteration<? extends BindingSet, QueryEvaluationException> evaluate(final String query, final SailConnection con, final BindingSet bs) throws Exception { // new pattern ((BigdataSailConnection) con).flush(); final AbstractTripleStore db = ((BigdataSailConnection) con).getTripleStore(); final ASTContainer astContainer = new Bigdata2ASTSPARQLParser().parseQuery2(query, null); final QueryRoot originalQuery = astContainer.getOriginalAST(); originalQuery.setIncludeInferred(false); final TupleQueryResult queryResult = ASTEvalHelper.evaluateTupleQuery( db, astContainer, new QueryBindingSet( bs), null /* dataset */); return queryResult; }
/** * A unit test where two nested graph groups have the same URI as their * context. This case is legal and there is nothing that needs to be changed * in the AST for enforce the graph context constraint. * * @throws MalformedQueryException */ public void test_graphContexts_constants_legal() throws MalformedQueryException { final String queryStr = ""// + "PREFIX : <http://example.org/>\n"// + "SELECT ?s\n"// + "WHERE {\n"// + " GRAPH :foo {\n"// + " ?s :p :o .\n"// + " GRAPH :foo { ?o :p2 ?s }\n"// + " }\n"// + "}"; final ASTContainer astContainer = new Bigdata2ASTSPARQLParser() .parseQuery2(queryStr, baseURI); final AST2BOpContext context = new AST2BOpContext(astContainer, store); new ASTGraphGroupOptimizer().optimize(context, new QueryNodeWithBindingSet(astContainer.getOriginalAST(), null)); }
.parseQuery2(queryStr, baseURI);