Class Data

java.lang.Object
weka.knowledgeflow.Data
All Implemented Interfaces:
Serializable

public class Data extends Object implements Serializable

Class for encapsulating data to be transferred between Knowledge Flow steps over a particular connection type. Typical usage involves constructing a Data object with a given connection name and then setting one or more pieces of "payload" data to encapsulate. Usually there is a primary payload that is associated with the connection name itself (there is a constructor that takes both the connection name and the primary payload data). Further auxiliary data items can be added via the setPayloadElement() method.

Standard connection types are defined as constants in the StepManager class. There is nothing to prevent clients from using their own connection types (as these are just string identifiers).

Typical usage in a client step (transferring an training instances object):

     Instances train = ...
     Data myData = new Data(StepManager.CON_TRAININGSET, train);
     getStepManager().outputData(myData);
 
Version:
$Revision: $
Author:
mhall{[at]}pentaho{[dot]}com
See Also:
  • Constructor Details

    • Data

      public Data()
      Empty constructor - no connection name; no payload
    • Data

      public Data(String connectionName)
      Construct a Data object with just a connection name
      Parameters:
      connectionName - the connection name
    • Data

      public Data(String connectionName, Object primaryPayload)
      Construct a Data object with a connection name and a primary payload object to associate with the connection name
      Parameters:
      connectionName - connection name
      primaryPayload - primary payload object (i.e. is keyed against the connection name)
  • Method Details

    • setSourceStep

      public void setSourceStep(Step sourceStep)
      Set the source step of producing this Data object
      Parameters:
      sourceStep - the source step
    • getSourceStep

      public Step getSourceStep()
      Get the source step producing this Data object
      Returns:
      the source step producing the data object
    • setConnectionName

      public void setConnectionName(String name)
      Set the connection name for this Data object
      Parameters:
      name - the name of the connection
    • getConnectionName

      public String getConnectionName()
      Get the connection name associated with this Data object
      Returns:
      the connection name
    • getPrimaryPayload

      public <T> T getPrimaryPayload()
      Get the primary payload of this data object (i.e. the data associated with the connection name)
      Type Parameters:
      T - the type of the primary payload
      Returns:
      the primary payload data (or null if there is no data associated with the connection)
    • getPayloadElement

      public <T> T getPayloadElement(String name)
      Get a payload element from this Data object. Standard payload element names (keys) can be found as constants defined in the StepManager class.
      Parameters:
      name - the name of the payload element to get
      Returns:
      the named payload element, or null if it does not exist in this Data object
    • getPayloadElement

      public <T> T getPayloadElement(String name, T defaultValue)
      Get a payload element from this Data object. Standard payload element names (keys) can be found as constants defined in the StepManager class.
      Type Parameters:
      T - the type of the payload element to get
      Parameters:
      name - the name of the payload element to get
      defaultValue - a default value if the named element does not exist
      Returns:
      the payload element, or the supplied default value.
    • setPayloadElement

      public void setPayloadElement(String name, Object value)
      Set a payload element to encapsulate in this Data object. Standard payload element names (keys) can be found as constants defined in the StepManager class.
      Parameters:
      name - the name of the payload element to encapsulate
      value - the value of the payload element
    • clearPayload

      public void clearPayload()
      Clear all payload elements from this Data object
    • isIncremental

      public boolean isIncremental()
      Return true if the connection specified for this data object is incremental
      Returns:
      true if the connection for this data object is incremental