Class: LogStash::PluginMixins::Jdbc::ExplicitPagingModeStatementHandler

Inherits:
PagedNormalStatementHandler show all
Defined in:
lib/logstash/plugin_mixins/jdbc/statement_handler.rb

Instance Attribute Summary

Attributes inherited from PagedNormalStatementHandler

#jdbc_page_size

Attributes inherited from StatementHandler

#parameters, #statement, #statement_logger

Instance Method Summary collapse

Methods inherited from PagedNormalStatementHandler

#post_init

Methods inherited from StatementHandler

#build_query, build_statement_handler, #initialize, #post_init

Constructor Details

This class inherits a constructor from LogStash::PluginMixins::Jdbc::StatementHandler

Instance Method Details

#perform_query(db, sql_last_value) {|row| ... } ⇒ Object

Performs the query, respecting our pagination settings, yielding once per row of data

Parameters:

  • db (Sequel::Database)
  • sql_last_value (Integer|DateTime|Time)

Yield Parameters:

  • row (Hash{Symbol=>Object})


101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/logstash/plugin_mixins/jdbc/statement_handler.rb', line 101

def perform_query(db, sql_last_value)
  query = build_query(db, sql_last_value)
  offset = 0
  loop do
    rows_in_page = 0
    query.with_sql(query.sql, offset: offset, size: jdbc_page_size).each do |row|
      yield row
      rows_in_page += 1
    end
    break unless rows_in_page == jdbc_page_size
    offset += jdbc_page_size
  end
end