AST2BOpContext getAST2BOpContext(QueryRoot given) { return new AST2BOpContext(new ASTContainer(given), store); }
AST2BOpContext getAST2BOpContext(QueryRoot given) { return new AST2BOpContext(new ASTContainer(given), store); }
/** * Creates a {@link StaticAnalysis} object for the nodes by setting up a * SELECT query with a single {@link JoinGroupNode} comprising the nodes * in its body to retrieve the {@link StaticAnalysis} object. */ StaticAnalysis statisAnalysisForNodes(List<IGroupMemberNode> nodes) { final IGroupMemberNode[] nodesArr = nodes.toArray(new IGroupMemberNode[nodes.size()]); final JoinGroupNode jgn = (JoinGroupNode) new Helper(){{ tmp = joinGroupNode((Object[])nodesArr); }}.getTmp(); final QueryRoot queryRoot = new QueryRoot(QueryType.SELECT); queryRoot.setWhereClause(jgn); return new StaticAnalysis( queryRoot, new AST2BOpContext(new ASTContainer(queryRoot), store)); }
/** * Creates a {@link StaticAnalysis} object for the nodes by setting up a * SELECT query with a single {@link JoinGroupNode} comprising the nodes * in its body to retrieve the {@link StaticAnalysis} object. */ StaticAnalysis statisAnalysisForNodes(List<IGroupMemberNode> nodes) { final IGroupMemberNode[] nodesArr = nodes.toArray(new IGroupMemberNode[nodes.size()]); final JoinGroupNode jgn = (JoinGroupNode) new Helper(){{ tmp = joinGroupNode((Object[])nodesArr); }}.getTmp(); final QueryRoot queryRoot = new QueryRoot(QueryType.SELECT); queryRoot.setWhereClause(jgn); return new StaticAnalysis( queryRoot, new AST2BOpContext(new ASTContainer(queryRoot), store)); }
/** * Return the {@link IDescribeCache} iff it is enabled. * * @return The {@link IDescribeCache} iff enabled and otherwise * <code>null</code>. */ protected IDescribeCache getDescribeCache(final ASTContainer astContainer, final AbstractTripleStore store) { final IDescribeCache describeCache; final AST2BOpContext context = new AST2BOpContext(astContainer, store); if (context.describeCache != null && astContainer.getOriginalAST().getQueryType() == QueryType.DESCRIBE) { /* * The DESCRIBE cache is enabled. */ describeCache = context.getDescribeCache(); } else { // DESCRIBE cache is not enabled. describeCache = null; } return describeCache; }
/** * Return the {@link IDescribeCache} iff it is enabled. * * @return The {@link IDescribeCache} iff enabled and otherwise * <code>null</code>. */ protected IDescribeCache getDescribeCache(final ASTContainer astContainer, final AbstractTripleStore store) { final IDescribeCache describeCache; final AST2BOpContext context = new AST2BOpContext(astContainer, store); if (context.describeCache != null && astContainer.getOriginalAST().getQueryType() == QueryType.DESCRIBE) { /* * The DESCRIBE cache is enabled. */ describeCache = context.getDescribeCache(); } else { // DESCRIBE cache is not enabled. describeCache = null; } return describeCache; }
AST2BOpContext getAST2BOpContext(QueryRoot given) { return new AST2BOpContext(new ASTContainer(given), store); }
/** * 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)); }
/** * Creates a {@link StaticAnalysis} object for the nodes by setting up a * SELECT query with a single {@link JoinGroupNode} comprising the nodes * in its body to retrieve the {@link StaticAnalysis} object. */ StaticAnalysis statisAnalysisForNodes(List<IGroupMemberNode> nodes) { final IGroupMemberNode[] nodesArr = nodes.toArray(new IGroupMemberNode[nodes.size()]); final JoinGroupNode jgn = (JoinGroupNode) new Helper(){{ tmp = joinGroupNode((Object[])nodesArr); }}.getTmp(); final QueryRoot queryRoot = new QueryRoot(QueryType.SELECT); queryRoot.setWhereClause(jgn); return new StaticAnalysis( queryRoot, new AST2BOpContext(new ASTContainer(queryRoot), store)); }
public QueryRoot optimize(final BindingsClause bc) throws QueryEvaluationException { final QueryRoot originalQuery = astContainer.getOriginalAST(); if (bc != null) originalQuery.setBindingsClause(bc); if (getMaxQueryTime() > 0) originalQuery.setTimeout(TimeUnit.SECONDS .toMillis(getMaxQueryTime())); originalQuery.setIncludeInferred(getIncludeInferred()); final QueryRoot optimized = ASTEvalHelper.optimizeQuery( astContainer, new AST2BOpContext(astContainer, getTripleStore()), new QueryBindingSet(getBindings()), getDataset()); return optimized; }
public QueryRoot optimize(final BindingsClause bc) throws QueryEvaluationException { final QueryRoot originalQuery = astContainer.getOriginalAST(); if (bc != null) originalQuery.setBindingsClause(bc); if (getMaxQueryTime() > 0) originalQuery.setTimeout(TimeUnit.SECONDS .toMillis(getMaxQueryTime())); originalQuery.setIncludeInferred(getIncludeInferred()); final QueryRoot optimized = ASTEvalHelper.optimizeQuery( astContainer, new AST2BOpContext(astContainer, getTripleStore()), new QueryBindingSet(getBindings()), getDataset()); return optimized; }
public QueryRoot optimize(final BindingsClause bc) throws QueryEvaluationException { final QueryRoot originalQuery = astContainer.getOriginalAST(); if (bc != null) originalQuery.setBindingsClause(bc); if (getMaxQueryTime() > 0) originalQuery.setTimeout(TimeUnit.SECONDS .toMillis(getMaxQueryTime())); originalQuery.setIncludeInferred(getIncludeInferred()); final QueryRoot optimized = ASTEvalHelper.optimizeQuery( astContainer, new AST2BOpContext(astContainer, getTripleStore()), new QueryBindingSet(getBindings()), getDataset()); return optimized; }
public QueryRoot optimize(final BindingsClause bc) throws QueryEvaluationException { final QueryRoot originalQuery = astContainer.getOriginalAST(); if (bc != null) originalQuery.setBindingsClause(bc); if (getMaxQueryTime() > 0) originalQuery.setTimeout(TimeUnit.SECONDS .toMillis(getMaxQueryTime())); originalQuery.setIncludeInferred(getIncludeInferred()); final QueryRoot optimized = ASTEvalHelper.optimizeQuery( astContainer, new AST2BOpContext(astContainer, getTripleStore()), new QueryBindingSet(getBindings()), getDataset()); return optimized; }
/** * Return the {@link IDescribeCache} iff it is enabled. * * @return The {@link IDescribeCache} iff enabled and otherwise * <code>null</code>. */ protected IDescribeCache getDescribeCache(final ASTContainer astContainer, final AbstractTripleStore store) { final IDescribeCache describeCache; final AST2BOpContext context = new AST2BOpContext(astContainer, store); if (context.describeCache != null && astContainer.getOriginalAST().getQueryType() == QueryType.DESCRIBE) { /* * The DESCRIBE cache is enabled. */ describeCache = context.getDescribeCache(); } else { // DESCRIBE cache is not enabled. describeCache = null; } return describeCache; }
/** * 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)); }
@SuppressWarnings("serial") public void testNamedSubquery() { final NamedSubqueryInclude nsi = (NamedSubqueryInclude) new Helper() {{ tmp = namedSubQueryInclude("_set1"); }}.getTmp(); final QueryRoot query = (QueryRoot) new Helper(){{ tmp = select( varNodes(x,y,y), namedSubQuery("_set1",varNode(x),where(statementPatternNode(varNode(x), constantNode(a), constantNode(b),1))), where(nsi,statementPatternNode(varNode(x), constantNode(c), varNode(y),1,OPTIONAL) ) ); }}.getTmp(); final AST2BOpContext context = new AST2BOpContext(new ASTContainer(query), store); final StaticAnalysis sa = new StaticAnalysis(query, context); final Set<IVariable<?>> requiredBound = new HashSet<IVariable<?>>(); final Set<IVariable<?>> desiredBound = new HashSet<IVariable<?>>() {{ add(Var.var("x")); }}; assertEquals(requiredBound, nsi.getRequiredBound(sa)); assertEquals(desiredBound, nsi.getDesiredBound(sa)); }
@SuppressWarnings("serial") public void testNamedSubquery() { final NamedSubqueryInclude nsi = (NamedSubqueryInclude) new Helper() {{ tmp = namedSubQueryInclude("_set1"); }}.getTmp(); final QueryRoot query = (QueryRoot) new Helper(){{ tmp = select( varNodes(x,y,y), namedSubQuery("_set1",varNode(x),where(statementPatternNode(varNode(x), constantNode(a), constantNode(b),1))), where(nsi,statementPatternNode(varNode(x), constantNode(c), varNode(y),1,OPTIONAL) ) ); }}.getTmp(); final AST2BOpContext context = new AST2BOpContext(new ASTContainer(query), store); final StaticAnalysis sa = new StaticAnalysis(query, context); final Set<IVariable<?>> requiredBound = new HashSet<IVariable<?>>(); final Set<IVariable<?>> desiredBound = new HashSet<IVariable<?>>() {{ add(Var.var("x")); }}; assertEquals(requiredBound, nsi.getRequiredBound(sa)); assertEquals(desiredBound, nsi.getDesiredBound(sa)); }
new AST2BOpContext(new ASTContainer(query), store); final StaticAnalysis sa = new StaticAnalysis(query, context);
@SuppressWarnings("serial") public void testNamedSubquery() { final NamedSubqueryInclude nsi = (NamedSubqueryInclude) new Helper() {{ tmp = namedSubQueryInclude("_set1"); }}.getTmp(); final QueryRoot query = (QueryRoot) new Helper(){{ tmp = select( varNodes(x,y,y), namedSubQuery("_set1",varNode(x),where(statementPatternNode(varNode(x), constantNode(a), constantNode(b),1))), where(nsi,statementPatternNode(varNode(x), constantNode(c), varNode(y),1,OPTIONAL) ) ); }}.getTmp(); final AST2BOpContext context = new AST2BOpContext(new ASTContainer(query), store); final StaticAnalysis sa = new StaticAnalysis(query, context); final Set<IVariable<?>> requiredBound = new HashSet<IVariable<?>>(); final Set<IVariable<?>> desiredBound = new HashSet<IVariable<?>>() {{ add(Var.var("x")); }}; assertEquals(requiredBound, nsi.getRequiredBound(sa)); assertEquals(desiredBound, nsi.getDesiredBound(sa)); }