Skip to content
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
20 changes: 11 additions & 9 deletions src/duckdb/src/execution/index/art/art.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1012,9 +1012,6 @@ void ART::Deserialize(const BlockPointer &pointer) {
}

void ART::SetPrefixCount(const IndexStorageInfo &info) {
auto numeric_max = NumericLimits<uint8_t>().Maximum();
auto max_aligned = AlignValueFloor<uint8_t>(numeric_max - Prefix::METADATA_SIZE);

if (info.IsValid() && info.root_block_ptr.IsValid()) {
prefix_count = Prefix::DEPRECATED_COUNT;
return;
Expand All @@ -1031,13 +1028,18 @@ void ART::SetPrefixCount(const IndexStorageInfo &info) {
compound_size += GetTypeIdSize(type);
}

auto aligned = AlignValue(compound_size) - 1;
if (aligned > NumericCast<idx_t>(max_aligned)) {
prefix_count = max_aligned;
return;
}
// Get the maximum possible prefix size.
// Minus one to index the prefix count (last byte).
auto numeric_max = NumericLimits<uint8_t>().Maximum();
uint8_t max_aligned = AlignValueFloor<uint8_t>(numeric_max - Prefix::METADATA_SIZE) - 1;

// Ceiling of compound size,
// minus one to index the prefix count (last byte).
idx_t key_aligned = AlignValue(compound_size) - 1;

prefix_count = NumericCast<uint8_t>(aligned);
// Set the prefix size to the maximum of the (compound) key size and the maximum prefix size.
bool exceeds_max = key_aligned > NumericCast<idx_t>(max_aligned);
prefix_count = exceeds_max ? max_aligned : NumericCast<uint8_t>(key_aligned);
}

idx_t ART::GetInMemorySize(IndexLock &index_lock) {
Expand Down
6 changes: 3 additions & 3 deletions src/duckdb/src/function/table/version/pragma_version.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef DUCKDB_PATCH_VERSION
#define DUCKDB_PATCH_VERSION "4-dev173"
#define DUCKDB_PATCH_VERSION "4-dev175"
#endif
#ifndef DUCKDB_MINOR_VERSION
#define DUCKDB_MINOR_VERSION 4
Expand All @@ -8,10 +8,10 @@
#define DUCKDB_MAJOR_VERSION 1
#endif
#ifndef DUCKDB_VERSION
#define DUCKDB_VERSION "v1.4.4-dev173"
#define DUCKDB_VERSION "v1.4.4-dev175"
#endif
#ifndef DUCKDB_SOURCE_ID
#define DUCKDB_SOURCE_ID "23dcc0f1f6"
#define DUCKDB_SOURCE_ID "a56ccd8040"
#endif
#include "duckdb/function/table/system_functions.hpp"
#include "duckdb/main/database.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class Prefix {
static constexpr uint8_t ROW_ID_SIZE = sizeof(row_t);
static constexpr uint8_t ROW_ID_COUNT = ROW_ID_SIZE - 1;
static constexpr uint8_t DEPRECATED_COUNT = 15;
// The child pointer and the in_memory boolean.
static constexpr uint8_t METADATA_SIZE = sizeof(Node) + 1;

public:
Expand Down