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 intchildCount
-
Constructor Summary
Constructors Modifier Constructor Description protectedRelationalNode()RelationalNode(int nodeID)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidaddBatchRow(List<?> row)voidaddChild(RelationalNode child)abstract Objectclone()All the implementation of Cloneable interface need to implement clone() method.voidclose()voidcloseDirect()protected voidcopyTo(RelationalNode target)static Map<Expression,Integer>createLookupMap(List<? extends Expression> elements)Useful function to build an element lookup map from an element list.protected intgetBatchSize()TupleBuffergetBuffer(int maxRows)return the final tuple buffer or null if not availableprotected TupleBuffergetBufferDirect(int maxRows)For subclasses to override if they wish to return a buffer rather than batches.protected BufferManagergetBufferManager()intgetChildCount()RelationalNode[]getChildren()protected StringgetClassName()Helper for the toString to get the class name from the full class name.protected StringgetConnectionID()CommandContextgetContext()protected ProcessorDataManagergetDataManager()PlanNodegetDescriptionProperties()List<? extends Expression>getElements()NumbergetEstimateNodeCardinality()intgetID()RelationalNodeStatisticsgetNodeStatistics()protected voidgetNodeString(StringBuffer str)List<? extends Expression>getOutputElements()Get list of resolved elements describing output columns for this plan.RelationalNodegetParent()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.booleanhasBuffer()Return true if the node provides a final buffer via getBufferprotected booleanhasPendingRows()voidinitialize(CommandContext context, BufferManager bufferManager, ProcessorDataManager dataMgr)protected booleanisBatchFull()booleanisClosed()Check if the node has been already closedbooleanisLastBatch()TupleBatchnextBatch()Wrapper for nextBatchDirect that does performance timing - callers should always call this rather than nextBatchDirect().protected abstract TupleBatchnextBatchDirect()Template method for subclasses to implement.StringnodeToString()Just print single node to string instead of node+recursive plan.voidopen()static <T> List<T>projectTuple(int[] indexes, List<T> tupleValues)static <T> List<T>projectTuple(int[] indexes, List<T> tupleValues, boolean omitMissing)protected TupleBatchpullBatch()BooleanrequiresTransaction(boolean transactionalReads)voidreset()voidsetContext(CommandContext context)voidsetElements(List<? extends Expression> elements)voidsetEstimateDepAccessCardinality(Number depAccessEstimate)voidsetEstimateDepJoinCost(Number estimateDepJoinCost)voidsetEstimateJoinCost(Number estimateJoinCost)voidsetEstimateNodeCardinality(Number estimateNodeCardinality)voidsetEstimateNodeSetSize(Number setSizeEstimate)voidsetID(int nodeID)voidsetParent(RelationalNode parent)protected voidterminateBatches()StringtoString()Print plantree structure starting at this nodestatic voidunwrapException(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.BatchProducerGet list of resolved elements describing output columns for this plan.- Specified by:
getOutputElementsin 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:
nextBatchin interfaceBatchCollector.BatchProducer- Returns:
- Throws:
BlockedExceptionTeiidComponentExceptionTeiidProcessingException- 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:
BlockedExceptionTeiidComponentExceptionTeiidProcessingException- if exception related to user input occured- Since:
- 4.2
-
close
public final void close() throws TeiidComponentException- Specified by:
closein 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:
hasBufferin 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:
getBufferin interfaceBatchCollector.BatchProducer- Returns:
- Throws:
TeiidProcessingExceptionTeiidComponentExceptionBlockedException
-
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:
BlockedExceptionTeiidComponentExceptionTeiidProcessingException
-
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.
-
-