Skip to content

Commit

Permalink
Fix VersionInfo SelVector creation (#4556)
Browse files Browse the repository at this point in the history
One branch of the code was setting the existing SelectionVector to filtered and then appending to it
Existing unfiltered elements would be discarded and replaced with whatever happened to be in the SelectionVector's mutable buffer
  • Loading branch information
benjaminwinger authored and ray6080 committed Dec 17, 2024
1 parent ba6b100 commit bfb3cfa
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
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

0 comments on commit bfb3cfa

Please sign in to comment.