From: <tho...@us...> - 2010-12-18 14:31:30
|
Revision: 4013 http://bigdata.svn.sourceforge.net/bigdata/?rev=4013&view=rev Author: thompsonbry Date: 2010-12-18 14:31:23 +0000 (Sat, 18 Dec 2010) Log Message: ----------- Some work on optional join group support, primarily declaring the new annotations. I need to apply the annotations to the unit tests and modify the QueryEngine logic for setting up the altSink to handle the push/pop(bool:save) as indicated by the annotations. Modified Paths: -------------- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/PipelineOp.java branches/QUADS_QUERY_BRANCH/bigdata/src/test/com/bigdata/bop/engine/TestAll.java branches/QUADS_QUERY_BRANCH/bigdata/src/test/com/bigdata/bop/engine/TestQueryEngineOptionalJoins.java branches/QUADS_QUERY_BRANCH/bigdata/src/test/com/bigdata/bop/join/TestPipelineJoin.java Modified: branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/PipelineOp.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/PipelineOp.java 2010-12-17 15:05:06 UTC (rev 4012) +++ branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/PipelineOp.java 2010-12-18 14:31:23 UTC (rev 4013) @@ -30,12 +30,9 @@ import java.util.Map; import java.util.concurrent.Callable; import java.util.concurrent.FutureTask; -import java.util.concurrent.TimeUnit; import com.bigdata.bop.engine.BOpStats; import com.bigdata.bop.engine.QueryEngine; -import com.bigdata.relation.accesspath.BlockingBuffer; -import com.bigdata.relation.accesspath.IBlockingBuffer; /** * Abstract base class for pipeline operators where the data moving along the @@ -85,6 +82,48 @@ boolean DEFAULT_SHARED_STATE = false; + /** + * Annotation used to mark the set of non-optional joins which may be + * input to either the static or runtime query optimizer. Joins within a + * join graph may be freely reordered by the query optimizer in order to + * minimize the amount of work required to compute the solutions. + * <p> + * Note: Optional joins MAY NOT appear within the a join graph. Optional + * joins SHOULD be evaluated as part of the "tail plan" following the + * join graph, but before operations such as SORT, DISTINCT, etc. + * + * @todo We should be able to automatically apply the static or runtime + * query optimizers to an operator tree using this annotation to + * identify the join graphs. + */ + String JOIN_GRAPH = PipelineOp.class.getName() + ".joinGraph"; + + /** + * Annotation marks a high level join group, which may include optional + * joins. Join groups are marked in order to decide the re-entry point + * in the query plan when a join within an optional join group fails. + * Also, the top-level join group is not marked -- only nested join + * groups are marked. This is used by the decision rule to handle do + * {@link IBindingSet#push()} when entering a + * <p> + * This is different from a {@link #JOIN_GRAPH} primarily in that the + * latter may not include optional joins. + */ + String JOIN_GROUP = PipelineOp.class.getName() + ".joinGroup"; + + /** + * Annotation is used to designate the target when a join within an + * optional join group fails. The value of this annotation must be the + * {@link #JOIN_GROUP} identifier corresponding to the next join group + * in the query plan. The target join group identifier is specified + * (rather than the bopId of the target join) since the joins in the + * target join group may be reordered by the query optimizer. The entry + * point for solutions redirected to the {@link #ALT_SINK_GROUP} is + * therefore the first operator in the target {@link #JOIN_GROUP}. This + * decouples the routing decisions from the join ordering decisions. + */ + String ALT_SINK_GROUP = PipelineOp.class.getName() + ".altSinkGroup"; + } /** Modified: branches/QUADS_QUERY_BRANCH/bigdata/src/test/com/bigdata/bop/engine/TestAll.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata/src/test/com/bigdata/bop/engine/TestAll.java 2010-12-17 15:05:06 UTC (rev 4012) +++ branches/QUADS_QUERY_BRANCH/bigdata/src/test/com/bigdata/bop/engine/TestAll.java 2010-12-18 14:31:23 UTC (rev 4013) @@ -75,6 +75,9 @@ // stress test for SliceOp. suite.addTestSuite(TestQueryEngine_Slice.class); + // test suite for optional join groups. + suite.addTestSuite(TestQueryEngineOptionalJoins.class); + // @todo test suite for query evaluation (DISTINCT, ORDER BY, GROUP BY). // suite.addTestSuite(TestQueryEngine2.class); Modified: branches/QUADS_QUERY_BRANCH/bigdata/src/test/com/bigdata/bop/engine/TestQueryEngineOptionalJoins.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata/src/test/com/bigdata/bop/engine/TestQueryEngineOptionalJoins.java 2010-12-17 15:05:06 UTC (rev 4012) +++ branches/QUADS_QUERY_BRANCH/bigdata/src/test/com/bigdata/bop/engine/TestQueryEngineOptionalJoins.java 2010-12-18 14:31:23 UTC (rev 4013) @@ -28,17 +28,9 @@ package com.bigdata.bop.engine; import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; import java.util.Map; import java.util.Properties; import java.util.UUID; -import java.util.concurrent.CancellationException; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.Executor; -import java.util.concurrent.FutureTask; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; import java.util.concurrent.atomic.AtomicInteger; import junit.framework.TestCase2; @@ -62,14 +54,10 @@ import com.bigdata.bop.bindingSet.HashBindingSet; import com.bigdata.bop.bset.ConditionalRoutingOp; import com.bigdata.bop.bset.StartOp; -import com.bigdata.bop.constraint.EQ; import com.bigdata.bop.constraint.EQConstant; import com.bigdata.bop.constraint.NEConstant; -import com.bigdata.bop.fed.TestFederatedQueryEngine; import com.bigdata.bop.join.PipelineJoin; import com.bigdata.bop.solutions.SliceOp; -import com.bigdata.bop.solutions.SliceOp.SliceStats; -import com.bigdata.io.DirectBufferPoolAllocator.IAllocationContext; import com.bigdata.journal.BufferMode; import com.bigdata.journal.ITx; import com.bigdata.journal.Journal; @@ -78,16 +66,16 @@ import com.bigdata.striterator.ChunkedArrayIterator; import com.bigdata.striterator.Dechunkerator; import com.bigdata.striterator.ICloseableIterator; -import com.bigdata.util.InnerCause; -import com.bigdata.util.concurrent.LatchedExecutor; -import com.ibm.icu.impl.ByteBuffer; /** - * Test suite for the {@link QueryEngine} against a local database instance. - * <p> - * Note: The {@link BOp}s are unit tested separately. This test suite is focused - * on interactions when {@link BOp}s are chained together in a query, such as a - * sequence of pipeline joins, a slice applied to a query, etc. + * Test suite for handling of optional join groups during query evaluation + * against a local database instance. Optional join groups are handled using + * {@link IBindingSet#push()} when entering the join group and + * {@link IBindingSet#pop(boolean)} when exiting the join group. If the join + * group was successful for a given binding set, then <code>save:=true</code> is + * specified for {@link IBindingSet#pop(boolean)} and the applied bindings will + * be visible to the downstream consumer. Otherwise the bindings applied during + * the join group are simply discarded. * * <pre> * -Dlog4j.configuration=bigdata/src/resources/logging/log4j.properties @@ -95,10 +83,6 @@ * * @author <a href="mailto:tho...@us...">Bryan Thompson</a> * @version $Id: TestQueryEngine.java 3950 2010-11-17 02:14:08Z thompsonbry $ - * - * @see TestFederatedQueryEngine - * - * @todo write a unit and stress tests for deadlines. */ public class TestQueryEngineOptionalJoins extends TestCase2 { @@ -270,14 +254,14 @@ */ public void test_query_join2_optionals() throws Exception { - final int startId = 1; - final int joinId1 = 2; - final int predId1 = 3; - final int joinId2 = 4; - final int predId2 = 5; - final int joinId3 = 6; - final int predId3 = 7; - final int sliceId = 8; + final int startId = 1; // + final int joinId1 = 2; // : base join group. + final int predId1 = 3; // (a b) + final int joinId2 = 4; // : joinGroup1 + final int predId2 = 5; // (b c) + final int joinId3 = 6; // : joinGroup1 + final int predId3 = 7; // (c d) + final int sliceId = 8; // final IVariable<?> a = Var.var("a"); final IVariable<?> b = Var.var("b"); Modified: branches/QUADS_QUERY_BRANCH/bigdata/src/test/com/bigdata/bop/join/TestPipelineJoin.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata/src/test/com/bigdata/bop/join/TestPipelineJoin.java 2010-12-17 15:05:06 UTC (rev 4012) +++ branches/QUADS_QUERY_BRANCH/bigdata/src/test/com/bigdata/bop/join/TestPipelineJoin.java 2010-12-18 14:31:23 UTC (rev 4013) @@ -535,16 +535,16 @@ } - /** - * Unit tests for optional joins. For an optional join, an alternative sink - * may be specified in the {@link BOpContext}. When specified, it is used if - * the join fails (if not specified, the binding sets which do not join are - * forwarded to the primary sink). Binding sets which join go to the primary - * sink regardless. - * - * @throws ExecutionException - * @throws InterruptedException - */ + /** + * Unit tests for optional joins. For an optional join, an alternative sink + * may be specified for the join. When specified, it is used if the join + * fails (if not specified, the binding sets which do not join are forwarded + * to the primary sink). Binding sets which join go to the primary sink + * regardless. + * + * @throws ExecutionException + * @throws InterruptedException + */ public void test_optionalJoin() throws InterruptedException, ExecutionException { final Var<?> x = Var.var("x"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |