Scanner C++ API
load_worker.h
1 /* Copyright 2016 Carnegie Mellon University
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #pragma once
17 
18 #include "scanner/engine/runtime.h"
19 #include "scanner/engine/source_factory.h"
20 #include "scanner/engine/table_meta_cache.h"
21 #include "scanner/util/common.h"
22 #include "scanner/util/queue.h"
23 #include "scanner/util/thread_pool.h"
24 #include "scanner/api/source.h"
25 #include "scanner/api/enumerator.h"
26 
27 namespace scanner {
28 namespace internal {
29 
31  // Uniform arguments
32  i32 node_id;
33  TableMetaCache& table_meta;
34  // Per worker arguments
35  int worker_id;
36  storehouse::StorageConfig* storage_config;
37  Profiler& profiler;
38  proto::Result& result;
39  i32 io_packet_size;
40  i32 work_packet_size;
41  std::vector<SourceFactory*> source_factories;
42  std::vector<SourceConfig> source_configs;
43 };
44 
45 class LoadWorker {
46  public:
47  LoadWorker(const LoadWorkerArgs& args);
48 
49  void feed(LoadWorkEntry& input_entry);
50 
51  bool yield(i32 item_size, EvalWorkEntry& output_entry);
52 
53  bool done();
54 
55  private:
56  const i32 node_id_;
57  const i32 worker_id_;
58  Profiler& profiler_;
59  i32 io_packet_size_;
60  i32 work_packet_size_;
61  i32 num_columns_;
62  std::vector<SourceConfig> source_configs_;
63  std::vector<std::unique_ptr<Source>>
64  sources_; // Provides the implementation for reading
65  // data under the specified data sources
66  std::vector<std::string> source_names_;
67  ThreadPool thread_pool_;
68 
69  // Continuation state
70  bool first_item_;
71  bool needs_configure_;
72  bool needs_reset_;
73  LoadWorkEntry entry_;
74  i64 current_row_;
75  i64 total_rows_;
76 };
77 
78 }
79 }
Definition: load_worker.h:30
Definition: profiler.h:40
Definition: database.cpp:36
Definition: table_meta_cache.h:26
Definition: runtime.h:44
Definition: load_worker.h:45