Module: Droonga::Searcher::RecordsFormattable

Included in:
ComplexRecordsFormatter, SimpleRecordsFormatter
Defined in:
lib/droonga/searcher.rb

Instance Method Summary collapse

Instance Method Details

#format(output_target_attributes, records, output_limit, output_offset) ⇒ Object



546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
# File 'lib/droonga/searcher.rb', line 546

def format(output_target_attributes, records, output_limit, output_offset)
  if output_offset >= records.size
    # to avoid Groonga::TooLargeOffset error, we have to create a blank result manually.
    output_offset = output_limit = 0
  end
  cursor_options = {
    :offset => output_offset,
    :limit  => output_limit,
  }
  formatted_records = nil
  records.open_cursor(cursor_options) do |cursor|
    formatted_records = cursor.collect do |record|
      format_record(output_target_attributes, record)
    end
  end
  formatted_records
end