Package edu.caltech.nanodb.plannodes
Class HashedGroupAggregateNode
- java.lang.Object
-
- edu.caltech.nanodb.plannodes.PlanNode
-
- edu.caltech.nanodb.plannodes.GroupAggregateNode
-
- edu.caltech.nanodb.plannodes.HashedGroupAggregateNode
-
- All Implemented Interfaces:
java.lang.Cloneable
public class HashedGroupAggregateNode extends GroupAggregateNode
Implements grouping and aggregation by using hashing as a method to identify groups.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.LinkedHashMap<TupleLiteral,java.util.Map<java.lang.String,FunctionCall>>
computedAggregates
private boolean
done
private java.util.Iterator<TupleLiteral>
groupIterator
private static org.apache.logging.log4j.Logger
logger
A logging object for reporting anything interesting that happens.-
Fields inherited from class edu.caltech.nanodb.plannodes.GroupAggregateNode
aggregates, estimatedNumTuples, groupByExprs, inputSchema
-
Fields inherited from class edu.caltech.nanodb.plannodes.PlanNode
cost, environment, leftChild, rightChild, schema, stats
-
-
Constructor Summary
Constructors Constructor Description HashedGroupAggregateNode(PlanNode subplan, java.util.List<Expression> groupByExprs, java.util.Map<java.lang.String,FunctionCall> aggregates)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
cleanUp()
Perform any necessary clean up tasks.private void
computeAggregates()
This helper function iterates through all tuples generated by the subplan, using an internal hash table to compute the grouping and aggregate results that this plan-node will output.boolean
equals(java.lang.Object obj)
Checks if the argument is a plan node tree with the same structure, but not necesarily the same references.Tuple
getNextTuple()
Gets the next tuple that fulfills the conditions for this plan node.int
hashCode()
Computes the hash-code of a plan-node, including any sub-plans of this plan.void
initialize()
Does any initialization the node might need.void
markCurrentPosition()
The hashed grouping/aggregate plan node doesn't support marking.void
prepare()
This method is responsible for computing critical details about the plan node, such as the schema of the results that are produced, the estimated cost of evaluating the plan node (and its children), and statistics describing the results produced by the plan node.boolean
requiresLeftMarking()
The hashed grouping/aggregate operation does not require marking.boolean
requiresRightMarking()
The hashed grouping/aggregate operation does not require marking.void
resetToLastMark()
The hashed grouping/aggregate plan node doesn't support marking.java.util.List<OrderByExpression>
resultsOrderedBy()
The hashed grouping/aggregate operation does not order its results in any way.boolean
supportsMarking()
The hashed grouping/aggregate operation does not support marking, since it must fully consume its input before it can produce any results.java.lang.String
toString()
Reports this node and its vital parameters as a string.-
Methods inherited from class edu.caltech.nanodb.plannodes.GroupAggregateNode
clearAggregates, evaluateGroupByExprs, generateOutputTuple, prepareSchemaStats, updateAggregates
-
Methods inherited from class edu.caltech.nanodb.plannodes.PlanNode
addParentEnvironmentToPlanTree, clone, duplicate, getCost, getEnvironment, getSchema, getStats, printNodeTree, printNodeTree, printNodeTree, printNodeTreeToString, printNodeTreeToString, setEnvironment
-
-
-
-
Field Detail
-
logger
private static org.apache.logging.log4j.Logger logger
A logging object for reporting anything interesting that happens.
-
computedAggregates
private java.util.LinkedHashMap<TupleLiteral,java.util.Map<java.lang.String,FunctionCall>> computedAggregates
-
groupIterator
private java.util.Iterator<TupleLiteral> groupIterator
-
done
private boolean done
-
-
Constructor Detail
-
HashedGroupAggregateNode
public HashedGroupAggregateNode(PlanNode subplan, java.util.List<Expression> groupByExprs, java.util.Map<java.lang.String,FunctionCall> aggregates)
-
-
Method Detail
-
equals
public boolean equals(java.lang.Object obj)
Description copied from class:PlanNode
Checks if the argument is a plan node tree with the same structure, but not necesarily the same references.
-
hashCode
public int hashCode()
Description copied from class:PlanNode
Computes the hash-code of a plan-node, including any sub-plans of this plan. This method is used to see if two plan nodes (or subtrees) might be equal.
-
toString
public java.lang.String toString()
Description copied from class:PlanNode
Reports this node and its vital parameters as a string.
-
resultsOrderedBy
public java.util.List<OrderByExpression> resultsOrderedBy()
The hashed grouping/aggregate operation does not order its results in any way.- Specified by:
resultsOrderedBy
in classPlanNode
- Returns:
- If the plan node produces ordered results, this will be a list of objects specifying the ordering. If the node doesn't produce ordered results then the return-value will either be an empty list or it will be null.
-
supportsMarking
public boolean supportsMarking()
The hashed grouping/aggregate operation does not support marking, since it must fully consume its input before it can produce any results.- Overrides:
supportsMarking
in classPlanNode
- Returns:
- true if the node supports position marking, false otherwise.
-
requiresLeftMarking
public boolean requiresLeftMarking()
The hashed grouping/aggregate operation does not require marking.- Overrides:
requiresLeftMarking
in classPlanNode
- Returns:
- true if the node requires that its left child supports marking, false otherwise.
-
requiresRightMarking
public boolean requiresRightMarking()
The hashed grouping/aggregate operation does not require marking.- Overrides:
requiresRightMarking
in classPlanNode
- Returns:
- true if the node requires that its right child supports marking, false otherwise.
-
getNextTuple
public Tuple getNextTuple()
Gets the next tuple that fulfills the conditions for this plan node. If the node has a child, it should call getNextTuple() on the child. If the node is a leaf, the tuple comes from some external source such as a table file, the network, etc.- Specified by:
getNextTuple
in classPlanNode
- Returns:
- the next tuple to be generated by this plan, or null if the plan has finished generating plan nodes.
- Throws:
java.lang.IllegalStateException
- if a plan node is not properly initialized
-
computeAggregates
private void computeAggregates()
This helper function iterates through all tuples generated by the subplan, using an internal hash table to compute the grouping and aggregate results that this plan-node will output.
-
prepare
public void prepare()
Description copied from class:PlanNode
This method is responsible for computing critical details about the plan node, such as the schema of the results that are produced, the estimated cost of evaluating the plan node (and its children), and statistics describing the results produced by the plan node.
-
initialize
public void initialize()
Does any initialization the node might need. This could include resetting state variables or starting the node over from the beginning.- Overrides:
initialize
in classPlanNode
-
markCurrentPosition
public void markCurrentPosition() throws java.lang.UnsupportedOperationException
The hashed grouping/aggregate plan node doesn't support marking.- Overrides:
markCurrentPosition
in classPlanNode
- Throws:
java.lang.UnsupportedOperationException
- always.
-
resetToLastMark
public void resetToLastMark()
The hashed grouping/aggregate plan node doesn't support marking.- Overrides:
resetToLastMark
in classPlanNode
- Throws:
java.lang.UnsupportedOperationException
- always.
-
-