From 1a315766770abd76c26fc34e2442c7e8c27da26b Mon Sep 17 00:00:00 2001 From: liulx20 <68941872+liulx20@users.noreply.github.com> Date: Thu, 8 Aug 2024 14:12:46 +0800 Subject: [PATCH] fix(interactive): fix bulking load with duplicate vertex id (#4120) --- .../loader/abstract_arrow_fragment_loader.h | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/flex/storages/rt_mutable_graph/loader/abstract_arrow_fragment_loader.h b/flex/storages/rt_mutable_graph/loader/abstract_arrow_fragment_loader.h index 71d12dfeafad..fe297884a21f 100644 --- a/flex/storages/rt_mutable_graph/loader/abstract_arrow_fragment_loader.h +++ b/flex/storages/rt_mutable_graph/loader/abstract_arrow_fragment_loader.h @@ -55,9 +55,14 @@ void set_column(gs::ColumnBase* col, std::shared_ptr array, size_t cur_ind = 0; for (auto j = 0; j < array->num_chunks(); ++j) { auto casted = std::static_pointer_cast(array->chunk(j)); + size_t size = col->size(); for (auto k = 0; k < casted->length(); ++k) { - col->set_any(offset[cur_ind++], - std::move(AnyConverter::to_any(casted->Value(k)))); + if (offset[cur_ind] >= size) { + cur_ind++; + } else { + col->set_any(offset[cur_ind++], + std::move(AnyConverter::to_any(casted->Value(k)))); + } } } } @@ -107,7 +112,7 @@ struct _add_vertex { for (size_t i = 0; i < row_num; ++i) { if (!indexer.add(casted_array->Value(i), vid)) { VLOG(2) << "Duplicate vertex id: " << casted_array->Value(i) << ".."; - offset.emplace_back(std::numeric_limits::max()); + offset.emplace_back(std::numeric_limits::max()); } else { offset.emplace_back(vid); } @@ -120,7 +125,7 @@ struct _add_vertex { std::string_view str_view(str.data(), str.size()); if (!indexer.add(str_view, vid)) { VLOG(2) << "Duplicate vertex id: " << str_view << ".."; - offset.emplace_back(std::numeric_limits::max()); + offset.emplace_back(std::numeric_limits::max()); } else { offset.emplace_back(vid); } @@ -133,7 +138,7 @@ struct _add_vertex { std::string_view str_view(str.data(), str.size()); if (!indexer.add(str_view, vid)) { VLOG(2) << "Duplicate vertex id: " << str_view << ".."; - offset.emplace_back(std::numeric_limits::max()); + offset.emplace_back(std::numeric_limits::max()); } else { offset.emplace_back(vid); }