| 64 | } |
| 65 | |
| 66 | class AverageFeatureMain : public MainUtil { |
| 67 | private: |
| 68 | std::unique_ptr<GraphClient> graph_client_; |
| 69 | GraphConfig graph_config_; |
| 70 | |
| 71 | int batch_node_; |
| 72 | int count_; |
| 73 | std::string entry_flag_; |
| 74 | |
| 75 | public: |
| 76 | ~AverageFeatureMain() override = default; |
| 77 | |
| 78 | bool Init() override { |
| 79 | if (FLAGS_dist) { |
| 80 | graph_config_.set_ip_ports(FLAGS_gs_addrs); |
| 81 | } else { |
| 82 | graph_config_.set_node_graph(FLAGS_node_graph); |
| 83 | graph_config_.set_node_feature(FLAGS_node_feature); |
| 84 | graph_config_.set_node_config(FLAGS_node_config); |
| 85 | graph_config_.set_thread_num(FLAGS_gs_thread_num); |
| 86 | } |
| 87 | |
| 88 | graph_client_ = NewGraphClient(graph_config_, (GraphClientEnum)FLAGS_dist); |
| 89 | // if (!graph_client_->Init(config_)) { |
| 90 | if (!graph_client_) { |
| 91 | return false; |
| 92 | } |
| 93 | |
| 94 | // used by RunEntry |
| 95 | batch_node_ = FLAGS_batch_node; |
| 96 | count_ = FLAGS_sample_num; |
| 97 | entry_flag_ = FLAGS_dist ? "Worker" : "Thread"; |
| 98 | return true; |
| 99 | } |
| 100 | |
| 101 | private: |
| 102 | const char* task_name() const noexcept override { return "AverageFeature"; } |
| 103 | |
| 104 | bool RunEntry(int entry_id, const vec_str_t& files, |
| 105 | const std::string& out) override { |
| 106 | DXINFO("%s id: %d is processing ...", entry_flag_.c_str(), entry_id); |
| 107 | |
| 108 | LineParser line_parser; |
| 109 | deepx_core::AutoOutputFileStream ofs; |
| 110 | std::ostringstream oss; |
| 111 | for (const auto& file : files) { |
| 112 | DXINFO("Processed file: %s", file.c_str()); |
| 113 | if (!line_parser.Open(file)) { |
| 114 | return false; |
| 115 | } |
| 116 | |
| 117 | auto out_file = deepx_core::GetOutputPredictFile(out, file); |
| 118 | if (!ofs.Open(out_file)) { |
| 119 | return false; |
| 120 | } |
| 121 | |
| 122 | // averaging feature |
| 123 | std::vector<NodeValue> values; |
nothing calls this directly
no outgoing calls
no test coverage detected