Package edu.caltech.nanodb.plannodes
Class FileScanNode
- java.lang.Object
-
- edu.caltech.nanodb.plannodes.PlanNode
-
- edu.caltech.nanodb.plannodes.SelectNode
-
- edu.caltech.nanodb.plannodes.FileScanNode
-
- All Implemented Interfaces:
java.lang.Cloneable
public class FileScanNode extends SelectNode
A select plan-node that scans a tuple file, checking the optional predicate against each tuple in the file. Note that there are no optimizations used if the tuple file is a sequential tuple file or a hashed tuple file.
This plan node can also be used with indexes, when a "file-scan" is to be performed over all of the index's tuples, in whatever order the index will produce the tuples. If the planner wishes to take advantage of an index's ability to look up tuples based on various values, the
IndexScanNode
should be used instead.
-
-
Field Summary
Fields Modifier and Type Field Description private IndexInfo
indexInfo
The index-info for the index being scanned, ornull
if the node is performing a scan over a table.private boolean
jumpToMarkedTuple
private static org.apache.logging.log4j.Logger
logger
A logging object for reporting anything interesting that happens.private FilePointer
markedTuple
This field allows the file-scan node to mark a particular tuple in the tuple-stream and then rewind to that point in the tuple-stream.private TableInfo
tableInfo
The table-info for the table being scanned, ornull
if the node is performing a scan over an index.private TupleFile
tupleFile
The table to select from if this node is a leaf.-
Fields inherited from class edu.caltech.nanodb.plannodes.SelectNode
currentTuple, predicate
-
Fields inherited from class edu.caltech.nanodb.plannodes.PlanNode
cost, environment, leftChild, rightChild, schema, stats
-
-
Constructor Summary
Constructors Constructor Description FileScanNode(IndexInfo indexInfo, Expression predicate)
Construct a file scan node that traverses an index file.FileScanNode(TableInfo tableInfo, Expression predicate)
Construct a file scan node that traverses a table file.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
advanceCurrentTuple()
Advances the current tuple forward for a file scan.void
cleanUp()
Perform any necessary clean up tasks.protected PlanNode
clone()
Creates a copy of this simple filter node node and its subtree.boolean
equals(java.lang.Object obj)
Returns true if the passed-in object is a FileScanNode with the same predicate and table.int
hashCode()
Computes the hashcode of a PlanNode.void
initialize()
Do initialization for the select operation.void
markCurrentPosition()
Marks the current tuple in the tuple-stream produced by this node.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.protected void
prepareSchema()
boolean
requiresLeftMarking()
This node has no children so of course it doesn't require marking.boolean
requiresRightMarking()
This node has no children so of course it doesn't require marking.void
resetToLastMark()
Resets the node's tuple-stream to the most recently marked position.java.util.List<OrderByExpression>
resultsOrderedBy()
Currently we will always say that the file-scan node produces unsorted results.boolean
supportsMarking()
This node supports marking.java.lang.String
toString()
Reports this node and its vital parameters as a string.-
Methods inherited from class edu.caltech.nanodb.plannodes.SelectNode
getNextTuple, isTupleSelected
-
Methods inherited from class edu.caltech.nanodb.plannodes.PlanNode
addParentEnvironmentToPlanTree, 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.
-
tableInfo
private TableInfo tableInfo
The table-info for the table being scanned, ornull
if the node is performing a scan over an index.
-
indexInfo
private IndexInfo indexInfo
The index-info for the index being scanned, ornull
if the node is performing a scan over a table.
-
tupleFile
private TupleFile tupleFile
The table to select from if this node is a leaf.
-
markedTuple
private FilePointer markedTuple
This field allows the file-scan node to mark a particular tuple in the tuple-stream and then rewind to that point in the tuple-stream.
-
jumpToMarkedTuple
private boolean jumpToMarkedTuple
-
-
Constructor Detail
-
FileScanNode
public FileScanNode(TableInfo tableInfo, Expression predicate)
Construct a file scan node that traverses a table file.- Parameters:
tableInfo
- the information about the table being scannedpredicate
- an optional predicate for selection, ornull
if all rows in the table should be included in the output
-
FileScanNode
public FileScanNode(IndexInfo indexInfo, Expression predicate)
Construct a file scan node that traverses an index file.- Parameters:
indexInfo
- the information about the index being scannedpredicate
- an optional predicate for selection, ornull
if all rows in the index should be included in the output
-
-
Method Detail
-
equals
public boolean equals(java.lang.Object obj)
Returns true if the passed-in object is a FileScanNode with the same predicate and table.
-
hashCode
public int hashCode()
Computes the hashcode of a PlanNode. This method is used to see if two plan nodes CAN be equal.
-
clone
protected PlanNode clone() throws java.lang.CloneNotSupportedException
Creates a copy of this simple filter node node and its subtree. This method is used byPlanNode.duplicate()
to copy a plan tree.- Overrides:
clone
in classSelectNode
- Throws:
java.lang.CloneNotSupportedException
-
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()
Currently we will always say that the file-scan node produces unsorted results. In actuality, a file scan's results will be sorted if the table file uses a sequential format, but currently we don't have any sequential file formats.- 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()
This node supports marking.- Overrides:
supportsMarking
in classPlanNode
- Returns:
- true if the node supports position marking, false otherwise.
-
requiresLeftMarking
public boolean requiresLeftMarking()
This node has no children so of course it doesn't require marking.- Overrides:
requiresLeftMarking
in classPlanNode
- Returns:
- true if the node requires that its left child supports marking, false otherwise.
-
requiresRightMarking
public boolean requiresRightMarking()
This node has no children so of course it doesn't require marking.- Overrides:
requiresRightMarking
in classPlanNode
- Returns:
- true if the node requires that its right child supports marking, false otherwise.
-
prepareSchema
protected void prepareSchema()
-
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()
Description copied from class:SelectNode
Do initialization for the select operation. Resets state variables.- Overrides:
initialize
in classSelectNode
-
cleanUp
public void cleanUp()
Description copied from class:PlanNode
Perform any necessary clean up tasks. This should probably be called when we are done with this plan node.
-
advanceCurrentTuple
protected void advanceCurrentTuple()
Advances the current tuple forward for a file scan. Grabs the first tuple if current is null. Otherwise gets the next tuple.- Specified by:
advanceCurrentTuple
in classSelectNode
-
markCurrentPosition
public void markCurrentPosition()
Description copied from class:PlanNode
Marks the current tuple in the tuple-stream produced by this node. ThePlanNode.resetToLastMark()
method can be used to return to this tuple. Note that only one marker can be set in the tuple-stream at a time.- Overrides:
markCurrentPosition
in classPlanNode
-
resetToLastMark
public void resetToLastMark()
Description copied from class:PlanNode
Resets the node's tuple-stream to the most recently marked position. Note that only one marker can be set in the tuple-stream at a time.- Overrides:
resetToLastMark
in classPlanNode
-
-