Skip to content

Commit

Permalink
Fix graph's incremental update (#1600)
Browse files Browse the repository at this point in the history
Signed-off-by: songqing <[email protected]>
  • Loading branch information
songqing authored Oct 24, 2023
1 parent 576371a commit c70ff7b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
5 changes: 4 additions & 1 deletion modules/graph/fragment/arrow_fragment_builder_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -1014,6 +1014,7 @@ ArrowFragment<OID_T, VID_T, VERTEX_MAP_T, COMPACT>::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);
}
Expand All @@ -1022,15 +1023,17 @@ ArrowFragment<OID_T, VID_T, VERTEX_MAP_T, COMPACT>::AddEdgesToExistedLabel(
}

auto gen_prev_fn =
[](std::vector<VID_T> vids, arrow::MemoryPool* pool,
[](const std::vector<VID_T>& vids, arrow::MemoryPool* pool,
std::shared_ptr<vid_array_t>& lid_list) -> boost::leaf::result<void> {
ArrowBuilderType<VID_T> builder(pool);
ARROW_OK_OR_RAISE(builder.AppendValues(vids.data(), vids.size()));
ARROW_OK_OR_RAISE(builder.Finish(&lid_list));
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];
Expand Down
10 changes: 4 additions & 6 deletions modules/graph/vertex_map/arrow_vertex_map_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,7 @@ ObjectID ArrowVertexMap<OID_T, VID_T>::updateLabelVertexMap(
}
}
}
prev_oids.clear();
ARROW_CHECK_OK(builder.Finish(&array_to_add));

incremental_array.push_back(prev_array);
Expand All @@ -485,12 +486,9 @@ ObjectID ArrowVertexMap<OID_T, VID_T>::updateLabelVertexMap(
builder.reserve(static_cast<size_t>(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)) {
Expand Down

0 comments on commit c70ff7b

Please sign in to comment.