Class WekaDatabaseReader

  • All Implemented Interfaces:
    AdditionalInformationHandler, CleanUpHandler, Destroyable, GlobalInfoSupporter, LoggingLevelHandler, LoggingSupporter, OptionHandler, PasswordSupporter, QuickInfoSupporter, ShallowCopySupporter<Actor>, SizeOfHandler, Stoppable, StoppableWithFeedback, VariablesInspectionHandler, DatabaseConnectionParameterHandler, VariableChangeListener, Actor, ErrorHandler, OutputProducer, Serializable, Comparable

    public class WekaDatabaseReader
    extends AbstractSource
    implements DatabaseConnectionParameterHandler
    Executes a query and returns the data either in batch or incremental mode.

    Input/output:
    - generates:
       weka.core.Instance
       weka.core.Instances


    Valid options are:

    -D <int> (property: debugLevel)
        The greater the number the more additional info the scheme may output to
        the console (0 = off).
        default: 0
        minimum: 0
     
    -name <java.lang.String> (property: name)
        The name of the actor.
        default: WekaDatabaseReader
     
    -annotation <adams.core.base.BaseText> (property: annotations)
        The annotations to attach to this actor.
        default:
     
    -skip (property: skip)
        If set to true, transformation is skipped and the input token is just forwarded
        as it is.
     
    -stop-flow-on-error (property: stopFlowOnError)
        If set to true, the flow gets stopped in case this actor encounters an error;
         useful for critical actors.
     
    -url <java.lang.String> (property: URL)
        The JDBC URL of the database to query.
     
    -user <java.lang.String> (property: user)
        The user for connecting to the database.
     
    -password <adams.core.base.BasePassword> (property: password)
        The password for the database user.
     
    -query <java.lang.String> (property: query)
        The SQL query to execute.
        default: select * from result0
     
    -keys <java.lang.String> (property: keys)
        The keys to use for identifying a single row (comma-separated list of column
        names).
        default:
     
    -incremental (property: incremental)
        If set to true, then single Instance objects are output, otherwise just
        one Instances object.
     
    Author:
    fracpete (fracpete at waikato dot ac dot nz)
    See Also:
    Serialized Form
    • Field Detail

      • m_URL

        protected String m_URL
        the database URL to query.
      • m_User

        protected String m_User
        the database user to use for connecting.
      • m_Password

        protected BasePassword m_Password
        the password for the user used for connecting.
      • m_Query

        protected SQLStatement m_Query
        the query to execute.
      • m_Keys

        protected String m_Keys
        the keys that uniquely identify a single row.
      • m_Incremental

        protected boolean m_Incremental
        whether to output the data row-by-row.
      • m_SparseFormat

        protected boolean m_SparseFormat
        whether to output data in sparse format.
      • m_CustomPropsFile

        protected PlaceholderFile m_CustomPropsFile
        a custom properties file to use instead of default one.
      • m_Structure

        protected weka.core.Instances m_Structure
        the structure.
      • m_Source

        protected weka.core.converters.DatabaseLoader m_Source
        the actual loader for loading the data.
      • m_NextInstance

        protected weka.core.Instance m_NextInstance
        the next instance to output.
      • m_Data

        protected weka.core.Instances m_Data
        the full data.
    • Constructor Detail

      • WekaDatabaseReader

        public WekaDatabaseReader()
    • Method Detail

      • URLTipText

        public String URLTipText()
        Returns the tip text for this property.
        Specified by:
        URLTipText in interface DatabaseConnectionParameterHandler
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • userTipText

        public String userTipText()
        Returns the tip text for this property.
        Specified by:
        userTipText in interface DatabaseConnectionParameterHandler
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setQuery

        public void setQuery​(SQLStatement value)
        Sets the query to execute.
        Parameters:
        value - the query
      • getQuery

        public SQLStatement getQuery()
        Returns the query to execute.
        Returns:
        the query
      • queryTipText

        public String queryTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setKeys

        public void setKeys​(String value)
        Sets the keys to use for identifying a single row (comma-separated list).
        Parameters:
        value - the keys
      • getKeys

        public String getKeys()
        Returns the keys to use for identifying a single row (comma-separated list).
        Returns:
        the keys
      • keysTipText

        public String keysTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setIncremental

        public void setIncremental​(boolean value)
        Sets whether to output single Instance objects or just one Instances object.
        Parameters:
        value - if true then a single Instance objects are output
      • getIncremental

        public boolean getIncremental()
        Returns whether to output single Instance objects or just one Instances object.
        Returns:
        true if single Instance objects are output
      • incrementalTipText

        public String incrementalTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setSparseFormat

        public void setSparseFormat​(boolean value)
        Sets whether to output the data in sparse format.
        Parameters:
        value - if true then sparse format is used
      • getSparseFormat

        public boolean getSparseFormat()
        Returns whether data is output in sparse format.
        Returns:
        true if sparse format is used
      • sparseFormatTipText

        public String sparseFormatTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setCustomPropsFile

        public void setCustomPropsFile​(PlaceholderFile value)
        Sets the custom properties file to use for initializing the database setup instead of WEKA's default one.
        Parameters:
        value - the custom props file, ignored if a directory
      • getCustomPropsFile

        public PlaceholderFile getCustomPropsFile()
        Returns the custom properties file to use for initializing the database setup instead of WEKA's default one.
        Returns:
        the custom props file, ignored if a directory
      • customPropsFileTipText

        public String customPropsFileTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • generates

        public Class[] generates()
        Returns the class of objects that it generates.
        Specified by:
        generates in interface OutputProducer
        Returns:
        weka.core.Instance.class, weka.core.Instances.class
      • reset

        protected void reset()
        Resets the scheme.
        Overrides:
        reset in class AbstractActor
      • doExecute

        protected String doExecute()
        Executes the flow item.
        Specified by:
        doExecute in class AbstractActor
        Returns:
        null if everything is fine, otherwise error message
      • output

        public Token output()
        Returns the generated token.
        Specified by:
        output in interface OutputProducer
        Returns:
        the generated token
      • hasPendingOutput

        public boolean hasPendingOutput()
        Checks whether there is pending output to be collected after executing the flow item.
        Specified by:
        hasPendingOutput in interface OutputProducer
        Returns:
        true if there is pending output
      • wrapUp

        public void wrapUp()
        Cleans up after the execution has finished.
        Specified by:
        wrapUp in interface Actor
        Overrides:
        wrapUp in class AbstractActor