MCPcopy Create free account
hub / github.com/Tencent/embedx / Init

Method Init

src/graph/client/local_graph_client_impl.cc:54–93  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

52class 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
96std::unique_ptr<GraphClientImpl> NewLocalGraphClientImpl(

Callers 1

NewLocalGraphClientImplFunction · 0.45

Calls 12

NewGraphSamplerSourceFunction · 0.85
NewSamplerBuilderFunction · 0.85
set_graph_configMethod · 0.80
set_graphMethod · 0.80
graphMethod · 0.80
neighbor_sampler_typeMethod · 0.80
set_sampler_sourceMethod · 0.45
sampler_sourceMethod · 0.45
negative_sampler_typeMethod · 0.45
thread_numMethod · 0.45

Tested by

no test coverage detected