From aac906079be397e0c123f03dee026a62c1f84220 Mon Sep 17 00:00:00 2001 From: liulx20 <68941872+liulx20@users.noreply.github.com> Date: Wed, 21 Aug 2024 13:57:16 +0800 Subject: [PATCH] fix(interactive): fix some bug with Intersect (#4168) --- flex/engines/graph_db/runtime/common/context.cc | 6 ++---- .../graph_db/runtime/common/operators/intersect.cc | 8 ++++++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/flex/engines/graph_db/runtime/common/context.cc b/flex/engines/graph_db/runtime/common/context.cc index 5a01d79078c3..11d6edf5c54b 100644 --- a/flex/engines/graph_db/runtime/common/context.cc +++ b/flex/engines/graph_db/runtime/common/context.cc @@ -161,10 +161,8 @@ const std::shared_ptr Context::get(int alias) const { return head; } assert(static_cast(alias) < columns.size()); - { - assert(columns[alias] != nullptr); - return columns[alias]; - } + // return nullptr if the column is not set + return columns[alias]; } size_t Context::row_num() const { diff --git a/flex/engines/graph_db/runtime/common/operators/intersect.cc b/flex/engines/graph_db/runtime/common/operators/intersect.cc index e4e7a9c6e9e7..ec98818c5359 100644 --- a/flex/engines/graph_db/runtime/common/operators/intersect.cc +++ b/flex/engines/graph_db/runtime/common/operators/intersect.cc @@ -134,6 +134,7 @@ static Context intersect_impl(std::vector&& ctxs, int key) { return idx_col1.get_value(a) < idx_col1.get_value(b); }); std::vector shuffle_offsets; + std::vector shuffle_offsets_1; size_t idx0 = 0, idx1 = 0; while (idx0 < idx_col0.size() && idx1 < idx_col1.size()) { if (idx_col0.get_value(offsets0[idx0]) < @@ -151,6 +152,7 @@ static Context intersect_impl(std::vector&& ctxs, int key) { auto v1 = vlist1.get_vertex(offsets1[idx1]); if (v0 == v1) { shuffle_offsets.push_back(offsets0[idx0]); + shuffle_offsets_1.push_back(offsets1[idx1]); } else if (v0 < v1) { break; } else { @@ -164,7 +166,13 @@ static Context intersect_impl(std::vector&& ctxs, int key) { } ctxs[0].reshuffle(shuffle_offsets); + ctxs[1].reshuffle(shuffle_offsets_1); ctxs[0].pop_idx_col(); + for (size_t i = 0; i < ctxs[1].col_num(); ++i) { + if (i >= ctxs[0].col_num() || ctxs[0].get(i) == nullptr) { + ctxs[0].set(i, ctxs[1].get(i)); + } + } return ctxs[0]; } }