Package adams.flow.source
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 Summary
Fields Modifier and Type Field Description protected PlaceholderFilem_CustomPropsFilea custom properties file to use instead of default one.protected weka.core.Instancesm_Datathe full data.protected booleanm_Incrementalwhether to output the data row-by-row.protected Stringm_Keysthe keys that uniquely identify a single row.protected weka.core.Instancem_NextInstancethe next instance to output.protected BasePasswordm_Passwordthe password for the user used for connecting.protected SQLStatementm_Querythe query to execute.protected weka.core.converters.DatabaseLoaderm_Sourcethe actual loader for loading the data.protected booleanm_SparseFormatwhether to output data in sparse format.protected weka.core.Instancesm_Structurethe structure.protected Stringm_URLthe database URL to query.protected Stringm_Userthe database user to use for connecting.-
Fields inherited from class adams.flow.core.AbstractActor
m_Annotations, m_BackupState, m_DetectedObjectVariables, m_DetectedVariables, m_ErrorHandler, m_Executed, m_Executing, m_ExecutionListeningSupporter, m_FullName, m_LoggingPrefix, m_Name, m_Parent, m_ScopeHandler, m_Self, m_Silent, m_Skip, m_StopFlowOnError, m_StopMessage, m_Stopped, m_StorageHandler, m_VariablesUpdated
-
Fields inherited from class adams.core.option.AbstractOptionHandler
m_OptionManager
-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
Fields inherited from interface adams.flow.core.Actor
FILE_EXTENSION, FILE_EXTENSION_GZ
-
-
Constructor Summary
Constructors Constructor Description WekaDatabaseReader()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringcustomPropsFileTipText()Returns the tip text for this property.voiddefineOptions()Adds options to the internal list of options.protected StringdoExecute()Executes the flow item.Class[]generates()Returns the class of objects that it generates.PlaceholderFilegetCustomPropsFile()Returns the custom properties file to use for initializing the database setup instead of WEKA's default one.booleangetIncremental()Returns whether to output single Instance objects or just one Instances object.StringgetKeys()Returns the keys to use for identifying a single row (comma-separated list).BasePasswordgetPassword()Returns the database password.SQLStatementgetQuery()Returns the query to execute.StringgetQuickInfo()Returns a quick info about the actor, which will be displayed in the GUI.booleangetSparseFormat()Returns whether data is output in sparse format.StringgetURL()Returns the query to execute.StringgetUser()Returns the database user.StringglobalInfo()Returns a string describing the object.booleanhasPendingOutput()Checks whether there is pending output to be collected after executing the flow item.StringincrementalTipText()Returns the tip text for this property.StringkeysTipText()Returns the tip text for this property.Tokenoutput()Returns the generated token.StringpasswordTipText()Returns the tip text for this property.StringqueryTipText()Returns the tip text for this property.protected voidreset()Resets the scheme.voidsetCustomPropsFile(PlaceholderFile value)Sets the custom properties file to use for initializing the database setup instead of WEKA's default one.voidsetIncremental(boolean value)Sets whether to output single Instance objects or just one Instances object.voidsetKeys(String value)Sets the keys to use for identifying a single row (comma-separated list).voidsetPassword(BasePassword value)Sets the database password.voidsetQuery(SQLStatement value)Sets the query to execute.voidsetSparseFormat(boolean value)Sets whether to output the data in sparse format.voidsetURL(String value)Sets the database URL to query.voidsetUser(String value)Sets the database user.StringsparseFormatTipText()Returns the tip text for this property.StringURLTipText()Returns the tip text for this property.StringuserTipText()Returns the tip text for this property.voidwrapUp()Cleans up after the execution has finished.-
Methods inherited from class adams.flow.core.AbstractActor
annotationsTipText, backupState, canInspectOptions, canPerformSetUpCheck, cleanUp, compareTo, configureLogger, destroy, equals, execute, finalUpdateVariables, findVariables, findVariables, forceVariables, forCommandLine, forName, forName, getAdditionalInformation, getAnnotations, getDefaultName, getDetectedVariables, getErrorHandler, getFlowActors, getFlowExecutionListeningSupporter, getFullName, getName, getNextSibling, getParent, getParentComponent, getPreviousSibling, getRoot, getScopeHandler, getSilent, getSkip, getStopFlowOnError, getStopMessage, getStorageHandler, getVariables, handleError, handleException, hasErrorHandler, hasStopMessage, index, initialize, isBackedUp, isExecuted, isExecuting, isFinished, isHeadless, isStopped, nameTipText, performSetUpChecks, performVariableChecks, postExecute, preExecute, pruneBackup, pruneBackup, restoreState, setAnnotations, setErrorHandler, setName, setParent, setSilent, setSkip, setStopFlowOnError, setUp, setVariables, shallowCopy, shallowCopy, silentTipText, sizeOf, skipTipText, stopExecution, stopExecution, stopFlowOnErrorTipText, updateDetectedVariables, updatePrefix, updateVariables, variableChanged
-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, finishInit, getDefaultLoggingLevel, getOptionManager, loggingLevelTipText, newOptionManager, setLoggingLevel, toCommandLine, toString
-
Methods inherited from class adams.core.logging.LoggingObject
getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface adams.flow.core.Actor
cleanUp, compareTo, destroy, equals, execute, findVariables, getAnnotations, getDefaultName, getDetectedVariables, getErrorHandler, getFlowExecutionListeningSupporter, getFullName, getName, getNextSibling, getParent, getParentComponent, getPreviousSibling, getRoot, getScopeHandler, getSilent, getSkip, getStopFlowOnError, getStopMessage, getStorageHandler, getVariables, handleError, hasErrorHandler, hasStopMessage, index, isExecuted, isFinished, isHeadless, isStopped, setAnnotations, setErrorHandler, setName, setParent, setSilent, setSkip, setStopFlowOnError, setUp, setVariables, shallowCopy, shallowCopy, sizeOf, stopExecution, stopExecution, toCommandLine, variableChanged
-
Methods inherited from interface adams.core.AdditionalInformationHandler
getAdditionalInformation
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel, setLoggingLevel
-
Methods inherited from interface adams.core.logging.LoggingSupporter
getLogger, isLoggingEnabled
-
Methods inherited from interface adams.core.option.OptionHandler
cleanUpOptions, getOptionManager
-
Methods inherited from interface adams.core.VariablesInspectionHandler
canInspectOptions
-
-
-
-
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.
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing the object.- Specified by:
globalInfoin interfaceGlobalInfoSupporter- Specified by:
globalInfoin classAbstractOptionHandler- Returns:
- a description suitable for displaying in the gui
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptionsin interfaceOptionHandler- Overrides:
defineOptionsin classAbstractActor
-
getQuickInfo
public String getQuickInfo()
Returns a quick info about the actor, which will be displayed in the GUI.- Specified by:
getQuickInfoin interfaceActor- Specified by:
getQuickInfoin interfaceQuickInfoSupporter- Overrides:
getQuickInfoin classAbstractActor- Returns:
- null if no info available, otherwise short string
-
setURL
public void setURL(String value)
Sets the database URL to query.- Specified by:
setURLin interfaceDatabaseConnectionParameterHandler- Parameters:
value- the JDBC URL
-
getURL
public String getURL()
Returns the query to execute.- Specified by:
getURLin interfaceDatabaseConnectionParameterHandler- Returns:
- the query
-
URLTipText
public String URLTipText()
Returns the tip text for this property.- Specified by:
URLTipTextin interfaceDatabaseConnectionParameterHandler- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setUser
public void setUser(String value)
Sets the database user.- Specified by:
setUserin interfaceDatabaseConnectionParameterHandler- Parameters:
value- the user
-
getUser
public String getUser()
Returns the database user.- Specified by:
getUserin interfaceDatabaseConnectionParameterHandler- Returns:
- the user
-
userTipText
public String userTipText()
Returns the tip text for this property.- Specified by:
userTipTextin interfaceDatabaseConnectionParameterHandler- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setPassword
public void setPassword(BasePassword value)
Sets the database password.- Specified by:
setPasswordin interfaceDatabaseConnectionParameterHandler- Specified by:
setPasswordin interfacePasswordSupporter- Parameters:
value- the password
-
getPassword
public BasePassword getPassword()
Returns the database password.- Specified by:
getPasswordin interfaceDatabaseConnectionParameterHandler- Specified by:
getPasswordin interfacePasswordSupporter- Returns:
- the password
-
passwordTipText
public String passwordTipText()
Returns the tip text for this property.- Specified by:
passwordTipTextin interfaceDatabaseConnectionParameterHandler- 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:
generatesin interfaceOutputProducer- Returns:
- weka.core.Instance.class, weka.core.Instances.class
-
reset
protected void reset()
Resets the scheme.- Overrides:
resetin classAbstractActor
-
doExecute
protected String doExecute()
Executes the flow item.- Specified by:
doExecutein classAbstractActor- Returns:
- null if everything is fine, otherwise error message
-
output
public Token output()
Returns the generated token.- Specified by:
outputin interfaceOutputProducer- Returns:
- the generated token
-
hasPendingOutput
public boolean hasPendingOutput()
Checks whether there is pending output to be collected after executing the flow item.- Specified by:
hasPendingOutputin interfaceOutputProducer- Returns:
- true if there is pending output
-
wrapUp
public void wrapUp()
Cleans up after the execution has finished.- Specified by:
wrapUpin interfaceActor- Overrides:
wrapUpin classAbstractActor
-
-