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

Method ImportanceCache

src/graph/cache/cache_node_builder.cc:76–96  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

74}
75
76bool CacheNodeBuilder::ImportanceCache(const vec_int_t& nodes, int thread_id) {
77 DXINFO("Thread: %d is processing...", thread_id);
78 for (auto& node : nodes) {
79 int tmp_out_degree = graph_->GetOutDegree(node);
80 int tmp_in_degree = graph_->GetInDegree(node);
81 DXCHECK(tmp_out_degree >= 0 && tmp_in_degree >= 0);
82 float_t node_importance =
83 (tmp_in_degree + 1) / ((tmp_out_degree + 1) * 1.0);
84 if (node_importance <= 0) {
85 DXERROR("Need node:%" PRIu64 " importance factor > 0, got %f.", node,
86 node_importance);
87 return false;
88 }
89 if (node_importance > cache_thld_) {
90 std::lock_guard<std::mutex> guard(mtx_);
91 nodes_.emplace_back(node);
92 }
93 }
94 DXINFO("Done.");
95 return true;
96}
97
98bool CacheNodeBuilder::Build(const InMemoryGraph* graph, int cache_type,
99 double cache_thld, int thread_num) {

Callers

nothing calls this directly

Calls 2

GetOutDegreeMethod · 0.45
GetInDegreeMethod · 0.45

Tested by

no test coverage detected