Sha256: 584086559fe1796a128a704bcde4c92644d711e4622973c79f7cb06160ebf53a
Contents?: true
Size: 683 Bytes
Versions: 16
Compression:
Stored size: 683 Bytes
Contents
class SampleSkimmer def initialize(num_sample_rows, &callback) @num_sample_rows = num_sample_rows @callback = callback @samples = [] @callback_called = false end def callbacks { during_execute: collect_samples, after_execute: submit_data_if_unsubmitted } end private def collect_samples lambda do |row, row_count| if row_count <= @num_sample_rows @samples << row if row_count == @num_sample_rows @callback.call(@samples) @callback_called = true end end end end def submit_data_if_unsubmitted ->(row_count) { @callback.call(@samples) unless @callback_called } end end
Version data entries
16 entries across 16 versions & 1 rubygems