Package edu.caltech.nanodb.plannodes
Class SortedGroupAggregateNode
- java.lang.Object
-
- edu.caltech.nanodb.plannodes.PlanNode
-
- edu.caltech.nanodb.plannodes.GroupAggregateNode
-
- edu.caltech.nanodb.plannodes.SortedGroupAggregateNode
-
- All Implemented Interfaces:
java.lang.Cloneable
public class SortedGroupAggregateNode extends GroupAggregateNode
Implements grouping and aggregation by using sorting as a method to find groups.
-
-
Field Summary
Fields Modifier and Type Field Description private TupleLiteral
currentGroupValues
A tuple of the current group-by values being considered.private boolean
done
private static org.apache.logging.log4j.Logger
logger
A logging object for reporting anything interesting that happens.private java.util.List<OrderByExpression>
orderByExprs
-
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 SortedGroupAggregateNode(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.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 sorted 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 sorted grouping/aggregate operation does not require marking.boolean
requiresRightMarking()
The sorted grouping/aggregate operation does not require marking.void
resetToLastMark()
The sorted grouping/aggregate plan node doesn't support marking.java.util.List<OrderByExpression>
resultsOrderedBy()
The sorted grouping/aggregate operation orders its results according to the columns in the GROUP BY clause.boolean
supportsMarking()
The sorted 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.
-
orderByExprs
private java.util.List<OrderByExpression> orderByExprs
-
done
private boolean done
-
currentGroupValues
private TupleLiteral currentGroupValues
A tuple of the current group-by values being considered. When each tuple is retrieved from the subplan, a set of group-by values is computed, and if it matches this set of group-by values then we are still in the same group; otherwise, we have moved to the next group.
-
-
Constructor Detail
-
SortedGroupAggregateNode
public SortedGroupAggregateNode(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 sorted grouping/aggregate operation orders its results according to the columns in the GROUP BY clause.- 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 sorted 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 sorted 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 sorted 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.
-
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 sorted grouping/aggregate plan node doesn't support marking.- Overrides:
markCurrentPosition
in classPlanNode
- Throws:
java.lang.UnsupportedOperationException
- always.
-
resetToLastMark
public void resetToLastMark()
The sorted grouping/aggregate plan node doesn't support marking.- Overrides:
resetToLastMark
in classPlanNode
- Throws:
java.lang.UnsupportedOperationException
- always.
-
-