Class BaseStep

java.lang.Object
weka.knowledgeflow.steps.BaseStep
All Implemented Interfaces:
Serializable, BaseStepExtender, Step
Direct Known Subclasses:
AlterRelationName, Appender, BaseSimpleDataVisualizer, Block, BoundaryPlotter, ClassAssigner, ClassifierPerformanceEvaluator, ClassValuePicker, ClustererPerformanceEvaluator, CrossValidationFoldMaker, DataGrid, DataVisualizer, Dummy, ExecuteProcess, FlowByExpression, GetDataFromResult, ImageSaver, ImageViewer, IncrementalClassifierEvaluator, InstanceStreamToBatchMaker, Job, Join, MakeResourceIntensive, MemoryBasedDataSource, ModelPerformanceChart, Note, PredictionAppender, SendToPerspective, SerializedModelSaver, SetPropertiesFromEnvironment, SetVariables, Sorter, StorePropertiesInEnvironment, StripChart, SubstringLabeler, SubstringReplacer, TestSetMaker, TextSaver, TextViewer, TrainingSetMaker, TrainTestSplitMaker, WekaAlgorithmWrapper, WriteDataToResult, WriteWekaLog

public abstract class BaseStep extends Object implements Step, BaseStepExtender, Serializable
Base class for implementations of Step to use. Provides handy functions that automatically setup the step's name and "about" info, provide access to the step's StepManager and for resolving environment variables.
Version:
$Revision: $
Author:
Mark Hall (mhall{[at]}pentaho{[dot]}com)
See Also:
  • Constructor Details

    • BaseStep

      public BaseStep()
      Constructor
  • Method Details

    • globalInfo

      public String globalInfo()
      Attempt to get default "about" information for this step by grabbing the toolTip from the KFStep annotation.
      Returns:
      a default "about" info string if this step uses the KFStep annotation and null otherwise. Subclasses should override to provide more comprehensive about info
    • getStepManager

      @NotPersistable public StepManager getStepManager()
      Get the step manager for this step
      Specified by:
      getStepManager in interface Step
      Returns:
      the step manager for this step
    • setStepManager

      public void setStepManager(StepManager manager)
      Set the step manager for this step
      Specified by:
      setStepManager in interface Step
      Parameters:
      manager - the step manager to use
    • setStepIsResourceIntensive

      @ProgrammaticProperty public void setStepIsResourceIntensive(boolean isResourceIntensive)
      Set whether this step is resource intensive (cpu/memory) or not. This affects which executor service is used to execute the step's processing.
      Parameters:
      isResourceIntensive - true if this step is resource intensive.
    • isResourceIntensive

      public boolean isResourceIntensive()
      Get whether this step is resource intensive (cpu/memory) or not.
      Returns:
      true if this step is resource intensive
    • setStepMustRunSingleThreaded

      @ProgrammaticProperty public void setStepMustRunSingleThreaded(boolean mustRunSingleThreaded)
      Set whether this step must run single threaded. I.e. on an executor service which has only one worker thread, thus effectively preventing more than one copy of the step executing at any one time.
      Parameters:
      mustRunSingleThreaded - true if the step must run single threaded
    • stepMustRunSingleThreaded

      public boolean stepMustRunSingleThreaded()
      Get whether this step must run single threaded. I.e. on an executor service which has only one worker thread, thus effectively preventing more than one copy of the step executing at any one time.
      Returns:
      true if the step must run single threaded
    • getName

      public String getName()
      Get the name of this step
      Specified by:
      getName in interface Step
      Returns:
      the name of this step
    • setName

      @ProgrammaticProperty public void setName(String name)
      Set the name of this step
      Specified by:
      setName in interface Step
      Parameters:
      name - the name for this step
    • start

      public void start() throws WekaException
      Start processing. Subclasses should override this method if they can act as a start point in a flow.
      Specified by:
      start in interface BaseStepExtender
      Specified by:
      start in interface Step
      Throws:
      WekaException - if a problem occurs
    • stop

      public void stop()
      Request that processing be stopped. Subclasses should call isStopRequested() periodically to see if they should stop processing.
      Specified by:
      stop in interface Step
    • outputStructureForConnectionType

      public Instances outputStructureForConnectionType(String connectionName) throws WekaException
      If possible, get the output structure for the named connection type as a header-only set of instances. Can return null if the specified connection type is not representable as Instances or cannot be determined at present.
      Specified by:
      outputStructureForConnectionType in interface Step
      Parameters:
      connectionName - the name of the connection type to get the output structure for
      Returns:
      the output structure as a header-only Instances object
      Throws:
      WekaException - if a problem occurs
    • outputStructureForConnectionType

      public Instances outputStructureForConnectionType(String connectionName, Environment env) throws WekaException
      If possible, get the output structure for the named connection type as a header-only set of instances. Can return null if the specified connection type is not representable as Instances or cannot be determined at present.
      Specified by:
      outputStructureForConnectionType in interface Step
      Parameters:
      connectionName - the name of the connection type to get the output structure for
      env - Environment variables
      Returns:
      the output structure as a header-only Instances object
      Throws:
      WekaException - if a problem occurs
    • processIncoming

      public void processIncoming(Data data) throws WekaException
      Process an incoming data payload (if the step accepts incoming connections)
      Specified by:
      processIncoming in interface BaseStepExtender
      Specified by:
      processIncoming in interface Step
      Parameters:
      data - the payload to process
      Throws:
      WekaException - if a problem occurs
    • getCustomEditorForStep

      public String getCustomEditorForStep()
      Return the fully qualified name of a custom editor component (JComponent) to use for editing the properties of the step. This method can return null, in which case the system will dynamically generate an editor using the GenericObjectEditor
      Specified by:
      getCustomEditorForStep in interface Step
      Returns:
      the fully qualified name of a step editor component
    • getInteractiveViewers

      public Map<String,String> getInteractiveViewers()
      When running in a graphical execution environment a step can make one or more popup Viewer components available. These might be used to display results, graphics etc. Returning null indicates that the step has no such additional graphical views. The map returned by this method should be keyed by action name (e.g. "View results"), and values should be fully qualified names of the corresponding StepInteractiveView implementation. Furthermore, the contents of this map can (and should) be dependent on whether a particular viewer should be made available - i.e. if execution hasn't occurred yet, or if a particular incoming connection type is not present, then it might not be possible to view certain results. Viewers can implement StepInteractiveView directly (in which case they need to extends JPanel), or extends the AbstractInteractiveViewer class. The later extends JPanel, uses a BorderLayout, provides a "Close" button and a method to add additional buttons.
      Specified by:
      getInteractiveViewers in interface Step
      Returns:
      a map of viewer component names, or null if this step has no graphical views
    • getInteractiveViewersImpls

      public Map<String,StepInteractiveViewer> getInteractiveViewersImpls()
      An alternative to getStepInteractiveViewers that returns a Map of instantiated StepInteractiveViewer objects. Generally, getInteractiveViewers() is the preferred mechanism to specify any interactive viewers, as it does not require Steps to import and instantiate GUI classes. However, in some cases it might be unavoidable (e.g. Groovy script compilation involves custom classloaders), in these cases this method can be used instead.
      Specified by:
      getInteractiveViewersImpls in interface Step
      Returns:
      a map of instantiated instances of StepInteractiveViewers
    • getDefaultSettings

      public Defaults getDefaultSettings()
      Get default settings for the step (if any). Returning null indicates that the step has no user-editable defaults.
      Specified by:
      getDefaultSettings in interface Step
      Returns:
      the default settings
    • isStopRequested

      public boolean isStopRequested()
      Convenience method that calls StepManager.isStopRequested()
      Returns:
      true if the execution environment has requested processing to stop
    • environmentSubstitute

      public String environmentSubstitute(String source)
      Substitute the values of environment variables in the given string
      Parameters:
      source - the source string to substitute in
      Returns:
      the source string with all known environment variables resolved