| 52 | class LocalGraphClientImpl : public GraphClientImplBase<LocalGraphClientTypes> { |
| 53 | public: |
| 54 | bool Init(const GraphConfig& config) { |
| 55 | resource_.reset(new graph_op::LocalGSOpResource); |
| 56 | |
| 57 | resource_->set_graph_config(config); |
| 58 | |
| 59 | // data |
| 60 | auto graph = InMemoryGraph::Create(config); |
| 61 | if (!graph) { |
| 62 | return false; |
| 63 | } |
| 64 | resource_->set_graph(std::move(graph)); |
| 65 | |
| 66 | auto sampler_source = NewGraphSamplerSource(resource_->graph()); |
| 67 | if (!sampler_source) { |
| 68 | return false; |
| 69 | } |
| 70 | resource_->set_sampler_source(std::move(sampler_source)); |
| 71 | |
| 72 | auto negative_sampler_builder = NewSamplerBuilder( |
| 73 | resource_->sampler_source(), SamplerBuilderEnum::NEGATIVE_SAMPLER, |
| 74 | config.negative_sampler_type(), config.thread_num()); |
| 75 | if (!negative_sampler_builder) { |
| 76 | return false; |
| 77 | } |
| 78 | resource_->set_negative_sampler_builder( |
| 79 | std::move(negative_sampler_builder)); |
| 80 | |
| 81 | auto neighbor_sampler_builder = NewSamplerBuilder( |
| 82 | resource_->sampler_source(), SamplerBuilderEnum::NEIGHBOR_SAMPLER, |
| 83 | config.neighbor_sampler_type(), config.thread_num()); |
| 84 | if (!neighbor_sampler_builder) { |
| 85 | return false; |
| 86 | } |
| 87 | resource_->set_neighbor_sampler_builder( |
| 88 | std::move(neighbor_sampler_builder)); |
| 89 | |
| 90 | // op factory init |
| 91 | factory_ = graph_op::LocalGSOpFactory::GetInstance(); |
| 92 | return factory_->Init(resource_.get()); |
| 93 | } |
| 94 | }; |
| 95 | |
| 96 | std::unique_ptr<GraphClientImpl> NewLocalGraphClientImpl( |
no test coverage detected