Package edu.caltech.nanodb.plannodes
Class SelectNode
- java.lang.Object
-
- edu.caltech.nanodb.plannodes.PlanNode
-
- edu.caltech.nanodb.plannodes.SelectNode
-
- All Implemented Interfaces:
java.lang.Cloneable
- Direct Known Subclasses:
FileScanNode
,SimpleFilterNode
public abstract class SelectNode extends PlanNode
PlanNode representing the WHERE clause in a SELECT operation. This is the relational algebra Select operator.
-
-
Field Summary
Fields Modifier and Type Field Description protected Tuple
currentTuple
The current tuple that the node is selecting.private boolean
done
True if we have finished scanning or pulling tuples from children.Expression
predicate
Predicate used for selection.-
Fields inherited from class edu.caltech.nanodb.plannodes.PlanNode
cost, environment, leftChild, rightChild, schema, stats
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
SelectNode(Expression predicate)
Constructs a SelectNode that scans a file for tuples.protected
SelectNode(PlanNode leftChild, Expression predicate)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract void
advanceCurrentTuple()
Helper function that advances the current tuple reference in the node.protected PlanNode
clone()
Creates a copy of this select node and its subtree.Tuple
getNextTuple()
Gets the next tuple selected by the predicate.void
initialize()
Do initialization for the select operation.protected boolean
isTupleSelected(Tuple tuple)
-
Methods inherited from class edu.caltech.nanodb.plannodes.PlanNode
addParentEnvironmentToPlanTree, cleanUp, duplicate, equals, getCost, getEnvironment, getSchema, getStats, hashCode, markCurrentPosition, prepare, printNodeTree, printNodeTree, printNodeTree, printNodeTreeToString, printNodeTreeToString, requiresLeftMarking, requiresRightMarking, resetToLastMark, resultsOrderedBy, setEnvironment, supportsMarking, toString
-
-
-
-
Field Detail
-
predicate
public Expression predicate
Predicate used for selection.
-
currentTuple
protected Tuple currentTuple
The current tuple that the node is selecting.
-
done
private boolean done
True if we have finished scanning or pulling tuples from children.
-
-
Constructor Detail
-
SelectNode
protected SelectNode(Expression predicate)
Constructs a SelectNode that scans a file for tuples.- Parameters:
predicate
- the selection criterion
-
SelectNode
protected SelectNode(PlanNode leftChild, Expression predicate)
-
-
Method Detail
-
clone
protected PlanNode clone() throws java.lang.CloneNotSupportedException
Creates a copy of this select node and its subtree. This method is used byPlanNode.duplicate()
to copy a plan tree.
-
initialize
public void initialize()
Do initialization for the select operation. Resets state variables.- Overrides:
initialize
in classPlanNode
-
getNextTuple
public Tuple getNextTuple()
Gets the next tuple selected by the predicate.- Specified by:
getNextTuple
in classPlanNode
- Returns:
- the tuple to be passed up to the next node.
- Throws:
java.lang.IllegalStateException
- if this is a scanning node with no algorithm or a filtering node with no child, or if the leftChild threw an IllegalStateException.
-
advanceCurrentTuple
protected abstract void advanceCurrentTuple()
Helper function that advances the current tuple reference in the node.
-
isTupleSelected
protected boolean isTupleSelected(Tuple tuple)
-
-