From: <tho...@us...> - 2010-10-12 12:05:33
|
Revision: 3770 http://bigdata.svn.sourceforge.net/bigdata/?rev=3770&view=rev Author: thompsonbry Date: 2010-10-12 12:05:26 +0000 (Tue, 12 Oct 2010) Log Message: ----------- Fix to AbstractSubquery (UNION) to propagate an error thrown by the subquery to the parent query. Added halt(Throwable) to IRunningQuery to support this. Fixed the last four test failures for scale-out quads query. The problem was that queries which used a UNION were not wrapping the subqueries with an operator which ran on the query controller. I moved the logic to do this from BigdataEvaluationStrategyImpl into Rule2BOpUtility so that it is consistently applied each time we have to wrap a rule (as converted into a bigdata operator tree) with a SliceOp scoped to be evaluated on the query controller. Modified Paths: -------------- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/controller/AbstractSubqueryOp.java branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/engine/IRunningQuery.java branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/engine/RunningQuery.java branches/QUADS_QUERY_BRANCH/bigdata/src/test/com/bigdata/bop/engine/MockRunningQuery.java branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/BigdataEvaluationStrategyImpl.java branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/Rule2BOpUtility.java branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/tck/BigdataSparqlTest.java Modified: branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/controller/AbstractSubqueryOp.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/controller/AbstractSubqueryOp.java 2010-10-11 19:55:40 UTC (rev 3769) +++ branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/controller/AbstractSubqueryOp.java 2010-10-12 12:05:26 UTC (rev 3770) @@ -263,7 +263,8 @@ } finally { // Cancel any tasks which are still running. - cancelTasks(); + for (FutureTask<RunningQuery> ft : tasks) + ft.cancel(true/* mayInterruptIfRunning */); context.getSink().close(); @@ -275,16 +276,6 @@ } /** - * Cancel any running tasks. - */ - private void cancelTasks() { - - for (FutureTask<RunningQuery> ft : tasks) - ft.cancel(true/* mayInterruptIfRunning */); - - } - - /** * Run a subquery. * * @author <a href="mailto:tho...@us...">Bryan @@ -338,12 +329,14 @@ } catch (Throwable t) { - // If a subquery fails, then cancel all of the subqueries. - ControllerTask.this.cancelTasks(); + /* + * If a subquery fails, then propagate the error to the + * parent and rethrow the first cause error out of the + * subquery. + */ + throw new RuntimeException(ControllerTask.this.context + .getRunningQuery().halt(t)); - // rethrow the exception. - throw new RuntimeException(t); - } finally { if (subquerySolutionItr != null) Modified: branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/engine/IRunningQuery.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/engine/IRunningQuery.java 2010-10-11 19:55:40 UTC (rev 3769) +++ branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/engine/IRunningQuery.java 2010-10-12 12:05:26 UTC (rev 3770) @@ -72,4 +72,17 @@ */ void halt(); + /** + * Cancel the query (abnormal termination). + * + * @param t + * The cause. + * + * @return The first cause. + * + * @throws IllegalArgumentException + * if the argument is <code>null</code>. + */ + Throwable halt(final Throwable t); + } Modified: branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/engine/RunningQuery.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/engine/RunningQuery.java 2010-10-11 19:55:40 UTC (rev 3769) +++ branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/engine/RunningQuery.java 2010-10-12 12:05:26 UTC (rev 3770) @@ -1217,17 +1217,6 @@ } - /** - * Cancel the query (abnormal termination). - * - * @param t - * The cause. - * - * @return The first cause. - * - * @throws IllegalArgumentException - * if the argument is <code>null</code>. - */ public Throwable halt(final Throwable t) { if (t == null) Modified: branches/QUADS_QUERY_BRANCH/bigdata/src/test/com/bigdata/bop/engine/MockRunningQuery.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata/src/test/com/bigdata/bop/engine/MockRunningQuery.java 2010-10-11 19:55:40 UTC (rev 3769) +++ branches/QUADS_QUERY_BRANCH/bigdata/src/test/com/bigdata/bop/engine/MockRunningQuery.java 2010-10-12 12:05:26 UTC (rev 3770) @@ -78,6 +78,11 @@ log.warn("Mock object does not implement halt()"); } + public Throwable halt(Throwable t) { + log.warn("Mock object does not implement halt(Throwable)"); + return t; + } + public QueryEngine getQueryEngine() { throw new UnsupportedOperationException(); } Modified: branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/BigdataEvaluationStrategyImpl.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/BigdataEvaluationStrategyImpl.java 2010-10-11 19:55:40 UTC (rev 3769) +++ branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/BigdataEvaluationStrategyImpl.java 2010-10-12 12:05:26 UTC (rev 3770) @@ -54,7 +54,6 @@ import com.bigdata.BigdataStatics; import com.bigdata.bop.BOp; -import com.bigdata.bop.BOpEvaluationContext; import com.bigdata.bop.Constant; import com.bigdata.bop.HashBindingSet; import com.bigdata.bop.IBindingSet; @@ -75,7 +74,6 @@ import com.bigdata.bop.engine.QueryEngine; import com.bigdata.bop.engine.RunningQuery; import com.bigdata.bop.solutions.ISortOrder; -import com.bigdata.bop.solutions.SliceOp; import com.bigdata.btree.IRangeQuery; import com.bigdata.btree.keys.IKeyBuilderFactory; import com.bigdata.rdf.internal.DummyIV; @@ -1711,28 +1709,10 @@ */ final AtomicInteger idFactory = new AtomicInteger(0); - /* - * Convert the step to a bigdata operator tree. - */ - PipelineOp tmp = Rule2BOpUtility.convert(step, idFactory, database, + // Convert the step to a bigdata operator tree. + query = Rule2BOpUtility.convert(step, idFactory, database, queryEngine); - if (!tmp.getEvaluationContext().equals( - BOpEvaluationContext.CONTROLLER)) { - /* - * Wrap with an operator which will be evaluated on the query - * controller. - */ - tmp = new SliceOp(new BOp[] { tmp }, NV.asMap(// - new NV(BOp.Annotations.BOP_ID, idFactory - .incrementAndGet()), // - new NV(BOp.Annotations.EVALUATION_CONTEXT, - BOpEvaluationContext.CONTROLLER))); - - } - - query = tmp; - if (log.isInfoEnabled()) log.info(query); Modified: branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/Rule2BOpUtility.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/Rule2BOpUtility.java 2010-10-11 19:55:40 UTC (rev 3769) +++ branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/Rule2BOpUtility.java 2010-10-12 12:05:26 UTC (rev 3770) @@ -78,7 +78,6 @@ import com.bigdata.rdf.spo.ISPO; import com.bigdata.rdf.spo.InGraphHashSetFilter; import com.bigdata.rdf.spo.NamedGraphSolutionExpander; -import com.bigdata.rdf.spo.SPORelation; import com.bigdata.rdf.store.AbstractTripleStore; import com.bigdata.relation.IRelation; import com.bigdata.relation.accesspath.AccessPath; @@ -235,8 +234,29 @@ final AtomicInteger idFactory, final AbstractTripleStore db, final QueryEngine queryEngine) { - if (step instanceof IRule<?>) - return convert((IRule<?>) step, idFactory, db, queryEngine); + if (step instanceof IRule<?>) { + + // Convert the step to a bigdata operator tree. + PipelineOp tmp = convert((IRule<?>) step, idFactory, db, + queryEngine); + + if (!tmp.getEvaluationContext().equals( + BOpEvaluationContext.CONTROLLER)) { + /* + * Wrap with an operator which will be evaluated on the query + * controller. + */ + tmp = new SliceOp(new BOp[] { tmp }, NV.asMap(// + new NV(BOp.Annotations.BOP_ID, idFactory + .incrementAndGet()), // + new NV(BOp.Annotations.EVALUATION_CONTEXT, + BOpEvaluationContext.CONTROLLER))); + + } + + return tmp; + + } return convert((IProgram) step, idFactory, db, queryEngine); Modified: branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/tck/BigdataSparqlTest.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/tck/BigdataSparqlTest.java 2010-10-11 19:55:40 UTC (rev 3769) +++ branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/tck/BigdataSparqlTest.java 2010-10-12 12:05:26 UTC (rev 3770) @@ -35,11 +35,9 @@ import java.util.Arrays; import java.util.Collection; import java.util.Enumeration; -import java.util.Iterator; import java.util.Properties; import junit.framework.Test; -import junit.framework.TestCase; import junit.framework.TestSuite; import org.openrdf.query.Dataset; @@ -59,10 +57,6 @@ import com.bigdata.rdf.sail.BigdataSailRepository; import com.bigdata.rdf.sail.BigdataSail.Options; -import cutthecrap.utils.striterators.Expander; -import cutthecrap.utils.striterators.SingleValueIterator; -import cutthecrap.utils.striterators.Striterator; - /** * Test harness for running the SPARQL test suites. * @@ -198,22 +192,38 @@ // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/expr-equals/manifest#eq-graph-2", /* - * busted with scale-out quads query. + * busted with scale-out quads query (problem was that the + * subqueries did not have a top-level operator which ran on + * the query controller). */ // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/optional/manifest#dawg-union-001", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/graph/manifest#dawg-graph-07", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/graph/manifest#dawg-graph-11", // "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/distinct/manifest#distinct-star-1" }); + + /** + * Return the sole test in the suite associated with the specified testURI. + * + * @param suite + * The test suite. + * @param testURI + * The test URI (these are defined by the DAWG). + * + * @return An instance of this class which will run just that one test. + * + * @throws RuntimeException + * if there is no test in the suite which is associated with + * that testURI. + */ + protected static BigdataSparqlTest getSingleTest(TestSuite suite, + final String testURI) throws RuntimeException { - protected static BigdataSparqlTest getSingleTest(TestSuite suite, String testURI) throws Exception { - BigdataSparqlTest test = null; -// TestSuite suite = (TestSuite) BigdataSparqlTest.suite(false); - Enumeration e1 = suite.tests(); + final Enumeration e1 = suite.tests(); while (e1.hasMoreElements()) { suite = (TestSuite) e1.nextElement(); - Enumeration e2 = suite.tests(); + final Enumeration e2 = suite.tests(); while (e2.hasMoreElements()) { test = (BigdataSparqlTest) e2.nextElement(); if (testURI.equals(test.getTestURI())) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |