Search in sources :

Example 1 with JoinRegion

use of org.teiid.query.optimizer.relational.rules.JoinRegion in project teiid by teiid.

the class TestJoinRegion method testFindJoinRegions.

public void testFindJoinRegions() {
    List regions = new ArrayList();
    PlanNode joinRoot = TestFrameUtil.getExamplePlan();
    PlanNode joinRoot1 = TestFrameUtil.getExamplePlan();
    PlanNode outerJoin = NodeFactory.getNewNode(NodeConstants.Types.JOIN);
    outerJoin.setProperty(NodeConstants.Info.JOIN_TYPE, JoinType.JOIN_LEFT_OUTER);
    outerJoin.addFirstChild(joinRoot);
    outerJoin.addFirstChild(joinRoot1);
    PlanNode source = NodeFactory.getNewNode(NodeConstants.Types.SOURCE);
    source.addFirstChild(outerJoin);
    RulePlanJoins.findJoinRegions(source, null, regions);
    assertEquals(3, regions.size());
    JoinRegion region = (JoinRegion) regions.get(0);
    // ensure that the first region is the trivial region of the outer join
    assertEquals(1, region.getJoinSourceNodes().size());
}
Also used : JoinRegion(org.teiid.query.optimizer.relational.rules.JoinRegion) PlanNode(org.teiid.query.optimizer.relational.plantree.PlanNode) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList)

Example 2 with JoinRegion

use of org.teiid.query.optimizer.relational.rules.JoinRegion in project teiid by teiid.

the class TestJoinRegion method testReconstruction.

public void testReconstruction() {
    List regions = new ArrayList();
    PlanNode joinRoot = TestFrameUtil.getExamplePlan();
    PlanNode source = NodeFactory.getNewNode(NodeConstants.Types.SOURCE);
    source.addFirstChild(joinRoot);
    RulePlanJoins.findJoinRegions(source, null, regions);
    assertEquals(1, regions.size());
    JoinRegion region = (JoinRegion) regions.get(0);
    assertEquals(3, region.getJoinSourceNodes().size());
    assertEquals(joinRoot, region.getJoinRoot());
    region.changeJoinOrder(new Object[] { new Integer(1), new Integer(0), new Integer(2) });
    region.reconstructJoinRegoin();
    PlanNode root = region.getJoinRoot();
    assertEquals(NodeConstants.Types.JOIN, root.getFirstChild().getType());
    // the tree is now left linear so go down a couple of levels to get to the first source
    assertEquals(NodeConstants.Types.SOURCE, root.getFirstChild().getFirstChild().getFirstChild().getType());
}
Also used : JoinRegion(org.teiid.query.optimizer.relational.rules.JoinRegion) PlanNode(org.teiid.query.optimizer.relational.plantree.PlanNode) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList)

Example 3 with JoinRegion

use of org.teiid.query.optimizer.relational.rules.JoinRegion in project teiid by teiid.

the class TestJoinRegion method testReconstructionOf1Source.

/**
 * Simple test to ensure that the reconstruction logic doesn't fail with a single source
 */
public void testReconstructionOf1Source() {
    PlanNode source = NodeFactory.getNewNode(NodeConstants.Types.SOURCE);
    PlanNode accessNode = NodeFactory.getNewNode(NodeConstants.Types.ACCESS);
    source.addFirstChild(accessNode);
    JoinRegion region = new JoinRegion();
    region.addJoinSourceNode(accessNode);
    region.reconstructJoinRegoin();
    assertEquals(NodeConstants.Types.ACCESS, region.getJoinRoot().getType());
}
Also used : JoinRegion(org.teiid.query.optimizer.relational.rules.JoinRegion) PlanNode(org.teiid.query.optimizer.relational.plantree.PlanNode)

Aggregations

PlanNode (org.teiid.query.optimizer.relational.plantree.PlanNode)3 JoinRegion (org.teiid.query.optimizer.relational.rules.JoinRegion)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2