Module: Bulkrax::ParserExportRecordSet
- Defined in:
- app/parsers/bulkrax/parser_export_record_set.rb
Overview
This module is responsible for providing the means of querying Solr for the appropriate works, collections, and file sets for an export of entries.
Defined Under Namespace
Classes: All, Base, Collection, Importer, Worktype
Constant Summary collapse
- SOLR_QUERY_PAGE_SIZE =
512
Class Method Summary collapse
-
.for(parser:, export_from:) ⇒ #each, #count
A factory method for returning an object that can yield each id and associated entry_class as well as return the count of objects in the record set.
-
.in_batches(array, page_size: SOLR_QUERY_PAGE_SIZE) {|slice| ... } ⇒ Array<Object>
A helper method for handling querying large batches of IDs.
Class Method Details
.for(parser:, export_from:) ⇒ #each, #count
A factory method for returning an object that can yield each id and associated entry_class as well as return the count of objects in the record set.
20 21 22 |
# File 'app/parsers/bulkrax/parser_export_record_set.rb', line 20 def self.for(parser:, export_from:) "Bulkrax::ParserExportRecordSet::#{export_from.classify}".constantize.new(parser: parser) end |
.in_batches(array, page_size: SOLR_QUERY_PAGE_SIZE) {|slice| ... } ⇒ Array<Object>
A helper method for handling querying large batches of IDs. By default SOLR has a max of 1024 ‘OR` clauses per query. This method helps chunk large sets of IDs into batches.
38 39 40 41 42 43 44 45 46 |
# File 'app/parsers/bulkrax/parser_export_record_set.rb', line 38 def self.in_batches(array, page_size: SOLR_QUERY_PAGE_SIZE) array = Array.wrap(array) return [] if array.empty? results = [] array.each_slice(page_size) do |slice| results += Array.wrap(yield(slice)) end results end |