MCPcopy Create free account
hub / github.com/alibaba/zvec / prune_node

Method prune_node

src/core/algorithm/diskann/diskann_algorithm.cc:58–90  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

56}
57
58int DiskAnnAlgorithm::prune_node(diskann_id_t id, DiskAnnContext *ctx) {
59 DistCalculator &dc = ctx->dist_calculator();
60
61 auto neighbors = entity_.get_neighbors(id);
62
63 if (neighbors.first > max_degree_) {
64 std::set<diskann_id_t> dummy_visited;
65 std::vector<Neighbor> dummy_pool(0);
66 std::vector<diskann_id_t> new_out_neighbors;
67
68 for (size_t i = 0; i < neighbors.first; ++i) {
69 diskann_id_t node_id = (neighbors.second)[i];
70
71 auto itr = dummy_visited.find(node_id);
72 if (itr == dummy_visited.end() && node_id != id) {
73 float dist = dc.dist(id, node_id);
74
75 dummy_pool.emplace_back(Neighbor(node_id, dist));
76 dummy_visited.insert(node_id);
77 }
78 }
79
80 prune_neighbors(id, dummy_pool, new_out_neighbors, ctx);
81
82 {
83 auto lock = lock_for(id);
84 int ret = entity_.set_neighbors(id, new_out_neighbors);
85 if (ret != 0) return ret;
86 }
87 }
88
89 return 0;
90}
91
92int DiskAnnAlgorithm::inter_insert(diskann_id_t id,
93 std::vector<diskann_id_t> &pruned_list,

Callers 2

do_pruneMethod · 0.80
TESTFunction · 0.80

Calls 7

NeighborClass · 0.70
get_neighborsMethod · 0.45
findMethod · 0.45
endMethod · 0.45
distMethod · 0.45
insertMethod · 0.45
set_neighborsMethod · 0.45

Tested by 1

TESTFunction · 0.64