Method: Cequel::Record::RecordSet#find_rows_in_batches
- Defined in:
- lib/cequel/record/record_set.rb
#find_rows_in_batches(options = {}) {|batch| ... } ⇒ Enumerator, void
Enumerate over batches of row data for the records in this record set.
645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 |
# File 'lib/cequel/record/record_set.rb', line 645 def find_rows_in_batches( = {}, &block) return find_rows_in_single_batch(, &block) if row_limit .assert_valid_keys(:batch_size) batch_size = .fetch(:batch_size, 1000) batch_record_set = base_record_set = limit(batch_size) more_results = true while more_results rows = batch_record_set.find_rows_in_single_batch yield rows if rows.any? more_results = rows.length == batch_size last_row = rows.last if more_results find_nested_batches_from(last_row, , &block) batch_record_set = base_record_set.next_batch_from(last_row) end end end |