Class RelationalNode
- java.lang.Object
-
- org.teiid.query.processor.relational.RelationalNode
-
- All Implemented Interfaces:
Cloneable
,BatchCollector.BatchProducer
- Direct Known Subclasses:
DupRemoveNode
,LimitNode
,NullNode
,ProjectIntoNode
,SortNode
,SubqueryAwareRelationalNode
,UnionAllNode
public abstract class RelationalNode extends Object implements Cloneable, BatchCollector.BatchProducer
-
-
Field Summary
Fields Modifier and Type Field Description protected int
childCount
-
Constructor Summary
Constructors Modifier Constructor Description protected
RelationalNode()
RelationalNode(int nodeID)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
addBatchRow(List<?> row)
void
addChild(RelationalNode child)
abstract Object
clone()
All the implementation of Cloneable interface need to implement clone() method.void
close()
void
closeDirect()
protected void
copyTo(RelationalNode target)
static Map<Expression,Integer>
createLookupMap(List<? extends Expression> elements)
Useful function to build an element lookup map from an element list.protected int
getBatchSize()
TupleBuffer
getBuffer(int maxRows)
return the final tuple buffer or null if not availableprotected TupleBuffer
getBufferDirect(int maxRows)
For subclasses to override if they wish to return a buffer rather than batches.protected BufferManager
getBufferManager()
int
getChildCount()
RelationalNode[]
getChildren()
protected String
getClassName()
Helper for the toString to get the class name from the full class name.protected String
getConnectionID()
CommandContext
getContext()
protected ProcessorDataManager
getDataManager()
PlanNode
getDescriptionProperties()
List<? extends Expression>
getElements()
Number
getEstimateNodeCardinality()
int
getID()
RelationalNodeStatistics
getNodeStatistics()
protected void
getNodeString(StringBuffer str)
List<? extends Expression>
getOutputElements()
Get list of resolved elements describing output columns for this plan.RelationalNode
getParent()
static int[]
getProjectionIndexes(Map<? extends Expression,Integer> tupleElements, List<? extends Expression> projectElements)
Helper method for all the node that will filter the elements needed for the next node.boolean
hasBuffer()
Return true if the node provides a final buffer via getBufferprotected boolean
hasPendingRows()
void
initialize(CommandContext context, BufferManager bufferManager, ProcessorDataManager dataMgr)
protected boolean
isBatchFull()
boolean
isClosed()
Check if the node has been already closedboolean
isLastBatch()
TupleBatch
nextBatch()
Wrapper for nextBatchDirect that does performance timing - callers should always call this rather than nextBatchDirect().protected abstract TupleBatch
nextBatchDirect()
Template method for subclasses to implement.String
nodeToString()
Just print single node to string instead of node+recursive plan.void
open()
static <T> List<T>
projectTuple(int[] indexes, List<T> tupleValues)
static <T> List<T>
projectTuple(int[] indexes, List<T> tupleValues, boolean omitMissing)
protected TupleBatch
pullBatch()
Boolean
requiresTransaction(boolean transactionalReads)
void
reset()
void
setContext(CommandContext context)
void
setElements(List<? extends Expression> elements)
void
setEstimateDepAccessCardinality(Number depAccessEstimate)
void
setEstimateDepJoinCost(Number estimateDepJoinCost)
void
setEstimateJoinCost(Number estimateJoinCost)
void
setEstimateNodeCardinality(Number estimateNodeCardinality)
void
setEstimateNodeSetSize(Number setSizeEstimate)
void
setID(int nodeID)
void
setParent(RelationalNode parent)
protected void
terminateBatches()
String
toString()
Print plantree structure starting at this nodestatic void
unwrapException(TeiidRuntimeException e)
-
-
-
Method Detail
-
getChildCount
public int getChildCount()
-
isLastBatch
public boolean isLastBatch()
-
setContext
public void setContext(CommandContext context)
-
initialize
public void initialize(CommandContext context, BufferManager bufferManager, ProcessorDataManager dataMgr)
-
getContext
public CommandContext getContext()
-
getID
public int getID()
-
setID
public void setID(int nodeID)
-
getBufferManager
protected BufferManager getBufferManager()
-
getDataManager
protected ProcessorDataManager getDataManager()
-
getConnectionID
protected String getConnectionID()
-
getBatchSize
protected int getBatchSize()
-
reset
public void reset()
-
setElements
public void setElements(List<? extends Expression> elements)
-
getOutputElements
public List<? extends Expression> getOutputElements()
Description copied from interface:BatchCollector.BatchProducer
Get list of resolved elements describing output columns for this plan.- Specified by:
getOutputElements
in interfaceBatchCollector.BatchProducer
- Returns:
- List of SingleElementSymbol
-
getElements
public List<? extends Expression> getElements()
-
getParent
public RelationalNode getParent()
-
setParent
public void setParent(RelationalNode parent)
-
getChildren
public RelationalNode[] getChildren()
-
addChild
public void addChild(RelationalNode child)
-
addBatchRow
protected void addBatchRow(List<?> row)
-
terminateBatches
protected void terminateBatches()
-
isBatchFull
protected boolean isBatchFull()
-
hasPendingRows
protected boolean hasPendingRows()
-
pullBatch
protected TupleBatch pullBatch()
-
open
public void open() throws TeiidComponentException, TeiidProcessingException
-
nextBatch
public final TupleBatch nextBatch() throws BlockedException, TeiidComponentException, TeiidProcessingException
Wrapper for nextBatchDirect that does performance timing - callers should always call this rather than nextBatchDirect().- Specified by:
nextBatch
in interfaceBatchCollector.BatchProducer
- Returns:
- Throws:
BlockedException
TeiidComponentException
TeiidProcessingException
- for business rule exception, related to user input or modeling- Since:
- 4.2
-
nextBatchDirect
protected abstract TupleBatch nextBatchDirect() throws BlockedException, TeiidComponentException, TeiidProcessingException
Template method for subclasses to implement.- Returns:
- Throws:
BlockedException
TeiidComponentException
TeiidProcessingException
- if exception related to user input occured- Since:
- 4.2
-
close
public final void close() throws TeiidComponentException
- Specified by:
close
in interfaceBatchCollector.BatchProducer
- Throws:
TeiidComponentException
-
closeDirect
public void closeDirect()
-
isClosed
public boolean isClosed()
Check if the node has been already closed- Returns:
-
getProjectionIndexes
public static int[] getProjectionIndexes(Map<? extends Expression,Integer> tupleElements, List<? extends Expression> projectElements)
Helper method for all the node that will filter the elements needed for the next node.
-
projectTuple
public static <T> List<T> projectTuple(int[] indexes, List<T> tupleValues, boolean omitMissing)
-
createLookupMap
public static Map<Expression,Integer> createLookupMap(List<? extends Expression> elements)
Useful function to build an element lookup map from an element list.- Parameters:
elements
- List of elements- Returns:
- Map of element to Integer, which is the index
-
toString
public String toString()
Print plantree structure starting at this node
-
nodeToString
public String nodeToString()
Just print single node to string instead of node+recursive plan.- Returns:
- String representing just this node
-
getNodeString
protected void getNodeString(StringBuffer str)
-
getClassName
protected String getClassName()
Helper for the toString to get the class name from the full class name.- Returns:
- Just the last part which is the class name
-
clone
public abstract Object clone()
All the implementation of Cloneable interface need to implement clone() method. The plan is only clonable in the pre-execution stage, not the execution state (things like program state, result sets, etc). It's only safe to call that method in between query processings, in other words, it's only safe to call clone() on a plan after nextTuple() returns null, meaning the plan has finished processing.
-
copyTo
protected void copyTo(RelationalNode target)
-
getDescriptionProperties
public PlanNode getDescriptionProperties()
-
getNodeStatistics
public RelationalNodeStatistics getNodeStatistics()
- Returns:
- Returns the nodeStatistics.
- Since:
- 4.2
-
setEstimateNodeCardinality
public void setEstimateNodeCardinality(Number estimateNodeCardinality)
-
setEstimateNodeSetSize
public void setEstimateNodeSetSize(Number setSizeEstimate)
-
setEstimateDepAccessCardinality
public void setEstimateDepAccessCardinality(Number depAccessEstimate)
-
setEstimateDepJoinCost
public void setEstimateDepJoinCost(Number estimateDepJoinCost)
-
setEstimateJoinCost
public void setEstimateJoinCost(Number estimateJoinCost)
-
getEstimateNodeCardinality
public Number getEstimateNodeCardinality()
- Returns:
- Returns the estimateNodeCardinality.
-
hasBuffer
public boolean hasBuffer()
Return true if the node provides a final buffer via getBuffer- Specified by:
hasBuffer
in interfaceBatchCollector.BatchProducer
-
getBuffer
public final TupleBuffer getBuffer(int maxRows) throws BlockedException, TeiidComponentException, TeiidProcessingException
return the final tuple buffer or null if not available- Specified by:
getBuffer
in interfaceBatchCollector.BatchProducer
- Returns:
- Throws:
TeiidProcessingException
TeiidComponentException
BlockedException
-
getBufferDirect
protected TupleBuffer getBufferDirect(int maxRows) throws BlockedException, TeiidComponentException, TeiidProcessingException
For subclasses to override if they wish to return a buffer rather than batches.- Parameters:
maxRows
-- Returns:
- Throws:
BlockedException
TeiidComponentException
TeiidProcessingException
-
unwrapException
public static void unwrapException(TeiidRuntimeException e) throws TeiidComponentException, TeiidProcessingException
-
requiresTransaction
public Boolean requiresTransaction(boolean transactionalReads)
- Parameters:
transactionalReads
-- Returns:
- true if required, false if not required, and null if a single source command is issued and a transaction may be needed.
-
-