Class JdbcSource

java.lang.Object
ca.uqac.lif.cep.Processor
ca.uqac.lif.cep.SynchronousProcessor
ca.uqac.lif.cep.tmf.Source
ca.uqac.lif.cep.jdbc.JdbcSource
All Implemented Interfaces:
ca.uqac.lif.cep.Contextualizable, ca.uqac.lif.cep.Duplicable, ca.uqac.lif.cep.DuplicableProcessor

public class JdbcSource extends ca.uqac.lif.cep.tmf.Source
Converts a query to a database into a trace of named tuples.
  • Nested Class Summary

    Nested classes/interfaces inherited from class ca.uqac.lif.cep.SynchronousProcessor

    ca.uqac.lif.cep.SynchronousProcessor.InputPushable, ca.uqac.lif.cep.SynchronousProcessor.OutputPullable

    Nested classes/interfaces inherited from class ca.uqac.lif.cep.Processor

    ca.uqac.lif.cep.Processor.InternalProcessorState
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected Connection
    The database connection object
    protected boolean
    Whether the tuples of the underlying relation should be output one by one on every call to compute(Object[], Queue), or output all at once on the first call to that method.
    protected boolean
    Remembers whether the query has already been run on the database
    protected final String
    The name of the database table to read from.
    protected ResultSet
    The query's result set, out of which tuples will be extracted one by one
    protected Statement
    The statement object corresponding to the SQL query being executed

    Fields inherited from class ca.uqac.lif.cep.SynchronousProcessor

    m_inputPushables, m_outputPullables, m_tempQueue

    Fields inherited from class ca.uqac.lif.cep.Processor

    m_context, m_hasBeenNotifiedOfEndOfTrace, m_inputArity, m_inputPullables, m_inputQueues, m_notifiedEndOfTraceDownstream, m_outputArity, m_outputPushables, m_outputQueues, MAX_PULL_RETRIES, s_versionString
  • Constructor Summary

    Constructors
    Constructor
    Description
    JdbcSource(Connection conn, String tablename)
    Builds a JDBC source.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected boolean
    compute(Object[] inputs, Queue<Object[]> outputs)
     
    duplicate(boolean with_state)
     
    void
     
    void
    setFeedOneByOne(boolean b)
    Sets whether the tuples of the underlying relation should be output one by one on every call to compute(Object[], Queue), or output all at once on the first call to that method.

    Methods inherited from class ca.uqac.lif.cep.tmf.Source

    push

    Methods inherited from class ca.uqac.lif.cep.SynchronousProcessor

    getPullableOutput, getPushableInput

    Methods inherited from class ca.uqac.lif.cep.Processor

    allNotifiedEndOfTrace, allNull, copyInputQueue, copyOutputQueue, duplicate, duplicateInto, equals, getAt, getContext, getContext, getEmptyQueue, getId, getInputArity, getInputQueue, getInputType, getInputTypesFor, getOutputArity, getOutputQueue, getOutputType, getPullableInput, getPullableOutput, getPushableInput, getPushableOutput, hashCode, leftShift, newContext, onEndOfTrace, or, or, or, printState, readState, rightShift, setContext, setContext, setPullableInput, setPushableOutput, start, startAll, stop, stopAll

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • m_query

      protected final String m_query
      The name of the database table to read from. Actually, this does not need to be a table name, as any SQL expression that returns a table (e.g. a SELECT statement) can do.
    • m_connection

      protected Connection m_connection
      The database connection object
    • m_statement

      protected Statement m_statement
      The statement object corresponding to the SQL query being executed
    • m_resultSet

      protected ResultSet m_resultSet
      The query's result set, out of which tuples will be extracted one by one
    • m_feedOneByOne

      protected boolean m_feedOneByOne
      Whether the tuples of the underlying relation should be output one by one on every call to compute(Object[], Queue), or output all at once on the first call to that method.
    • m_hasRun

      protected boolean m_hasRun
      Remembers whether the query has already been run on the database
  • Constructor Details

    • JdbcSource

      public JdbcSource(Connection conn, String tablename)
      Builds a JDBC source.
      Parameters:
      conn - An open connection on the database
      tablename - The name of the table to be read from. Actually, this does not need to be a table name, as any SQL expression that returns a table (e.g. a SELECT statement) can do.
  • Method Details

    • setFeedOneByOne

      public void setFeedOneByOne(boolean b)
      Sets whether the tuples of the underlying relation should be output one by one on every call to compute(Object[], Queue), or output all at once on the first call to that method. While this has no effect on the end result, it might have an impact on the performance (e.g. if the source outputs a very large number of tuples in the output queue, which must be stored in memory).
      Parameters:
      b - Set to true to feed the tuples one by one, false otherwise
    • compute

      protected boolean compute(Object[] inputs, Queue<Object[]> outputs)
      Specified by:
      compute in class ca.uqac.lif.cep.SynchronousProcessor
    • duplicate

      public JdbcSource duplicate(boolean with_state)
      Specified by:
      duplicate in interface ca.uqac.lif.cep.Duplicable
      Specified by:
      duplicate in class ca.uqac.lif.cep.Processor
    • reset

      public void reset()
      Overrides:
      reset in class ca.uqac.lif.cep.Processor