| 74 | } |
| 75 | |
| 76 | bool 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 | |
| 98 | bool CacheNodeBuilder::Build(const InMemoryGraph* graph, int cache_type, |
| 99 | double cache_thld, int thread_num) { |
nothing calls this directly
no test coverage detected