org.knime.base.node.parallel.appender
Class ThreadedColAppenderNodeModel

java.lang.Object
  extended by org.knime.core.node.NodeModel
      extended by org.knime.base.node.parallel.appender.ThreadedColAppenderNodeModel

public abstract class ThreadedColAppenderNodeModel
extends NodeModel

Author:
Thorsten Meinl, University of Konstanz

Field Summary
static int DEFAULT_MAX_THREAD_COUNT
          The default maximum number of threads for each threaded node.
 
Constructor Summary
ThreadedColAppenderNodeModel(int nrDataIns, int nrDataOuts)
          Creates a new AbstractParallelNodeModel.
 
Method Summary
protected static DataTableSpec createOutputSpec(DataTableSpec inSpec, ExtendedCellFactory cellFactory)
          Returns the output spec based on the input spec and the cell factory.
protected  BufferedDataTable[] execute(BufferedDataTable[] data, ExecutionContext exec)
          This function is invoked by the Node#executeNode() method of the node (through the #executeModel(BufferedDataTable[],ExecutionMonitor) method)only after all predecessor nodes have been successfully executed and all data is therefore available at the input ports.
protected  BufferedDataTable[] getAdditionalTables()
          Returns all additional tables passed into the node, i.e.
protected  BufferedDataTable[] postExecute(BufferedDataTable[] res, ExecutionContext exec)
          This method is called after all rows have been processed and combined into the final result tables.
protected abstract  ExtendedCellFactory[] prepareExecute(DataTable[] data)
          This method is called before the first chunked is processed.
 void setMaxThreads(int count)
          Sets the maximum number of threads that may be used by this node.
 
Methods inherited from class org.knime.core.node.NodeModel
addWarningListener, configure, configure, continueLoop, execute, executeModel, getInHiLiteHandler, getLoopEndNode, getLoopStartNode, getNrInPorts, getNrOutPorts, getOutHiLiteHandler, getWarningMessage, loadInternals, loadValidatedSettingsFrom, notifyViews, notifyWarningListeners, peekFlowVariableDouble, peekFlowVariableInt, peekFlowVariableString, peekScopeVariableDouble, peekScopeVariableInt, peekScopeVariableString, pushFlowVariableDouble, pushFlowVariableInt, pushFlowVariableString, pushScopeVariableDouble, pushScopeVariableInt, pushScopeVariableString, removeWarningListener, reset, saveInternals, saveSettingsTo, setInHiLiteHandler, setWarningMessage, stateChanged, validateSettings
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_MAX_THREAD_COUNT

public static final int DEFAULT_MAX_THREAD_COUNT
The default maximum number of threads for each threaded node.

Constructor Detail

ThreadedColAppenderNodeModel

public ThreadedColAppenderNodeModel(int nrDataIns,
                                    int nrDataOuts)
Creates a new AbstractParallelNodeModel.

Parameters:
nrDataIns - The number of DataTable elements expected as inputs.
nrDataOuts - The number of DataTable objects expected at the output.
Method Detail

prepareExecute

protected abstract ExtendedCellFactory[] prepareExecute(DataTable[] data)
                                                 throws Exception
This method is called before the first chunked is processed. The method must return a cell factory for each output table. The factory must create the new cells for each row in the input table and also specify where the new columns should be placed in the output table.

Parameters:
data - the input data tables
Returns:
extended cell factories, one for each output table
Throws:
Exception - if something goes wrong during preparation

execute

protected final BufferedDataTable[] execute(BufferedDataTable[] data,
                                            ExecutionContext exec)
                                     throws Exception
This function is invoked by the Node#executeNode() method of the node (through the #executeModel(BufferedDataTable[],ExecutionMonitor) method)only after all predecessor nodes have been successfully executed and all data is therefore available at the input ports. Implement this function with your task in the derived model.

The input data is available in the given array argument inData and is ensured to be neither null nor contain null elements.

In order to create output data, you need to create objects of class BufferedDataTable. Use the execution context argument to create BufferedDataTable.

Overrides:
execute in class NodeModel
Parameters:
data - An array holding DataTable elements, one for each input.
exec - The execution monitor for this execute method. It provides us with means to create new BufferedDataTable. Additionally, it should be asked frequently if the execution should be interrupted and throws an exception then. This exception might me caught, and then after closing all data streams, been thrown again. Also, if you can tell the progress of your task, just set it in this monitor.
Returns:
An array of non- null DataTable elements with the size of the number of outputs. The result of this execution.
Throws:
Exception - If you must fail the execution. Try to provide a meaningful error message in the exception as it will be displayed to the user.Please be advised to check frequently the canceled status by invoking ExecutionMonitor#checkCanceled which will throw an CanceledExcecutionException and abort the execution.

postExecute

protected BufferedDataTable[] postExecute(BufferedDataTable[] res,
                                          ExecutionContext exec)
This method is called after all rows have been processed and combined into the final result tables. Implementors of subclasses may override this in order to e.g. change the spec of the result tables. The default implementation returns the parameter unaltered.

Parameters:
res - the combined result tables
exec - the currently active execution context
Returns:
the output tables of the node.

getAdditionalTables

protected final BufferedDataTable[] getAdditionalTables()
Returns all additional tables passed into the node, i.e. tables from 1 to n. This result is only non-null during execute(BufferedDataTable[], ExecutionContext).

Returns:
the array of additional input tables, or null if the node is not currently executing

setMaxThreads

public void setMaxThreads(int count)
Sets the maximum number of threads that may be used by this node.

Parameters:
count - the maximum thread count

createOutputSpec

protected static DataTableSpec createOutputSpec(DataTableSpec inSpec,
                                                ExtendedCellFactory cellFactory)
Returns the output spec based on the input spec and the cell factory.

Parameters:
inSpec - the input spec
cellFactory - the cell factory used
Returns:
the output spec


Copyright, 2003 - 2010. All rights reserved.
University of Konstanz, Germany.
Chair for Bioinformatics and Information Mining, Prof. Dr. Michael R. Berthold.
You may not modify, publish, transmit, transfer or sell, reproduce, create derivative works from, distribute, perform, display, or in any way exploit any of the content, in whole or in part, except as otherwise expressly permitted in writing by the copyright owner or as specified in the license file distributed with this product.