Class: Ductr::SQLite::BufferedLookup

Inherits:
ETL::BufferedTransform
  • Object
show all
Defined in:
lib/ductr/sqlite/buffered_lookup.rb

Overview

A lookup control that execute the query for a bunch of rows, registered as :buffered. Accept the :buffer_size option, default value is 10 000. You have to implement your own row matching logic:

lookup :some_sqlite_database, :buffered, buffer_size: 42 def my_lookup(db, buffer, &) ids = buffer.map {|row| row[:id]} db[:items].where(item: ids).each do |row| match = buffer.find { |r| r[:id] == row[:item] }

  next yield(row) unless match

  yield(row.merge match)
end

end

Instance Method Summary collapse

Instance Method Details

#on_flush { ... } ⇒ void

This method returns an undefined value.

Opens the database if needed, calls the job's method and pass the each block to it.

Yields:

  • The each block



32
33
34
# File 'lib/ductr/sqlite/buffered_lookup.rb', line 32

def on_flush(&)
  call_method(adapter.db, buffer, &)
end