com.google.visualization.datasource.query.engine
Class AggregationTree

java.lang.Object
  extended by com.google.visualization.datasource.query.engine.AggregationTree

public class AggregationTree
extends java.lang.Object

An aggregation tree is the logical data structure that represents table grouping information. Each level of the tree (besides the root-level) is associated with an aggregation column. Each node of the tree is associated with a value (of some cell in the column defining its level). Each node contains aggregation information, i.e., information about the minimum, maximum, count, average and sum on the aggregated columns. A leaf node holds this aggregation information for the corresponding "path" of values. For example, if the group-by columns are {Name, Revenue}, then the tree consists of 3 levels: the root level, holding only the root, then a level with nodes representing different values of Name, and then a level with nodes holding different values of Revenue. Then the leaf node which is at the path {"Joe", 100} from the root will hold the aggregation information for all rows in the table for which the value of Name is "Joe" and the value of Revenue is 100. The non-leaf node which is at the path {"Joe"} will contain the aggregation information for all rows in which the name is "Joe", without any consideration of the value of the Revenue column. The root node contains all aggregation information for the entire table.

Author:
Yoav G.

Constructor Summary
AggregationTree(java.util.Set<java.lang.String> columnsToAggregate, DataTable table)
          Construct an aggregation tree.
 
Method Summary
 void aggregate(AggregationPath path, java.util.Map<java.lang.String,Value> valuesToAggregate)
          Aggregates values to all the nodes on a path.
 AggregationNode getNode(AggregationPath path)
          Returns the aggregation node at the end of a path.
 java.util.Set<AggregationPath> getPathsToLeaves()
          Returns a set containing a path for each leaf in the tree.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AggregationTree

public AggregationTree(java.util.Set<java.lang.String> columnsToAggregate,
                       DataTable table)
Construct an aggregation tree.

Parameters:
columnsToAggregate - A set of ids of the columns to aggregate.
table - The table.
Method Detail

aggregate

public void aggregate(AggregationPath path,
                      java.util.Map<java.lang.String,Value> valuesToAggregate)
Aggregates values to all the nodes on a path. The nodes of the path that are not in the tree are created and inserted into the tree.

Parameters:
valuesToAggregate - Maps column ids to values (to aggregate).
path - The aggregation path.

getNode

public AggregationNode getNode(AggregationPath path)
Returns the aggregation node at the end of a path.

Parameters:
path - The aggregation path.
Returns:
The aggregation node at the end of a path.
Throws:
java.util.NoSuchElementException - In case no node lies at the end of the path.

getPathsToLeaves

public java.util.Set<AggregationPath> getPathsToLeaves()
Returns a set containing a path for each leaf in the tree.

Returns:
A set containing a path for each leaf in the tree.


Copyright © 2009 Google. All Rights Reserved.