From c70ff7b3ea7728ba49042c53edba9a41ba6377bf Mon Sep 17 00:00:00 2001 From: Songqing Zhang Date: Tue, 24 Oct 2023 15:01:17 +0800 Subject: [PATCH] Fix graph's incremental update (#1600) Signed-off-by: songqing --- modules/graph/fragment/arrow_fragment_builder_impl.h | 5 ++++- modules/graph/vertex_map/arrow_vertex_map_impl.h | 10 ++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/modules/graph/fragment/arrow_fragment_builder_impl.h b/modules/graph/fragment/arrow_fragment_builder_impl.h index bc04b31cd..29e081847 100644 --- a/modules/graph/fragment/arrow_fragment_builder_impl.h +++ b/modules/graph/fragment/arrow_fragment_builder_impl.h @@ -1014,6 +1014,7 @@ ArrowFragment::AddEdgesToExistedLabel( } else { if (vis.count(std::to_string(src_id) + std::to_string(dst_id))) continue; + vis[std::to_string(src_id) + std::to_string(dst_id)] = 1; prev_src_ids.push_back(src_id); prev_dst_ids.push_back(dst_id); } @@ -1022,7 +1023,7 @@ ArrowFragment::AddEdgesToExistedLabel( } auto gen_prev_fn = - [](std::vector vids, arrow::MemoryPool* pool, + [](const std::vector& vids, arrow::MemoryPool* pool, std::shared_ptr& lid_list) -> boost::leaf::result { ArrowBuilderType builder(pool); ARROW_OK_OR_RAISE(builder.AppendValues(vids.data(), vids.size())); @@ -1030,7 +1031,9 @@ ArrowFragment::AddEdgesToExistedLabel( return {}; }; gen_prev_fn(prev_src_ids, pool, prev_src_id_list); + prev_src_ids.clear(); gen_prev_fn(prev_dst_ids, pool, prev_dst_id_list); + prev_dst_ids.clear(); // check duplicates auto src_id_array = edge_src[0]; auto dst_id_array = edge_dst[0]; diff --git a/modules/graph/vertex_map/arrow_vertex_map_impl.h b/modules/graph/vertex_map/arrow_vertex_map_impl.h index 91e0fa3e1..7cbf0bc95 100644 --- a/modules/graph/vertex_map/arrow_vertex_map_impl.h +++ b/modules/graph/vertex_map/arrow_vertex_map_impl.h @@ -461,6 +461,7 @@ ObjectID ArrowVertexMap::updateLabelVertexMap( } } } + prev_oids.clear(); ARROW_CHECK_OK(builder.Finish(&array_to_add)); incremental_array.push_back(prev_array); @@ -485,12 +486,9 @@ ObjectID ArrowVertexMap::updateLabelVertexMap( builder.reserve(static_cast(vnum)); for (int64_t k = 0; k < vnum; ++k) { // check whether has been added before - if (o2g_[fid][label_id].find(array->GetView(k)) != - o2g_[fid][label_id].end()) { - auto it = o2g_[fid][label_id].find(array->GetView(k)); - if (it != o2g_[fid][label_id].end()) { - builder.emplace(array->GetView(k), it->second); - } + auto it = o2g_[fid][label_id].find(array->GetView(k)); + if (it != o2g_[fid][label_id].end()) { + builder.emplace(array->GetView(k), it->second); continue; } if (!builder.emplace(array->GetView(k), cur_gid)) {