Skip to content

Commit

Permalink
fix(interactive): fix some bug with Intersect (#4168)
Browse files Browse the repository at this point in the history
  • Loading branch information
liulx20 authored Aug 21, 2024
1 parent 0305629 commit aac9060
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
6 changes: 2 additions & 4 deletions flex/engines/graph_db/runtime/common/context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,8 @@ const std::shared_ptr<IContextColumn> Context::get(int alias) const {
return head;
}
assert(static_cast<size_t>(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 {
Expand Down
8 changes: 8 additions & 0 deletions flex/engines/graph_db/runtime/common/operators/intersect.cc
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ static Context intersect_impl(std::vector<Context>&& ctxs, int key) {
return idx_col1.get_value(a) < idx_col1.get_value(b);
});
std::vector<size_t> shuffle_offsets;
std::vector<size_t> 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]) <
Expand All @@ -151,6 +152,7 @@ static Context intersect_impl(std::vector<Context>&& 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 {
Expand All @@ -164,7 +166,13 @@ static Context intersect_impl(std::vector<Context>&& 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];
}
}
Expand Down

0 comments on commit aac9060

Please sign in to comment.