com.metamatrix.query.processor.relational
Class SortNode

java.lang.Object
  extended by com.metamatrix.query.processor.relational.RelationalNode
      extended by com.metamatrix.query.processor.relational.SortNode
All Implemented Interfaces:
Describable, java.lang.Cloneable
Direct Known Subclasses:
DupRemoveNode

public class SortNode
extends RelationalNode


Field Summary
 
Fields inherited from interface com.metamatrix.query.processor.Describable
PROP_BINDINGS, PROP_CHILDREN, PROP_CONDITIONS, PROP_CRITERIA, PROP_DATA_COL, PROP_DEFAULT, PROP_DEFAULT_PROGRAM, PROP_ELSE, PROP_ENCODING, PROP_EXECUTION_PLAN, PROP_EXPRESSION, PROP_FORMATTED, PROP_GROUP, PROP_GROUP_COLS, PROP_IN_MEMORY, PROP_INTO_GROUP, PROP_IS_STAGING, PROP_JOIN_CRITERIA, PROP_JOIN_STRATEGY, PROP_JOIN_TYPE, PROP_MESSAGE, PROP_MODEL_NAME, PROP_NAMESPACE, PROP_NAMESPACE_DECL, PROP_NODE_COST_ESTIMATES, PROP_NODE_STATS_LIST, PROP_NODE_STATS_PROPS, PROP_OPTIONAL, PROP_OUTPUT_COLS, PROP_PROGRAM, PROP_PROGRAMS, PROP_RECURSE_DIR, PROP_REMOVE_DUPS, PROP_RESULT_SET, PROP_ROW_LIMIT, PROP_ROW_OFFSET, PROP_SELECT_COLS, PROP_SORT_COLS, PROP_SQL, PROP_TAG, PROP_THEN, PROP_TYPE, PROP_VARIABLE
 
Constructor Summary
SortNode(int nodeID)
           
 
Method Summary
 java.lang.Object clone()
          All the implementation of Cloneable interface need to implement clone() method.
 void close()
           
protected  void collectionPhase(TupleBatch batch)
           
protected  void copy(SortNode source, SortNode target)
           
 java.util.Map getDescriptionProperties()
          Get a description as a set of properties of primitive types such as String, Integer, etc.
protected  void getNodeString(java.lang.StringBuffer str)
           
 java.util.List getSortElements()
           
 TupleBatch nextBatchDirect()
          1ST PHASE - COLLECTION Collect all batches from child node, save in collected tuple source 2ND PHASE - SORT INITIAL SUBLISTS Repeat until all batches from collection TS have been read Get and pin batches from collection TS until MemoryNotAvailableException Sort batches Write batches into new sorted TS Unpin all batches Remove collection TS 3RD PHASE - MERGE SORTED SUBLISTS Repeat until there is one sublist Repeat until all sorted sublists have been merged For each sorted sublist S Load and pin a batch until memory not available Merge from pinned batches As batch is done, unpin and load next Output merge into new sublist T Remove merged sublists Let sublists = set of T's 4TH PHASE - OUTPUT Return batches from single sublist from T
 void open()
           
 void reset()
           
protected  void setRemoveDuplicates(boolean removeDuplicates)
           
 void setSortElements(java.util.List sortElements, java.util.List sortTypes)
           
 
Methods inherited from class com.metamatrix.query.processor.relational.RelationalNode
addBatchRow, addChild, copy, createLookupMap, getBatchSize, getBufferManager, getChildDescriptionProperties, getChildPlans, getChildren, getClassName, getConnectionID, getContext, getDataManager, getElements, getEstimateNodeCardinality, getID, getNodeStatistics, getParent, initialize, isBatchFull, isClosed, nextBatch, nodeToString, projectTuple, pullBatch, setElements, setEstimateDepAccessCardinality, setEstimateDepJoinCost, setEstimateJoinCost, setEstimateNodeCardinality, setEstimateNodeSetSize, setID, setParent, terminateBatches, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SortNode

public SortNode(int nodeID)
Method Detail

reset

public void reset()
Overrides:
reset in class RelationalNode

setSortElements

public void setSortElements(java.util.List sortElements,
                            java.util.List sortTypes)

getSortElements

public java.util.List getSortElements()

setRemoveDuplicates

protected void setRemoveDuplicates(boolean removeDuplicates)

open

public void open()
          throws MetaMatrixComponentException,
                 MetaMatrixProcessingException
Overrides:
open in class RelationalNode
Throws:
MetaMatrixComponentException
MetaMatrixProcessingException

nextBatchDirect

public TupleBatch nextBatchDirect()
                           throws BlockedException,
                                  MetaMatrixComponentException,
                                  MetaMatrixProcessingException
1ST PHASE - COLLECTION Collect all batches from child node, save in collected tuple source 2ND PHASE - SORT INITIAL SUBLISTS Repeat until all batches from collection TS have been read Get and pin batches from collection TS until MemoryNotAvailableException Sort batches Write batches into new sorted TS Unpin all batches Remove collection TS 3RD PHASE - MERGE SORTED SUBLISTS Repeat until there is one sublist Repeat until all sorted sublists have been merged For each sorted sublist S Load and pin a batch until memory not available Merge from pinned batches As batch is done, unpin and load next Output merge into new sublist T Remove merged sublists Let sublists = set of T's 4TH PHASE - OUTPUT Return batches from single sublist from T

Specified by:
nextBatchDirect in class RelationalNode
Returns:
Throws:
BlockedException
MetaMatrixComponentException
MetaMatrixProcessingException - if exception related to user input occured

collectionPhase

protected void collectionPhase(TupleBatch batch)
                        throws BlockedException,
                               TupleSourceNotFoundException,
                               MetaMatrixComponentException,
                               MetaMatrixProcessingException
Throws:
BlockedException
TupleSourceNotFoundException
MetaMatrixComponentException
MetaMatrixProcessingException

close

public void close()
           throws MetaMatrixComponentException
Overrides:
close in class RelationalNode
Throws:
MetaMatrixComponentException

getNodeString

protected void getNodeString(java.lang.StringBuffer str)
Overrides:
getNodeString in class RelationalNode

copy

protected void copy(SortNode source,
                    SortNode target)

clone

public java.lang.Object clone()
Description copied from class: RelationalNode
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.

Specified by:
clone in class RelationalNode

getDescriptionProperties

public java.util.Map getDescriptionProperties()
Description copied from interface: Describable
Get a description as a set of properties of primitive types such as String, Integer, etc.

Specified by:
getDescriptionProperties in interface Describable
Overrides:
getDescriptionProperties in class RelationalNode
Returns:
Map of properties


Copyright © 2009. All Rights Reserved.