|
From: <mrp...@us...> - 2014-05-20 18:55:47
|
Revision: 8386
http://sourceforge.net/p/bigdata/code/8386
Author: mrpersonick
Date: 2014-05-20 18:55:44 +0000 (Tue, 20 May 2014)
Log Message:
-----------
added a means of just running the AST optimizers without actually running the query
Modified Paths:
--------------
branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/eval/ASTEvalHelper.java
branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/java/com/bigdata/rdf/sail/BigdataSailTupleQuery.java
Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/eval/ASTEvalHelper.java
===================================================================
--- branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/eval/ASTEvalHelper.java 2014-05-20 17:13:40 UTC (rev 8385)
+++ branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/eval/ASTEvalHelper.java 2014-05-20 18:55:44 UTC (rev 8386)
@@ -411,7 +411,53 @@
}
}
+
+ /**
+ * Optimize a SELECT query.
+ *
+ * @param store
+ * The {@link AbstractTripleStore} having the data.
+ * @param queryPlan
+ * The {@link ASTContainer}.
+ * @param bs
+ * The initial solution to kick things off.
+ *
+ * @return An optimized AST.
+ *
+ * @throws QueryEvaluationException
+ */
+ static public QueryRoot optimizeTupleQuery(
+ final AbstractTripleStore store, final ASTContainer astContainer,
+ final QueryBindingSet bs) throws QueryEvaluationException {
+ final AST2BOpContext context = new AST2BOpContext(astContainer, store);
+
+ // Clear the optimized AST.
+ astContainer.clearOptimizedAST();
+
+ // Batch resolve Values to IVs and convert to bigdata binding set.
+ final IBindingSet[] bindingSets = mergeBindingSets(astContainer,
+ batchResolveIVs(store, bs));
+
+ // Convert the query (generates an optimized AST as a side-effect).
+ AST2BOpUtility.convert(context, bindingSets);
+
+ // Get the projection for the query.
+ final IVariable<?>[] projected = astContainer.getOptimizedAST()
+ .getProjection().getProjectionVars();
+
+ final List<String> projectedSet = new LinkedList<String>();
+
+ for (IVariable<?> var : projected)
+ projectedSet.add(var.getName());
+
+ // The optimized AST.
+ final QueryRoot optimizedQuery = astContainer.getOptimizedAST();
+
+ return optimizedQuery;
+
+ }
+
/**
* Evaluate a CONSTRUCT/DESCRIBE query.
* <p>
Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/java/com/bigdata/rdf/sail/BigdataSailTupleQuery.java
===================================================================
--- branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/java/com/bigdata/rdf/sail/BigdataSailTupleQuery.java 2014-05-20 17:13:40 UTC (rev 8385)
+++ branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/java/com/bigdata/rdf/sail/BigdataSailTupleQuery.java 2014-05-20 18:55:44 UTC (rev 8386)
@@ -98,4 +98,32 @@
}
+ public QueryRoot optimize() throws QueryEvaluationException {
+
+ return optimize((BindingsClause) null);
+
+ }
+
+ 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.optimizeTupleQuery(
+ getTripleStore(), astContainer, new QueryBindingSet(
+ getBindings()));
+
+ return optimized;
+
+ }
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|