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 NormalStatementHandler

#parameters

Attributes inherited from StatementHandler

#parameters, #statement

Instance Method Summary collapse

Methods inherited from PagedNormalStatementHandler

#initialize

Methods inherited from NormalStatementHandler

#initialize

Methods inherited from StatementHandler

#build_query, build_statement_handler, #initialize

Constructor Details

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

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})


110
111
112
113
114
115
116
117
118
119
120
121
122
123
# File 'lib/logstash/plugin_mixins/jdbc/statement_handler.rb', line 110

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