Class: KMDB::Jobs::ParseFile
- Defined in:
- lib/kmdb/jobs/parse_file.rb
Overview
Reads a file from disk, queues jobs for chunks of events.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(file) ⇒ ParseFile
constructor
A new instance of ParseFile.
- #work ⇒ Object
Constructor Details
#initialize(file) ⇒ ParseFile
Returns a new instance of ParseFile.
21 22 23 |
# File 'lib/kmdb/jobs/parse_file.rb', line 21 def initialize(file) @file = file end |
Class Method Details
Instance Method Details
#work ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/kmdb/jobs/parse_file.rb', line 25 def work current_batch = [] current_stamp = nil _each_event_in_file(@file) do |event| if event.nil? _save_batch(current_batch) true elsif current_batch.length > _batch_size && event['_t'] != current_stamp _save_batch(current_batch) current_batch << event true else current_batch << event false end end end |