Package org.voltdb.plannodes

Examples of org.voltdb.plannodes.AggregatePlanNode


            // ---------------------------------------------------
            // AGGREGATE
            // ---------------------------------------------------
            case AGGREGATE:
            case HASHAGGREGATE: {
                AggregatePlanNode agg_node = (AggregatePlanNode) node;
                for (Integer col_guid : agg_node.getAggregateColumnGuids()) {
                    PlanColumn col = plannerContext.get(col_guid);
                    assert (col != null) : "Invalid PlanColumn #" + col_guid;
                    if (col.getExpression() != null)
                        exps.add(col.getExpression());
                } // FOR
                for (Integer col_guid : agg_node.getGroupByColumnGuids()) {
                    PlanColumn col = plannerContext.get(col_guid);
                    assert (col != null) : "Invalid PlanColumn #" + col_guid;
                    if (col.getExpression() != null)
                        exps.add(col.getExpression());
                } // FOR
View Full Code Here


        }

        // If this is an AggregatePlanNode, then we also need to include columns
        // computed in the aggregates
        if (node instanceof AggregatePlanNode) {
            AggregatePlanNode agg_node = (AggregatePlanNode) node;
            planColumnIds.addAll(agg_node.getAggregateColumnGuids());
            if (debug.val)
                LOG.debug(node.getPlanNodeType() + ": " + agg_node.getAggregateColumnGuids());
        }

        return (planColumnIds);
    }
View Full Code Here

            sb.append(inner_spacer).append("TargetTableId[" + cast_node.getTargetTableName() + "]\n");
        }

        // AggregatePlanNode
        if (node instanceof AggregatePlanNode) {
            AggregatePlanNode cast_node = (AggregatePlanNode) node;
            sb.append(inner_spacer).append("AggregateTypes[" + cast_node.getAggregateTypes().size() + "]: " + cast_node.getAggregateTypes() + "\n");
            sb.append(inner_spacer).append("AggregateColumnOffsets[" + cast_node.getAggregateOutputColumns().size() + "]: " + cast_node.getAggregateOutputColumns() + "\n");
            sb.append(inner_spacer).append(PlanNodeUtil.debugOutputColumns("AggregateColumns", cast_node.getAggregateColumnGuids(), line_spacer));
            sb.append(inner_spacer).append(PlanNodeUtil.debugOutputColumns("GroupByColumns", cast_node.getGroupByColumnGuids(), line_spacer));

            // DeletePlanNode
        } else if (node instanceof DeletePlanNode) {
            sb.append(inner_spacer).append("Truncate[" + ((DeletePlanNode) node).isTruncate() + "\n");

            // DistinctPlanNode
        } else if (node instanceof DistinctPlanNode) {
            DistinctPlanNode dist_node = (DistinctPlanNode) node;
            PlanColumn col = PlannerContext.singleton().get(dist_node.getDistinctColumnGuid());
            sb.append(inner_spacer).append("DistinctColumn[" + col + "]\n");

            // IndexScanPlanNode
        } else if (node instanceof IndexScanPlanNode) {
            IndexScanPlanNode cast_node = (IndexScanPlanNode) node;
            sb.append(inner_spacer).append("TargetIndexName[" + cast_node.getTargetIndexName() + "]\n");
            sb.append(inner_spacer).append("EnableKeyIteration[" + cast_node.getKeyIterate() + "]\n");
            sb.append(inner_spacer).append("IndexLookupType[" + cast_node.getLookupType() + "]\n");
            sb.append(inner_spacer).append("SearchKey Expressions:\n");
            for (AbstractExpression search_key : cast_node.getSearchKeyExpressions()) {
                sb.append(ExpressionUtil.debug(search_key, line_spacer));
            }
            sb.append(inner_spacer).append("End Expression: " + (cast_node.getEndExpression() != null ? "\n" + ExpressionUtil.debug(cast_node.getEndExpression(), line_spacer) : null + "\n"));
            sb.append(inner_spacer).append("Post-Scan Expression: " + (cast_node.getPredicate() != null ? "\n" + ExpressionUtil.debug(cast_node.getPredicate(), line_spacer) : null + "\n"));

            // InsertPlanNode
        } else if (node instanceof InsertPlanNode) {
            sb.append(inner_spacer).append("MultiPartition[" + ((InsertPlanNode) node).getMultiPartition() + "]\n");

            // LimitPlanNode
        } else if (node instanceof LimitPlanNode) {
            sb.append(inner_spacer).append("Limit[" + ((LimitPlanNode) node).getLimit() + "]\n");
            sb.append(inner_spacer).append("Offset[" + ((LimitPlanNode) node).getOffset() + "]\n");

            // NestLoopIndexPlanNode
        } else if (node instanceof NestLoopIndexPlanNode) {
            // Nothing

            // NestLoopPlanNode
        } else if (node instanceof NestLoopPlanNode) {
            // Nothing

        } else if (node instanceof OrderByPlanNode) {
            OrderByPlanNode cast_node = (OrderByPlanNode) node;
            sb.append(inner_spacer).append(PlanNodeUtil.debugOutputColumns("SortColumns", cast_node.getSortColumnGuids(), line_spacer));

        } else if (node instanceof ProjectionPlanNode) {
            // ProjectionPlanNode cast_node = (ProjectionPlanNode)node;
            if (node instanceof MaterializePlanNode) {
                sb.append(line_spacer).append("Batched[" + ((MaterializePlanNode) node).isBatched() + "]\n");
View Full Code Here

        // ---------------------------------------------------
        // AGGREGATE
        // ---------------------------------------------------
        if (node instanceof AggregatePlanNode) {
            AggregatePlanNode agg_node = (AggregatePlanNode) node;
            for (Integer col_guid : agg_node.getAggregateColumnGuids()) {
                PlanColumn col = state.plannerContext.get(col_guid);
                assert (col != null) : "Invalid PlanColumn #" + col_guid;
                if (col.getExpression() != null)
                    exps.add(col.getExpression());
            } // FOR
            for (Integer col_guid : agg_node.getGroupByColumnGuids()) {
                PlanColumn col = state.plannerContext.get(col_guid);
                assert (col != null) : "Invalid PlanColumn #" + col_guid;
                if (col.getExpression() != null)
                    exps.add(col.getExpression());
            } // FOR
View Full Code Here

                    // Every PlanColumn referenced in this node must appear in its children's output
                    Collection<Integer> planCols = node.getOutputColumnGUIDs();
                    assert(planCols != null);
                   
//                    System.err.println(PlanNodeUtil.debugNode(node));
                    AggregatePlanNode cast_node = (AggregatePlanNode)node;
                    assertEquals(cast_node.toString(), cast_node.getAggregateTypes().size(), cast_node.getAggregateColumnGuids().size());
                    assertEquals(cast_node.toString(), cast_node.getAggregateTypes().size(), cast_node.getAggregateColumnNames().size());
                    assertEquals(cast_node.toString(), cast_node.getAggregateTypes().size(), cast_node.getAggregateOutputColumns().size());
                   
                   
//                    Set<Integer> foundCols = new HashSet<Integer>();
//                    for (AbstractPlanNode child : node.getChildren()) {
//                        Collection<Integer> childCols = PlanNodeUtil.getOutputColumnIdsForPlanNode(child);
View Full Code Here

        // We should have two AggregatePlanNodes.
        // Make sure that they have the same GroupByColumns
        Collection<AggregatePlanNode> agg_nodes = PlanNodeUtil.getPlanNodes(root, AggregatePlanNode.class);
        assertEquals(2, agg_nodes.size());
       
        AggregatePlanNode agg0 = CollectionUtil.get(agg_nodes, 0);
        assertNotNull(agg0);
        AggregatePlanNode agg1 = CollectionUtil.get(agg_nodes, 1);
        assertNotNull(agg1);
        assertNotSame(agg0, agg1);
       
// System.err.println(PlanNodeUtil.debug(root));
       
        assertEquals(agg0.getAggregateOutputColumns(), agg1.getAggregateOutputColumns());
        assertEquals(agg0.getGroupByColumnNames(), agg1.getGroupByColumnNames());
// assertEquals(agg0.getGroupByColumnGuids(), agg1.getGroupByColumnGuids());
    }
View Full Code Here

    AbstractPlanNode insertCountInDMLPlan(AbstractPlanNode dmlRoot)
    {
        // update the output columns in case our caller hasn't
        dmlRoot.updateOutputColumns(m_catalogDb);
        // Add an aggregate count.
        AggregatePlanNode countNode = new AggregatePlanNode(m_context, getNextPlanNodeId());
        List<String> countColumnNames = new ArrayList<String>();
        List<Integer> countColumnGuids = new ArrayList<Integer>();
        List<ExpressionType> countColumnTypes = new ArrayList<ExpressionType>();
        List<Integer> countOutputColumns = countNode.getAggregateOutputColumns();

        // aggregate column name same as original dmlRoot name.
        int colGuid = dmlRoot.getOutputColumnGUIDs().get(0); // offset 0.
        countColumnNames.add(m_context.get(colGuid).getDisplayName());
        countColumnGuids.add(colGuid);
        countOutputColumns.add(0);
        countColumnTypes.add(ExpressionType.AGGREGATE_COUNT_STAR);
        countNode.setAggregateColumnNames(countColumnNames);
        countNode.setAggregateColumnGuids(countColumnGuids);
        countNode.setAggregateTypes(countColumnTypes);

        // The output column. Not really based on a TVE (it is really the
        // count expression represented by the count configured above). But
        // this is sufficient for now.
        TupleValueExpression tve = new TupleValueExpression();
        tve.setValueType(VoltType.BIGINT);
        tve.setValueSize(VoltType.BIGINT.getLengthInBytesForFixedTypes());
        tve.setColumnIndex(0);
        tve.setColumnName(m_context.get(colGuid).getDisplayName());
        tve.setColumnAlias(m_context.get(colGuid).getDisplayName());
        tve.setTableName("");
        PlanColumn countColInfo = m_context.getPlanColumn(tve, "modified_tuples");
        countNode.appendOutputColumn(countColInfo);
        countNode.addAndLinkChild(dmlRoot);
        return countNode;
    }
View Full Code Here

    AbstractPlanNode addSumAndSendToDMLNode(AbstractPlanNode dmlRoot, boolean isReplicated) {
        // do some output column organizing...
        dmlRoot.updateOutputColumns(m_catalogDb);

        // create the nodes being pushed on top of dmlRoot.
        AggregatePlanNode countNode = new AggregatePlanNode(m_context, getNextPlanNodeId());
        SendPlanNode sendNode = new SendPlanNode(m_context, getNextPlanNodeId());

        // configure the count aggregate (sum) node to produce a single
        // output column containing the result of the sum.

        List<String> countColumnNames = new ArrayList<String>();
        List<Integer> countColumnGuids = new ArrayList<Integer>();
        List<ExpressionType> countColumnTypes = new ArrayList<ExpressionType>();
        List<Integer> countOutputColumns = countNode.getAggregateOutputColumns();

        // aggregate column name same as original dmlRoot name.
        int colGuid = dmlRoot.getOutputColumnGUIDs().get(0); // offset 0.
        countColumnNames.add(m_context.get(colGuid).getDisplayName());
        countColumnGuids.add(colGuid);
        countOutputColumns.add(0);
        // IMPORTANT: If this is for a replicated table, then we want to compute
        // the max. If it's not a replicated table, then we want to compute the SUM
        countColumnTypes.add(isReplicated ? ExpressionType.AGGREGATE_MAX : ExpressionType.AGGREGATE_SUM);
        countNode.setAggregateColumnNames(countColumnNames);
        countNode.setAggregateColumnGuids(countColumnGuids);
        countNode.setAggregateTypes(countColumnTypes);

        // The output column. Not really based on a TVE (it is really the
        // count expression represented by the count configured above). But
        // this is sufficient for now.
        TupleValueExpression tve = new TupleValueExpression();
        tve.setValueType(VoltType.BIGINT);
        tve.setValueSize(VoltType.BIGINT.getLengthInBytesForFixedTypes());
        tve.setColumnIndex(0);
        tve.setColumnName(m_context.get(colGuid).getDisplayName());
        tve.setColumnAlias(m_context.get(colGuid).getDisplayName());
        tve.setTableName("");
        PlanColumn colInfo = m_context.getPlanColumn(tve, "modified_tuples");
        countNode.appendOutputColumn(colInfo);

        // connect the nodes to build the graph
        countNode.addAndLinkChild(dmlRoot);
        sendNode.addAndLinkChild(countNode);

        return sendNode;
    }
View Full Code Here

        }
    }

    public void testGroupByA1() {
        AbstractPlanNode p;
        AggregatePlanNode aggNode;
        pns = compileToFragments("SELECT A1 from T1 group by A1");
        p = pns.get(0).getChild(0);
        assertTrue(p instanceof AggregatePlanNode);
        assertTrue(p.getChild(0) instanceof ReceivePlanNode);

        p = pns.get(1).getChild(0);
        assertTrue(p instanceof AbstractScanPlanNode);
        // No index, inline hash aggregate
        assertNotNull(p.getInlinePlanNode(PlanNodeType.HASHAGGREGATE));

        // Having
        pns = compileToFragments("SELECT A1, count(*) from T1 group by A1 Having count(*) > 3");
        p = pns.get(0).getChild(0);
        assertTrue(p instanceof AggregatePlanNode);
        aggNode = (AggregatePlanNode)p;
        assertNotNull(aggNode.getPostPredicate());
        assertTrue(p.getChild(0) instanceof ReceivePlanNode);

        p = pns.get(1).getChild(0);
        assertTrue(p instanceof AbstractScanPlanNode);
        // No index, inline hash aggregate
        assertNotNull(p.getInlinePlanNode(PlanNodeType.HASHAGGREGATE));
        aggNode = (AggregatePlanNode)p.getInlinePlanNode(PlanNodeType.HASHAGGREGATE);
        assertNull(aggNode.getPostPredicate());

    }
View Full Code Here

    }

    private void checkGroupByPartitionKey(boolean topAgg, boolean having) {
        AbstractPlanNode p;
        AggregatePlanNode aggNode;

        p = pns.get(0).getChild(0);
        if (topAgg) {
            assertTrue(p instanceof AggregatePlanNode);
            if (having) {
                aggNode = (AggregatePlanNode)p;
                assertNotNull(aggNode.getPostPredicate());
            }
            p = p.getChild(0);
        }
        assertTrue(p instanceof ReceivePlanNode);

        p = pns.get(1).getChild(0);
        // inline aggregate
        assertTrue(p instanceof AbstractScanPlanNode);

        PlanNodeType aggType = PlanNodeType.HASHAGGREGATE;
        if (p instanceof IndexScanPlanNode &&
                ((IndexScanPlanNode)p).isForGroupingOnly() ) {
            aggType = PlanNodeType.AGGREGATE;
        }
        assertNotNull(p.getInlinePlanNode(aggType));

        if (having && !topAgg) {
            aggNode = (AggregatePlanNode)p.getInlinePlanNode(aggType);
            assertNotNull(aggNode.getPostPredicate());
        }
    }
View Full Code Here

TOP

Related Classes of org.voltdb.plannodes.AggregatePlanNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.