Skip to content
Snippets Groups Projects
Commit 298a2486 authored by Valery Sizov's avatar Valery Sizov
Browse files

Merge branch 'feature/yield-batch-and-total-while-indexing' into 'master'

Yield current batch and total count when indexing

When indexing large repos, there's no indication of progress in the logs, there's only start and finish events, which could give an indication of a stuck progress. With this change we can show that there's something happening.

See merge request !19
parents 78b6dd89 5fabe7ca
No related branches found
No related tags found
1 merge request!19Yield current batch and total count when indexing
Pipeline #
Loading
Loading
@@ -91,8 +91,9 @@ module Elasticsearch
from, to = parse_revs(from_rev, to_rev)
 
diff = repository_for_indexing.diff(from, to)
deltas = diff.deltas
 
diff.deltas.reverse.each_slice(BLOBS_BATCH) do |slice|
deltas.reverse.each_slice(BLOBS_BATCH) do |slice|
bulk_operations = slice.map do |delta|
if delta.status == :deleted
next if delta.old_file[:mode].to_s(8) == "160000"
Loading
Loading
@@ -106,6 +107,8 @@ module Elasticsearch
end
 
perform_bulk bulk_operations
yield slice, deltas.length if block_given?
end
 
ObjectSpace.garbage_collect
Loading
Loading
@@ -205,6 +208,8 @@ module Elasticsearch
end
 
perform_bulk bulk_operations
yield batch, commit_oids.length if block_given?
end
 
ObjectSpace.garbage_collect
Loading
Loading
Loading
Loading
@@ -106,4 +106,31 @@ describe TestRepository do
expect(TestRepository.__elasticsearch__.search('test').results.count).to eq(6)
expect(repo.search('test')[:commits][:total_count]).to eq(3)
end
it "yields current batch and total length when indexing commits" do
count = 0
total = 0
repo.index_commits do |batch, total_count|
count += batch.length
total = total_count
end
expect(count).to be > 0
expect(count).to eq(total)
end
it "yields current batch and total length when indexing blobs" do
count = 0
total = 0
repo.index_blobs do |batch, total_count|
count += batch.length
total = total_count
end
expect(count).to be > 0
expect(count).to eq(total)
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment