joiner_executor.h
1 // Copyright 2019, Beeri 15. All rights reserved.
2 // Author: Roman Gershman (romange@gmail.com)
3 //
4 
5 #pragma once
6 
7 #include <boost/fiber/unbuffered_channel.hpp>
8 
9 #include "mr/operator_executor.h"
10 
11 namespace mr3 {
12 
14  struct IndexedInput {
15  uint32_t index;
16  const pb::Input::FileSpec* fspec;
17  const pb::WireFormat* wf;
18  };
19 
20  using ShardInput = std::pair<ShardId, std::vector<IndexedInput>>;
21  public:
23  ~JoinerExecutor();
24 
25  void Run(const std::vector<const InputBase*>& inputs, detail::TableBase* tb,
26  ShardFileMap* out_files) final;
27 
28  // Stops the executor in the middle.
29  void Stop() final;
30 
31  private:
32  void InitInternal() final;
33  void CheckInputs(const std::vector<const InputBase*>& inputs);
34 
35  void ProcessInputQ(detail::TableBase* tb);
36 
37  void JoinerFiber();
38 
39  ::boost::fibers::unbuffered_channel<ShardInput> input_q_;
40 
41  std::atomic<uint64_t> finish_shard_latency_sum_{0}, finish_shard_latency_cnt_{0};
42 };
43 
44 } // namespace mr3
Base class for operator executors.
A pool of IoContext objects, representing and managing CPU resources of the system.