Debian Codegraph @

plugins/sharding/stream_executor.rb

raw symbols SCIP
1 module Groonga
2 module Sharding
3 class StreamExecutor
4 def initialize(context, shard_executor_class)
5 @context = context
6 @shard_executor_class = shard_executor_class
7 end
8
9 private
10 def each_shard_executor(&block)
11 enumerator = @context.enumerator
12 target_range = enumerator.target_range
13 if @context.order == :descending
14 each_method = :reverse_each
15 else
16 each_method = :each
17 end
18 if @context.need_look_ahead?
19 previous_executor = nil
20 enumerator.send(each_method) do |shard, shard_range|
21 @context.push
22 current_executor = @shard_executor_class.new(@context, shard, shard_range)
23 if previous_executor
24 previous_executor.next_executor = current_executor
25 current_executor.previous_executor = previous_executor
26 yield(previous_executor)
27 @context.shift unless previous_executor.shard.first?
28 end
29 if shard.last?
30 yield(current_executor)
31 @context.shift
32 end
33 previous_executor = current_executor
34 end
35 else
36 enumerator.send(each_method) do |shard, shard_range|
37 @context.push
38 yield(@shard_executor_class.new(@context, shard, shard_range))
39 @context.shift
40 end
41 end
42 end
43 end
44 end
45 end