Search in sources :

Example 16 with SendPlanNode

use of org.voltdb.plannodes.SendPlanNode in project voltdb by VoltDB.

the class TestWindowedFunctions method validateQueryWithSubquery.

/**
     * Validate that each similar windowed query in testRankWithSubqueries
     * produces a similar plan
     * @param windowedQuery a variant of a test query of a known basic format
     **/
private void validateQueryWithSubquery(String windowedQuery, boolean waiveAliasMatch) {
    AbstractPlanNode node = compile(windowedQuery);
    // Dissect the plan.
    assertTrue(node instanceof SendPlanNode);
    AbstractPlanNode projectionPlanNode = node.getChild(0);
    assertTrue(projectionPlanNode instanceof ProjectionPlanNode);
    AbstractPlanNode partitionByPlanNode = projectionPlanNode.getChild(0);
    assertTrue(partitionByPlanNode instanceof WindowFunctionPlanNode);
    AbstractPlanNode orderByPlanNode = partitionByPlanNode.getChild(0);
    assertTrue(orderByPlanNode instanceof OrderByPlanNode);
    NodeSchema input_schema = orderByPlanNode.getOutputSchema();
    AbstractPlanNode scanNode = orderByPlanNode.getChild(0);
    assertTrue(scanNode instanceof NestLoopPlanNode);
    NodeSchema schema = partitionByPlanNode.getOutputSchema();
    SchemaColumn column = schema.getColumns().get(0);
    assertEquals("ARANK", column.getColumnAlias());
    validateTVEs(input_schema, (WindowFunctionPlanNode) partitionByPlanNode, waiveAliasMatch);
}
Also used : AbstractPlanNode(org.voltdb.plannodes.AbstractPlanNode) OrderByPlanNode(org.voltdb.plannodes.OrderByPlanNode) SendPlanNode(org.voltdb.plannodes.SendPlanNode) WindowFunctionPlanNode(org.voltdb.plannodes.WindowFunctionPlanNode) SchemaColumn(org.voltdb.plannodes.SchemaColumn) NestLoopPlanNode(org.voltdb.plannodes.NestLoopPlanNode) NodeSchema(org.voltdb.plannodes.NodeSchema) ProjectionPlanNode(org.voltdb.plannodes.ProjectionPlanNode)

Example 17 with SendPlanNode

use of org.voltdb.plannodes.SendPlanNode in project voltdb by VoltDB.

the class testPlannerTester method testWriteAndLoad.

public void testWriteAndLoad() throws Exception {
    AbstractPlanNode pn = null;
    plannerTester.setUpForTest(m_currentDir + "tests/frontend/org/voltdb/planner/testplans-plannerTester-ddl.sql", "testplans-plannerTester-ddl");
    List<AbstractPlanNode> pnList = plannerTester.testCompile("select * from l, t where t.a=l.a limit ?;");
    System.out.println(pnList.size());
    pn = pnList.get(0);
    assert (pnList.get(1) instanceof SendPlanNode);
    pn.reattachFragment(pnList.get(1));
    System.out.println(pn.toJSONString());
    System.out.println(pn.toExplainPlanString());
    plannerTester.writePlanToFile(pn, m_homeDir, "prettyJson.txt", "");
    ArrayList<String> getsql = new ArrayList<String>();
    AbstractPlanNode pn2 = plannerTester.loadPlanFromFile(m_homeDir + "prettyJson.txt", getsql);
    System.out.println(pn2.toExplainPlanString());
    ArrayList<AbstractPlanNode> list1 = pn.getPlanNodeList();
    ArrayList<AbstractPlanNode> list2 = pn2.getPlanNodeList();
    assertTrue(list1.size() == list2.size());
    for (int i = 0; i < list1.size(); i++) {
        Map<PlanNodeType, AbstractPlanNode> inlineNodes1 = list1.get(i).getInlinePlanNodes();
        Map<PlanNodeType, AbstractPlanNode> inlineNodes2 = list2.get(i).getInlinePlanNodes();
        if (inlineNodes1 != null) {
            assertTrue(inlineNodes1.size() == inlineNodes2.size());
        }
    }
}
Also used : AbstractPlanNode(org.voltdb.plannodes.AbstractPlanNode) PlanNodeType(org.voltdb.types.PlanNodeType) SendPlanNode(org.voltdb.plannodes.SendPlanNode) ArrayList(java.util.ArrayList)

Example 18 with SendPlanNode

use of org.voltdb.plannodes.SendPlanNode in project voltdb by VoltDB.

the class testPlannerTester method testReAttachFragments.

public void testReAttachFragments() {
    try {
        plannerTester.setUpForTest(m_currentDir + "tests/frontend/org/voltdb/planner/testplans-plannerTester-ddl.sql", "testplans-plannerTester-ddl");
        List<AbstractPlanNode> pnList = plannerTester.testCompile("select * from l, t where t.a=l.a limit ?;");
        System.out.println(pnList.size());
        System.out.println(pnList.get(0).toExplainPlanString());
        assert (pnList.size() == 2);
        assert (pnList.get(1) instanceof SendPlanNode);
        if (pnList.get(0).reattachFragment(pnList.get(1))) {
            AbstractPlanNode pn = pnList.get(0);
            System.out.println(pn.toExplainPlanString());
            assertTrue(pn.toExplainPlanString().contains("SEND PARTITION RESULTS TO COORDINATOR"));
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : AbstractPlanNode(org.voltdb.plannodes.AbstractPlanNode) SendPlanNode(org.voltdb.plannodes.SendPlanNode) FileNotFoundException(java.io.FileNotFoundException) JSONException(org.json_voltpatches.JSONException)

Example 19 with SendPlanNode

use of org.voltdb.plannodes.SendPlanNode in project voltdb by VoltDB.

the class PlanAssembler method handleMVBasedMultiPartQuery.

private AbstractPlanNode handleMVBasedMultiPartQuery(HashAggregatePlanNode reAggNode, AbstractPlanNode root, boolean edgeCaseOuterJoin) {
    MaterializedViewFixInfo mvFixInfo = m_parsedSelect.m_mvFixInfo;
    AbstractPlanNode receiveNode = root;
    AbstractPlanNode reAggParent = null;
    // re-aggregation plan node.
    if (root instanceof AbstractReceivePlanNode) {
        root = reAggNode;
    } else {
        List<AbstractPlanNode> recList = root.findAllNodesOfClass(AbstractReceivePlanNode.class);
        assert (recList.size() == 1);
        receiveNode = recList.get(0);
        reAggParent = receiveNode.getParent(0);
        boolean result = reAggParent.replaceChild(receiveNode, reAggNode);
        assert (result);
    }
    reAggNode.addAndLinkChild(receiveNode);
    reAggNode.m_isCoordinatingAggregator = true;
    assert (receiveNode instanceof ReceivePlanNode);
    AbstractPlanNode sendNode = receiveNode.getChild(0);
    assert (sendNode instanceof SendPlanNode);
    AbstractPlanNode sendNodeChild = sendNode.getChild(0);
    HashAggregatePlanNode reAggNodeForReplace = null;
    if (m_parsedSelect.m_tableList.size() > 1 && !edgeCaseOuterJoin) {
        reAggNodeForReplace = reAggNode;
    }
    boolean find = mvFixInfo.processScanNodeWithReAggNode(sendNode, reAggNodeForReplace);
    assert (find);
    // receive node with materialized view scan node.
    if (m_parsedSelect.m_tableList.size() > 1 && !edgeCaseOuterJoin) {
        AbstractPlanNode joinNode = sendNodeChild;
        // No agg, limit pushed down at this point.
        assert (joinNode instanceof AbstractJoinPlanNode);
        // Fix the node after Re-aggregation node.
        joinNode.clearParents();
        assert (mvFixInfo.m_scanNode != null);
        mvFixInfo.m_scanNode.clearParents();
        // replace joinNode with MV scan node on each partition.
        sendNode.clearChildren();
        sendNode.addAndLinkChild(mvFixInfo.m_scanNode);
        // its parent will be the parent of the new join node. Update the root node.
        if (reAggParent != null) {
            reAggParent.replaceChild(reAggNode, joinNode);
            root = reAggParent;
        } else {
            root = joinNode;
        }
    }
    return root;
}
Also used : AbstractPlanNode(org.voltdb.plannodes.AbstractPlanNode) AbstractReceivePlanNode(org.voltdb.plannodes.AbstractReceivePlanNode) SendPlanNode(org.voltdb.plannodes.SendPlanNode) AbstractReceivePlanNode(org.voltdb.plannodes.AbstractReceivePlanNode) MergeReceivePlanNode(org.voltdb.plannodes.MergeReceivePlanNode) ReceivePlanNode(org.voltdb.plannodes.ReceivePlanNode) AbstractJoinPlanNode(org.voltdb.plannodes.AbstractJoinPlanNode) HashAggregatePlanNode(org.voltdb.plannodes.HashAggregatePlanNode)

Example 20 with SendPlanNode

use of org.voltdb.plannodes.SendPlanNode in project voltdb by VoltDB.

the class PlanAssembler method removeCoordinatorSendReceivePairRecursive.

private static AbstractPlanNode removeCoordinatorSendReceivePairRecursive(AbstractPlanNode root, AbstractPlanNode current) {
    if (current instanceof AbstractReceivePlanNode) {
        assert (current.getChildCount() == 1);
        AbstractPlanNode child = current.getChild(0);
        assert (child instanceof SendPlanNode);
        assert (child.getChildCount() == 1);
        child = child.getChild(0);
        child.clearParents();
        if (current == root) {
            return child;
        }
        assert (current.getParentCount() == 1);
        AbstractPlanNode parent = current.getParent(0);
        parent.unlinkChild(current);
        parent.addAndLinkChild(child);
        return root;
    }
    if (current.getChildCount() == 1) {
        // This is still a coordinator node
        return removeCoordinatorSendReceivePairRecursive(root, current.getChild(0));
    }
    // I'm not sure what the correct behavior is for a union.
    return root;
}
Also used : AbstractPlanNode(org.voltdb.plannodes.AbstractPlanNode) AbstractReceivePlanNode(org.voltdb.plannodes.AbstractReceivePlanNode) SendPlanNode(org.voltdb.plannodes.SendPlanNode)

Aggregations

SendPlanNode (org.voltdb.plannodes.SendPlanNode)29 AbstractPlanNode (org.voltdb.plannodes.AbstractPlanNode)27 ProjectionPlanNode (org.voltdb.plannodes.ProjectionPlanNode)16 ReceivePlanNode (org.voltdb.plannodes.ReceivePlanNode)12 MergeReceivePlanNode (org.voltdb.plannodes.MergeReceivePlanNode)11 OrderByPlanNode (org.voltdb.plannodes.OrderByPlanNode)9 HashAggregatePlanNode (org.voltdb.plannodes.HashAggregatePlanNode)8 NestLoopPlanNode (org.voltdb.plannodes.NestLoopPlanNode)8 AggregatePlanNode (org.voltdb.plannodes.AggregatePlanNode)6 AbstractReceivePlanNode (org.voltdb.plannodes.AbstractReceivePlanNode)4 IndexScanPlanNode (org.voltdb.plannodes.IndexScanPlanNode)4 NestLoopIndexPlanNode (org.voltdb.plannodes.NestLoopIndexPlanNode)4 LimitPlanNode (org.voltdb.plannodes.LimitPlanNode)3 NodeSchema (org.voltdb.plannodes.NodeSchema)3 SchemaColumn (org.voltdb.plannodes.SchemaColumn)3 SeqScanPlanNode (org.voltdb.plannodes.SeqScanPlanNode)3 WindowFunctionPlanNode (org.voltdb.plannodes.WindowFunctionPlanNode)3 JSONException (org.json_voltpatches.JSONException)2 AbstractJoinPlanNode (org.voltdb.plannodes.AbstractJoinPlanNode)2 FileNotFoundException (java.io.FileNotFoundException)1