Skip to content

Commit b0093bc

Browse files
committed
vendor: Update vendored sources to duckdb/duckdb@89bcc3e
[Dev] Fix wrong result reported by Roaring Compression `FinalAnalyze` (duckdb/duckdb#15677)
1 parent 2275cd8 commit b0093bc

File tree

4 files changed

+22
-12
lines changed

4 files changed

+22
-12
lines changed

src/duckdb/src/function/table/version/pragma_version.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#ifndef DUCKDB_PATCH_VERSION
2-
#define DUCKDB_PATCH_VERSION "4-dev4489"
2+
#define DUCKDB_PATCH_VERSION "4-dev4492"
33
#endif
44
#ifndef DUCKDB_MINOR_VERSION
55
#define DUCKDB_MINOR_VERSION 1
@@ -8,10 +8,10 @@
88
#define DUCKDB_MAJOR_VERSION 1
99
#endif
1010
#ifndef DUCKDB_VERSION
11-
#define DUCKDB_VERSION "v1.1.4-dev4489"
11+
#define DUCKDB_VERSION "v1.1.4-dev4492"
1212
#endif
1313
#ifndef DUCKDB_SOURCE_ID
14-
#define DUCKDB_SOURCE_ID "31cb6c5582"
14+
#define DUCKDB_SOURCE_ID "89bcc3e2ce"
1515
#endif
1616
#include "duckdb/function/table/system_functions.hpp"
1717
#include "duckdb/main/database.hpp"

src/duckdb/src/include/duckdb/storage/compression/roaring/roaring.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,9 @@ struct RoaringAnalyzeState : public AnalyzeState {
244244
//! Flushed analyze data
245245

246246
//! The space used by the current segment
247-
idx_t space_used = 0;
247+
idx_t data_size = 0;
248+
idx_t metadata_size = 0;
249+
248250
//! The total amount of segments to write
249251
idx_t segment_count = 0;
250252
//! The amount of values in the current segment;

src/duckdb/src/storage/compression/roaring/analyze.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ void RoaringAnalyzeState::Flush(RoaringAnalyzeState &state) {
108108
}
109109

110110
bool RoaringAnalyzeState::HasEnoughSpaceInSegment(idx_t required_space) {
111+
auto space_used = data_size + metadata_size;
111112
D_ASSERT(space_used <= info.GetBlockSize());
112113
idx_t remaining_space = info.GetBlockSize() - space_used;
113114
if (required_space > remaining_space) {
@@ -117,13 +118,15 @@ bool RoaringAnalyzeState::HasEnoughSpaceInSegment(idx_t required_space) {
117118
}
118119

119120
void RoaringAnalyzeState::FlushSegment() {
121+
auto space_used = data_size + metadata_size;
120122
if (!current_count) {
121123
D_ASSERT(!space_used);
122124
return;
123125
}
124126
metadata_collection.FlushSegment();
125127
total_size += space_used;
126-
space_used = 0;
128+
data_size = 0;
129+
metadata_size = 0;
127130
current_count = 0;
128131
segment_count++;
129132
}
@@ -146,15 +149,14 @@ void RoaringAnalyzeState::FlushContainer() {
146149
arrays_count++;
147150
}
148151

149-
idx_t required_space = metadata_collection.GetMetadataSize(runs_count + arrays_count, runs_count, arrays_count);
152+
metadata_size = metadata_collection.GetMetadataSize(runs_count + arrays_count, runs_count, arrays_count);
150153

151-
required_space += metadata.GetDataSizeInBytes(count);
152-
if (!HasEnoughSpaceInSegment(required_space)) {
154+
data_size += metadata.GetDataSizeInBytes(count);
155+
if (!HasEnoughSpaceInSegment(metadata_size + data_size)) {
153156
FlushSegment();
154157
}
155158
container_metadata.push_back(metadata);
156159
metadata_collection.AddMetadata(metadata);
157-
space_used += required_space;
158160
current_count += count;
159161

160162
// Reset the container analyze state

src/duckdb/src/storage/table/column_data_checkpointer.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "duckdb/storage/data_table.hpp"
66
#include "duckdb/parser/column_definition.hpp"
77
#include "duckdb/storage/table/scan_state.hpp"
8+
#include "duckdb/main/database.hpp"
89

910
namespace duckdb {
1011

@@ -240,14 +241,19 @@ vector<CheckpointAnalyzeResult> ColumnDataCheckpointer::DetectBestCompressionMet
240241
}
241242
}
242243

244+
auto &checkpoint_state = checkpoint_states[i];
245+
auto &col_data = checkpoint_state.get().column_data;
243246
if (!chosen_state) {
244-
auto &checkpoint_state = checkpoint_states[i];
245-
auto &col_data = checkpoint_state.get().column_data;
246247
throw FatalException("No suitable compression/storage method found to store column of type %s",
247248
col_data.type.ToString());
248249
}
249250
D_ASSERT(compression_idx != DConstants::INVALID_INDEX);
250-
result[i] = CheckpointAnalyzeResult(std::move(chosen_state), *functions[compression_idx]);
251+
252+
auto &best_function = *functions[compression_idx];
253+
Logger::Info(db, "FinalAnalyze(%s) result for %s.%s.%d(%s): %d", EnumUtil::ToString(best_function.type),
254+
col_data.info.GetSchemaName(), col_data.info.GetTableName(), col_data.column_index,
255+
col_data.type.ToString(), best_score);
256+
result[i] = CheckpointAnalyzeResult(std::move(chosen_state), best_function);
251257
}
252258
return result;
253259
}

0 commit comments

Comments
 (0)