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

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

public class AggregationNode
extends java.lang.Object

An aggregation node is a node in an aggregation tree. This node holds a value, equal to the value in the corresponding group-by column. It also holds: value aggregators (one for each aggregation column), a reference to its parent in the tree, and a set of references to its children. Each child is associated with a unique value, which corresponds to the value held in the child node. See AggregationTree for more details.

Author:
Yoav G.

Constructor Summary
AggregationNode(java.util.Set<java.lang.String> columnsToAggregate, DataTable table)
          Construct a new aggregation node.
 
Method Summary
 void addChild(Value key, java.util.Set<java.lang.String> columnsToAggregate, DataTable table)
          Adds a new child.
 void aggregate(java.util.Map<java.lang.String,Value> valuesByColumn)
          Aggregates values using the value aggregators of this node.
 boolean containsChild(Value v)
          Returns true if a node contains a child (identified by value) and false otherwise.
 Value getAggregationValue(java.lang.String columnId, AggregationType type)
          Returns the aggregation value of a specific column and type.
 AggregationNode getChild(Value v)
          Returns the child of this node defined by a specific value.
 java.util.Map<Value,AggregationNode> getChildren()
          Returns a copy of the map of children of this node.
protected  AggregationNode getParent()
          Returns the parent of this node in the aggregation tree.
protected  Value getValue()
          Returns the value of this node.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AggregationNode

public AggregationNode(java.util.Set<java.lang.String> columnsToAggregate,
                       DataTable table)
Construct a new aggregation node.

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

aggregate

public void aggregate(java.util.Map<java.lang.String,Value> valuesByColumn)
Aggregates values using the value aggregators of this node.

Parameters:
valuesByColumn - Maps a column id to the value that needs be aggregated (for that column).

getAggregationValue

public Value getAggregationValue(java.lang.String columnId,
                                 AggregationType type)
Returns the aggregation value of a specific column and type.

Parameters:
columnId - The requested column id.
type - The requested aggregation type.
Returns:
The aggregation values of a specific column.

getChild

public AggregationNode getChild(Value v)
Returns the child of this node defined by a specific value.

Parameters:
v - The value.
Returns:
The child of this node defined by a specific value.

containsChild

public boolean containsChild(Value v)
Returns true if a node contains a child (identified by value) and false otherwise.

Parameters:
v - The value of the child.
Returns:
True if this node contains a child (identified by value) and false otherwise.

addChild

public void addChild(Value key,
                     java.util.Set<java.lang.String> columnsToAggregate,
                     DataTable table)
Adds a new child.

Parameters:
key - The value defining the new child.
columnsToAggregate - The ids of the columns to aggregate.
table - The table.

getChildren

public java.util.Map<Value,AggregationNode> getChildren()
Returns a copy of the map of children of this node.

Returns:
A copy of the map of children of this node.

getValue

protected Value getValue()
Returns the value of this node. This is also the key of this node in the children set of this parent.

Returns:
The value of this node.

getParent

protected AggregationNode getParent()
Returns the parent of this node in the aggregation tree.

Returns:
The parent of this node.


Copyright © 2009 Google. All Rights Reserved.