Class: Embulk::Input::Elasticsearch::InputThread
- Inherits:
-
Object
- Object
- Embulk::Input::Elasticsearch::InputThread
- Defined in:
- lib/embulk/input/elasticsearch/input_thread.rb
Class Method Summary collapse
Class Method Details
.get_slice_from_num_threads(array, define_num_threads) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/embulk/input/elasticsearch/input_thread.rb', line 5 def self.get_slice_from_num_threads(array, define_num_threads) num_threads = array.size < define_num_threads ? array.size : define_num_threads per_queries = if (array.size % num_threads) == 0 (array.size / num_threads) else (array.size / num_threads) + 1 end sliced = array.each_slice(per_queries).to_a Embulk.logger.info("calculate num threads => #{sliced.size}") return sliced end |