| @@ 18-32 (lines=15) @@ | ||
| 15 | end |
|
| 16 | ||
| 17 | # Load data for all the indexes |
|
| 18 | def load(indexes, config, show_progress = false, limit = nil, |
|
| 19 | skip_existing = true) |
|
| 20 | indexes.map!(&:to_id_graph).uniq! if @backend.by_id_graph |
|
| 21 | ||
| 22 | simple_indexes = find_simple_indexes indexes, skip_existing |
|
| 23 | simple_indexes.each do |entity, simple_index_list| |
|
| 24 | filename = File.join config[:directory], "#{entity.name}.csv" |
|
| 25 | total_rows = (limit || 0) - 1 # account for header row |
|
| 26 | File.open(filename) { |file| file.each_line { total_rows += 1 } } |
|
| 27 | ||
| 28 | progress = initialize_progress entity, simple_index_list, |
|
| 29 | total_rows if show_progress |
|
| 30 | load_file_indexes filename, entity, simple_index_list, progress |
|
| 31 | end |
|
| 32 | end |
|
| 33 | ||
| 34 | private |
|
| 35 | ||
| @@ 16-24 (lines=9) @@ | ||
| 13 | ||
| 14 | # Load a generated set of indexes with data from MySQL |
|
| 15 | # @return [void] |
|
| 16 | def load(indexes, config, show_progress = false, limit = nil, |
|
| 17 | skip_existing = true) |
|
| 18 | limit = 1 if limit.nil? |
|
| 19 | ||
| 20 | indexes.map!(&:to_id_graph).uniq! if @backend.by_id_graph |
|
| 21 | indexes.uniq.each do |index| |
|
| 22 | load_index index, config, show_progress, limit, skip_existing |
|
| 23 | end |
|
| 24 | end |
|
| 25 | ||
| 26 | private |
|
| 27 | ||