当前位置: 首页>>代码示例>>Java>>正文


Java HashAggregatePlanNode类代码示例

本文整理汇总了Java中org.voltdb.plannodes.HashAggregatePlanNode的典型用法代码示例。如果您正苦于以下问题:Java HashAggregatePlanNode类的具体用法?Java HashAggregatePlanNode怎么用?Java HashAggregatePlanNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


HashAggregatePlanNode类属于org.voltdb.plannodes包,在下文中一共展示了HashAggregatePlanNode类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testDistinctA1_Subquery

import org.voltdb.plannodes.HashAggregatePlanNode; //导入依赖的package包/类
public void testDistinctA1_Subquery() {
    AbstractPlanNode p;
    // Distinct rewrote with group by
    pns = compileToFragments("select * from (SELECT DISTINCT A1 FROM T1) temp");
    printExplainPlan(pns);

    p = pns.get(0).getChild(0);
    assertTrue(p instanceof SeqScanPlanNode);
    assertTrue(p.getChild(0) instanceof HashAggregatePlanNode);
    assertTrue(p.getChild(0).getChild(0) instanceof ReceivePlanNode);

    p = pns.get(1).getChild(0);
    assertTrue(p instanceof AbstractScanPlanNode);
    assertNotNull(p.getInlinePlanNode(PlanNodeType.HASHAGGREGATE));
}
 
开发者ID:anhnv-3991,项目名称:VoltDB,代码行数:16,代码来源:TestPlansGroupBy.java

示例2: handleMVBasedMultiPartQuery

import org.voltdb.plannodes.HashAggregatePlanNode; //导入依赖的package包/类
private AbstractPlanNode handleMVBasedMultiPartQuery (AbstractPlanNode root, boolean edgeCaseOuterJoin) {
    MaterializedViewFixInfo mvFixInfo = m_parsedSelect.m_mvFixInfo;

    HashAggregatePlanNode reAggNode = new HashAggregatePlanNode(mvFixInfo.getReAggregationPlanNode());
    reAggNode.clearChildren();
    reAggNode.clearParents();

    AbstractPlanNode receiveNode = root;
    AbstractPlanNode reAggParent = null;
    // Find receive plan node and insert the constructed re-aggregation plan node.
    if (root.getPlanNodeType() == PlanNodeType.RECEIVE) {
        root = reAggNode;
    } else {
        List<AbstractPlanNode> recList = root.findAllNodesOfType(PlanNodeType.RECEIVE);
        assert(recList.size() == 1);
        receiveNode = recList.get(0);

        reAggParent = receiveNode.getParent(0);
        boolean result = reAggParent.replaceChild(receiveNode, reAggNode);
        assert(result);
    }
    reAggNode.addAndLinkChild(receiveNode);

    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);

    // If it is normal joined query, replace the node under 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);

        // If reAggNode has parent node before we put it under join node,
        // 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;
}
 
开发者ID:anhnv-3991,项目名称:VoltDB,代码行数:64,代码来源:PlanAssembler.java

示例3: handleDistinctWithGroupby

import org.voltdb.plannodes.HashAggregatePlanNode; //导入依赖的package包/类
/**
 * Handle DISTINCT with Group by if it is not redundant with aggregation/grouping.
 * DISTINCT is basically rewrote with GROUP BY to benefit all kinds of GROUP BY OPTIMIZATIONS.
 * Trivial case non GROUP BY DISTINCT has been rewrote very early at query parsing time.
 * In the non-trivial case, where an existing GROUP BY column is NOT in the select list,
 * a final aggregation (never pushed down) can be added to the top of the plan.
 * @param root can be aggregate plan node or project plan node
 * @return
 */
private AbstractPlanNode handleDistinctWithGroupby(AbstractPlanNode root) {
    if (! m_parsedSelect.hasDistinctWithGroupBy()) {
        return root;
    }
    assert(m_parsedSelect.isGrouped());

    // DISTINCT is redundant with GROUP BY IFF all of the grouping columns are present in the display columns.
    if (m_parsedSelect.displayColumnsContainAllGroupByColumns()) {
        return root;
    }
    // Now non complex aggregation cases are handled already
    assert(m_parsedSelect.hasComplexAgg());

    AggregatePlanNode distinctAggNode = new HashAggregatePlanNode();
    distinctAggNode.setOutputSchema(m_parsedSelect.getDistinctProjectionSchema());

    for (ParsedColInfo col : m_parsedSelect.m_distinctGroupByColumns) {
        distinctAggNode.addGroupByExpression(col.expression);
    }

    // TODO(xin): push down the DISTINCT for certain cases
    // Ticket: ENG-7360
    /*
    boolean pushedDown = false;
    boolean canPushdownDistinctAgg = m_parsedSelect.hasPartitionColumnInDistinctGroupby();
    //
    // disable pushdown, DISTINCT push down turns out complex
    //
    canPushdownDistinctAgg = false;

    if (canPushdownDistinctAgg && !m_parsedSelect.m_mvFixInfo.needed()) {
        assert(m_parsedSelect.hasPartitionColumnInGroupby());
        AbstractPlanNode receive = root;

        if (receive instanceof ReceivePlanNode) {
            // Temporarily strip send/receive pair
            AbstractPlanNode distNode = receive.getChild(0).getChild(0);
            receive.getChild(0).unlinkChild(distNode);

            distinctAggNode.addAndLinkChild(distNode);
            receive.getChild(0).addAndLinkChild(distinctAggNode);

            pushedDown = true;
        }
    }*/

    distinctAggNode.addAndLinkChild(root);
    root = distinctAggNode;

    return root;
}
 
开发者ID:anhnv-3991,项目名称:VoltDB,代码行数:61,代码来源:PlanAssembler.java

示例4: getReAggregationPlanNode

import org.voltdb.plannodes.HashAggregatePlanNode; //导入依赖的package包/类
public HashAggregatePlanNode getReAggregationPlanNode () {
    return m_reAggNode;
}
 
开发者ID:anhnv-3991,项目名称:VoltDB,代码行数:4,代码来源:MaterializedViewFixInfo.java

示例5: testPartitionedGroupByWithoutAggregate

import org.voltdb.plannodes.HashAggregatePlanNode; //导入依赖的package包/类
public void testPartitionedGroupByWithoutAggregate() {
    AbstractPlanNode pn;
    List<AbstractPlanNode> planNodes;

    // group by non-partition column, no pushed down
    planNodes = compileToFragments(
            "SELECT * FROM (SELECT C FROM P1 GROUP BY C) T1");
    assertEquals(2, planNodes.size());
    pn = planNodes.get(0).getChild(0);
    checkSeqScan(pn, "T1");
    pn = pn.getChild(0);
    assertTrue(pn instanceof HashAggregatePlanNode);

    pn = planNodes.get(1).getChild(0);
    checkPrimaryKeyIndexScan(pn, "P1");

    // count(*), no pushed down
    planNodes = compileToFragments(
            "SELECT count(*) FROM (SELECT c FROM P1 GROUP BY c) T1");
    assertEquals(2, planNodes.size());
    pn = planNodes.get(0).getChild(0);
    assertTrue(pn instanceof TableCountPlanNode);
    pn = pn.getChild(0);
    assertTrue(pn instanceof HashAggregatePlanNode);

    pn = planNodes.get(1).getChild(0);
    checkPrimaryKeyIndexScan(pn, "P1");


    // group by partition column, pushed down
    planNodes = compileToFragments(
            "SELECT * FROM (SELECT A FROM P1 GROUP BY A) T1");
    assertEquals(2, planNodes.size());
    pn = planNodes.get(0).getChild(0);
    assertTrue(pn instanceof ProjectionPlanNode);
    assertTrue(pn.getChild(0) instanceof ReceivePlanNode);

    pn = planNodes.get(1).getChild(0);
    checkSeqScan(pn, "T1");
    pn = pn.getChild(0);
    checkPrimaryKeyIndexScan(pn, "P1");

    planNodes = compileToFragments(
            "SELECT count(*) FROM (SELECT A FROM P1 GROUP BY A) T1");
    assertEquals(2, planNodes.size());
    pn = planNodes.get(0).getChild(0);
    assertTrue(pn.getChild(0) instanceof ReceivePlanNode);

    pn = planNodes.get(1).getChild(0);
    assertTrue(pn instanceof TableCountPlanNode);
    pn = pn.getChild(0);
    checkPrimaryKeyIndexScan(pn, "P1");
}
 
开发者ID:anhnv-3991,项目名称:VoltDB,代码行数:54,代码来源:TestSubQueries.java

示例6: checkMVFixWithWhere

import org.voltdb.plannodes.HashAggregatePlanNode; //导入依赖的package包/类
private void checkMVFixWithWhere(Object aggFilters, Object scanFilters) {
    AbstractPlanNode p = pns.get(0);

    List<AbstractPlanNode> nodes = p.findAllNodesOfType(PlanNodeType.RECEIVE);
    assertEquals(1, nodes.size());
    p = nodes.get(0);

    // Find re-aggregation node.
    assertTrue(p instanceof ReceivePlanNode);
    assertTrue(p.getParent(0) instanceof HashAggregatePlanNode);
    HashAggregatePlanNode reAggNode = (HashAggregatePlanNode) p.getParent(0);
    String reAggNodeStr = reAggNode.toExplainPlanString().toLowerCase();

    // Find scan node.
    p = pns.get(1);
    assert (p.getScanNodeList().size() == 1);
    p = p.getScanNodeList().get(0);
    String scanNodeStr = p.toExplainPlanString().toLowerCase();

    if (aggFilters != null) {
        String[] aggFilterStrings = null;
        if (aggFilters instanceof String) {
            aggFilterStrings = new String[] { (String) aggFilters };
        } else {
            aggFilterStrings = (String[]) aggFilters;
        }
        for (String aggFilter : aggFilterStrings) {
            System.out.println(reAggNodeStr.contains(aggFilter
                    .toLowerCase()));
            assertTrue(reAggNodeStr.contains(aggFilter.toLowerCase()));
            System.out
                    .println(scanNodeStr.contains(aggFilter.toLowerCase()));
            assertFalse(scanNodeStr.contains(aggFilter.toLowerCase()));
        }
    } else {
        assertNull(reAggNode.getPostPredicate());
    }

    if (scanFilters != null) {
        String[] scanFilterStrings = null;
        if (scanFilters instanceof String) {
            scanFilterStrings = new String[] { (String) scanFilters };
        } else {
            scanFilterStrings = (String[]) scanFilters;
        }
        for (String scanFilter : scanFilterStrings) {
            System.out.println(reAggNodeStr.contains(scanFilter
                    .toLowerCase()));
            assertFalse(reAggNodeStr.contains(scanFilter.toLowerCase()));
            System.out.println(scanNodeStr.contains(scanFilter
                    .toLowerCase()));
            assertTrue(scanNodeStr.contains(scanFilter.toLowerCase()));
        }
    }
}
 
开发者ID:anhnv-3991,项目名称:VoltDB,代码行数:56,代码来源:TestPlansGroupBy.java


注:本文中的org.voltdb.plannodes.HashAggregatePlanNode类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。