Using input and output ports for creating workflows

Is there a more specific example of how to use knime methods for creating ports and assign data to them; so that they can be used as input to another node? How can this be done? I have read the examples provided by your webpage but i haven’t understood exactly what is beeing done and how nodes interract with each other by using the input and output ports.

Though there are specific port types available (such as the blue square PMML ports) usually a data port is sufficient if you have to pass tabluar data from one node to another. This is then be done by the framework. You tell the framework how many ports and of which type you have in the NodeModel's constructor:

  • See our documentation for simple constructor for data ports
  • or use the more sophisticated constructor, if you are using different port types in your node:
    public YourNodeModel() {
            super(
                      // input port types
                    new PortType[] {YourPortObject.TYPE},
                      // output port types
                    new PortType[] {BufferedDataTable.TYPE});
        }
    
    The example above creates a node with your port type as input port and a data port as output port.

In the execute method you get access to these objects. The execute method is called when the user clicks "Execute" on a node. At this point the framework passes the output data from the connected out-port to the in-port of your node and calls the execute method with an array of BufferedDataTables as an argument, which directly refers to your input ports.

inData[0] is the data at your first in-port.

The return type of the execute method is again an array of BufferedDataTables and again directly refers to the out-ports of your node. The data provided at the index 0 in the returned array will be available at the first out-port of your node.

However, if you want to use different port types you have to use PortObject instead of BufferedDataTable in the execute method and PortObjectSpec instead of DataTableSpec in the configure method.

See also our documentation: