Class: LogStash::PluginMixins::Jdbc::PagedNormalStatementHandler

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

Direct Known Subclasses

ExplicitPagingModeStatementHandler

Instance Attribute Summary

Attributes inherited from NormalStatementHandler

#parameters

Attributes inherited from StatementHandler

#parameters, #statement

Instance Method Summary collapse

Methods inherited from StatementHandler

#build_query, build_statement_handler

Constructor Details

#initialize(plugin) ⇒ PagedNormalStatementHandler

Returns a new instance of PagedNormalStatementHandler.



74
75
76
77
78
# File 'lib/logstash/plugin_mixins/jdbc/statement_handler.rb', line 74

def initialize(plugin)
  super(plugin)
  @jdbc_page_size = plugin.jdbc_page_size
  @logger = plugin.logger
end

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


84
85
86
87
88
89
90
91
92
# File 'lib/logstash/plugin_mixins/jdbc/statement_handler.rb', line 84

def perform_query(db, sql_last_value)
  query = build_query(db, sql_last_value)
  query.each_page(@jdbc_page_size) do |paged_dataset|
    log_dataset_page(paged_dataset) if @logger.debug?
    paged_dataset.each do |row|
      yield row
    end
  end
end