Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix VersionInfo SelectionVector creation #4556

Merged
merged 1 commit into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/include/common/data_chunk/sel_vector.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once

#include <string.h>

#include <memory>

#include "common/constants.h"
Expand Down Expand Up @@ -58,6 +60,13 @@ class SelectionVector {
selectedSize = size;
}

// Copies the data in selectedPositions into selectedPositionsBuffer
void makeDynamic() {
memcpy(selectedPositionsBuffer.get(), selectedPositions, selectedSize * sizeof(sel_t));
state = State::DYNAMIC;
selectedPositions = selectedPositionsBuffer.get();
}

std::span<sel_t> getMutableBuffer() const {
return std::span<sel_t>(selectedPositionsBuffer.get(), capacity);
}
Expand Down
5 changes: 5 additions & 0 deletions src/storage/store/version_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ void VectorVersionInfo::getSelVectorForScan(const transaction_t startTS,
selVector.setToFiltered(numSelected);
}
} else if (insertionStatus != InsertionStatus::NO_INSERTED) {
// If there were no deleted values up to this point the selVector may be unfiltered but have
// non-zero size, and the mutable buffer may have arbitrary contents
if (selVector.isUnfiltered()) {
selVector.makeDynamic();
}
for (auto i = 0u; i < numRows; i++) {
if (const auto rowIdx = startRow + i; isInserted(startTS, transactionID, rowIdx) &&
!isDeleted(startTS, transactionID, rowIdx)) {
Expand Down
2 changes: 0 additions & 2 deletions test/test_files/dml_rel/delete/delete_ldbc_sf01.test
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
-DATASET CSV ldbc-sf01
--

# FIX-ME(Guodong): https://github.com/kuzudb/kuzu/issues/4271
-CASE DeleteLikeComment1
-SKIP
-STATEMENT MATCH (n:Person)-[e:likes_Comment]->(m:Comment) WHERE n.id=6597069767457 RETURN COUNT(*);
---- 1
66
Expand Down