Skip to content

Commit

Permalink
Fix constant compression in-place check for bools
Browse files Browse the repository at this point in the history
Bools are stored packed in column chunks, so indexing into the data using the size in bytes of the type will not work.
  • Loading branch information
benjaminwinger committed Apr 4, 2024
1 parent fa0ef79 commit d3efe70
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/storage/compression/compression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,16 @@ bool CompressionMetadata::canUpdateInPlace(
switch (compression) {
case CompressionType::CONSTANT: {
// Value can be updated in place only if it is identical to the value already stored.
auto size = getDataTypeSizeInChunk(physicalType);
return memcmp(data + pos * size, this->data.data(), size) == 0;
switch (physicalType) {
case PhysicalTypeID::BOOL: {
return NullMask::isNull(reinterpret_cast<const uint64_t*>(data), pos) ==
*reinterpret_cast<const bool*>(this->data.data());
} break;
default: {
auto size = getDataTypeSizeInChunk(physicalType);
return memcmp(data + pos * size, this->data.data(), size) == 0;
}
}
}
case CompressionType::BOOLEAN_BITPACKING:
case CompressionType::UNCOMPRESSED: {
Expand Down

0 comments on commit d3efe70

Please sign in to comment.