Autonomy Software C++ 24.5.1
Welcome to the Autonomy Software repository of the Mars Rover Design Team (MRDT) at Missouri University of Science and Technology (Missouri S&T)! API reference contains the source code and other resources for the development of the autonomy software for our Mars rover. The Autonomy Software project aims to compete in the University Rover Challenge (URC) by demonstrating advanced autonomous capabilities and robust navigation algorithms.
Loading...
Searching...
No Matches
duckdb::FSSTStorage Struct Reference

Static Public Member Functions

static unique_ptr< AnalyzeState > StringInitAnalyze (ColumnData &col_data, PhysicalType type)
static bool StringAnalyze (AnalyzeState &state_p, Vector &input, idx_t count)
static idx_t StringFinalAnalyze (AnalyzeState &state_p)
static unique_ptr< CompressionState > InitCompression (ColumnDataCheckpointData &checkpoint_data, unique_ptr< AnalyzeState > analyze_state_p)
static void Compress (CompressionState &state_p, Vector &scan_vector, idx_t count)
static void FinalizeCompress (CompressionState &state_p)
static unique_ptr< SegmentScanState > StringInitScan (const QueryContext &context, ColumnSegment &segment)
template<bool ALLOW_FSST_VECTORS = false>
static void StringScanPartial (ColumnSegment &segment, ColumnScanState &state, idx_t scan_count, Vector &result, idx_t result_offset)
static void StringScan (ColumnSegment &segment, ColumnScanState &state, idx_t scan_count, Vector &result)
static void StringFetchRow (ColumnSegment &segment, ColumnFetchState &state, row_t row_id, Vector &result, idx_t result_idx)
static void Select (ColumnSegment &segment, ColumnScanState &state, idx_t vector_count, Vector &result, const SelectionVector &sel, idx_t sel_count)
static void SetDictionary (ColumnSegment &segment, BufferHandle &handle, StringDictionaryContainer container)
static StringDictionaryContainer GetDictionary (ColumnSegment &segment, BufferHandle &handle)
static char * FetchStringPointer (StringDictionaryContainer dict, data_ptr_t baseptr, int32_t dict_offset)
static bp_delta_offsets_t CalculateBpDeltaOffsets (int64_t last_known_row, idx_t start, idx_t scan_count)
static bool ParseFSSTSegmentHeader (data_ptr_t base_ptr, duckdb_fsst_decoder_t *decoder_out, bitpacking_width_t *width_out, const idx_t block_size)
static bp_delta_offsets_t StartScan (FSSTScanState &scan_state, data_ptr_t base_data, idx_t start, idx_t vector_count)
static void EndScan (FSSTScanState &scan_state, bp_delta_offsets_t &offsets, idx_t start, idx_t scan_count)

Static Public Attributes

static constexpr double MINIMUM_COMPRESSION_RATIO = 1.2
static constexpr double ANALYSIS_SAMPLE_SIZE = 0.25

Member Function Documentation

◆ StringInitAnalyze()

unique_ptr< AnalyzeState > duckdb::FSSTStorage::StringInitAnalyze ( ColumnData & col_data,
PhysicalType type )
static
400989 {
400990 auto &storage_manager = col_data.GetStorageManager();
400991 if (storage_manager.GetStorageVersion() >= 5) {
400992 // dict_fsst introduced - disable fsst
400993 return nullptr;
400994 }
400995
400996 CompressionInfo info(col_data.GetBlockManager());
400997 return make_uniq<FSSTAnalyzeState>(info);
400998}

◆ StringAnalyze()

bool duckdb::FSSTStorage::StringAnalyze ( AnalyzeState & state_p,
Vector & input,
idx_t count )
static
401000 {
401001 auto &state = state_p.Cast<FSSTAnalyzeState>();
401002 UnifiedVectorFormat vdata;
401003 input.ToUnifiedFormat(count, vdata);
401004
401005 state.count += count;
401006 auto data = UnifiedVectorFormat::GetData<string_t>(vdata);
401007
401008 // Note that we ignore the sampling in case we have not found any valid strings yet, this solves the issue of
401009 // not having seen any valid strings here leading to an empty fsst symbol table.
401010 bool sample_selected = !state.have_valid_row || state.random_engine.NextRandom() < ANALYSIS_SAMPLE_SIZE;
401011
401012 for (idx_t i = 0; i < count; i++) {
401013 auto idx = vdata.sel->get_index(i);
401014
401015 if (!vdata.validity.RowIsValid(idx)) {
401016 continue;
401017 }
401018
401019 // We need to check all strings for this, otherwise we run in to trouble during compression if we miss ones
401020 auto string_size = data[idx].GetSize();
401021 if (string_size >= StringUncompressed::GetStringBlockLimit(state.info.GetBlockSize())) {
401022 return false;
401023 }
401024
401025 if (!sample_selected) {
401026 continue;
401027 }
401028
401029 if (string_size > 0) {
401030 state.have_valid_row = true;
401031 if (data[idx].IsInlined()) {
401032 state.fsst_strings.push_back(data[idx]);
401033 } else {
401034 state.fsst_strings.emplace_back(state.fsst_string_heap.AddBlob(data[idx]));
401035 }
401036 state.fsst_string_total_size += string_size;
401037 } else {
401038 state.empty_strings++;
401039 }
401040 }
401041 return true;
401042}
uint64_t idx_t
a saner size_t for loop indices etc
Definition duckdb.hpp:237

◆ StringFinalAnalyze()

idx_t duckdb::FSSTStorage::StringFinalAnalyze ( AnalyzeState & state_p)
static
401044 {
401045 auto &state = state_p.Cast<FSSTAnalyzeState>();
401046
401047 size_t compressed_dict_size = 0;
401048 size_t max_compressed_string_length = 0;
401049
401050 auto string_count = state.fsst_strings.size();
401051
401052 if (!string_count) {
401054 }
401055
401056 size_t output_buffer_size = 7 + 2 * state.fsst_string_total_size; // size as specified in fsst.h
401057
401058 vector<size_t> fsst_string_sizes;
401059 vector<unsigned char *> fsst_string_ptrs;
401060 for (auto &str : state.fsst_strings) {
401061 fsst_string_sizes.push_back(str.GetSize());
401062 fsst_string_ptrs.push_back((unsigned char *)str.GetData()); // NOLINT
401063 }
401064
401065 state.fsst_encoder = duckdb_fsst_create(string_count, &fsst_string_sizes[0], &fsst_string_ptrs[0], 0);
401066
401067 // TODO: do we really need to encode to get a size estimate?
401068 auto compressed_ptrs = vector<unsigned char *>(string_count, nullptr);
401069 auto compressed_sizes = vector<size_t>(string_count, 0);
401070 unique_ptr<unsigned char[]> compressed_buffer(new unsigned char[output_buffer_size]);
401071
401072 auto res =
401073 duckdb_fsst_compress(state.fsst_encoder, string_count, &fsst_string_sizes[0], &fsst_string_ptrs[0],
401074 output_buffer_size, compressed_buffer.get(), &compressed_sizes[0], &compressed_ptrs[0]);
401075
401076 if (string_count != res) {
401077 throw std::runtime_error("FSST output buffer is too small unexpectedly");
401078 }
401079
401080 // Sum and and Max compressed lengths
401081 for (auto &size : compressed_sizes) {
401082 compressed_dict_size += size;
401083 max_compressed_string_length = MaxValue(max_compressed_string_length, size);
401084 }
401085 D_ASSERT(compressed_dict_size ==
401086 (uint64_t)(compressed_ptrs[res - 1] - compressed_ptrs[0]) + compressed_sizes[res - 1]);
401087
401088 auto minimum_width = BitpackingPrimitives::MinimumBitWidth(max_compressed_string_length);
401089 auto bitpacked_offsets_size =
401090 BitpackingPrimitives::GetRequiredSize(string_count + state.empty_strings, minimum_width);
401091
401092 auto estimated_base_size = double(bitpacked_offsets_size + compressed_dict_size) * (1 / ANALYSIS_SAMPLE_SIZE);
401093 auto num_blocks = estimated_base_size / double(state.info.GetBlockSize() - sizeof(duckdb_fsst_decoder_t));
401094 auto symtable_size = num_blocks * sizeof(duckdb_fsst_decoder_t);
401095 auto estimated_size = estimated_base_size + symtable_size;
401096
401097 return LossyNumericCast<idx_t>(estimated_size * MINIMUM_COMPRESSION_RATIO);
401098}
GOpaque< Size > size(const GMat &src)
static constexpr const idx_t INVALID_INDEX
The value used to signify an invalid index entry.
Definition duckdb.hpp:1117

◆ InitCompression()

unique_ptr< CompressionState > duckdb::FSSTStorage::InitCompression ( ColumnDataCheckpointData & checkpoint_data,
unique_ptr< AnalyzeState > analyze_state_p )
static
401310 {
401311 auto &analyze_state = analyze_state_p->Cast<FSSTAnalyzeState>();
401312 auto compression_state = make_uniq<FSSTCompressionState>(checkpoint_data, analyze_state.info);
401313
401314 if (analyze_state.fsst_encoder == nullptr) {
401315 throw InternalException("No encoder found during FSST compression");
401316 }
401317
401318 compression_state->fsst_encoder = analyze_state.fsst_encoder;
401319 compression_state->fsst_serialized_symbol_table_size =
401320 duckdb_fsst_export(compression_state->fsst_encoder, &compression_state->fsst_serialized_symbol_table[0]);
401321 analyze_state.fsst_encoder = nullptr;
401322
401323 return std::move(compression_state);
401324}

◆ Compress()

void duckdb::FSSTStorage::Compress ( CompressionState & state_p,
Vector & scan_vector,
idx_t count )
static
401326 {
401327 auto &state = state_p.Cast<FSSTCompressionState>();
401328
401329 // Get vector data
401330 UnifiedVectorFormat vdata;
401331 scan_vector.ToUnifiedFormat(count, vdata);
401332 auto data = UnifiedVectorFormat::GetData<string_t>(vdata);
401333
401334 // Collect pointers to strings to compress
401335 vector<size_t> sizes_in;
401336 vector<unsigned char *> strings_in;
401337 size_t total_size = 0;
401338 idx_t total_count = 0;
401339 for (idx_t i = 0; i < count; i++) {
401340 auto idx = vdata.sel->get_index(i);
401341
401342 // Note: we treat nulls and empty strings the same
401343 const bool is_null = !vdata.validity.RowIsValid(idx);
401344 if (is_null || data[idx].GetSize() == 0) {
401345 continue;
401346 }
401347
401348 total_count++;
401349 total_size += data[idx].GetSize();
401350 sizes_in.push_back(data[idx].GetSize());
401351 strings_in.push_back((unsigned char *)data[idx].GetData()); // NOLINT
401352 }
401353
401354 // Only Nulls or empty strings in this vector, nothing to compress
401355 if (total_count == 0) {
401356 for (idx_t i = 0; i < count; i++) {
401357 auto idx = vdata.sel->get_index(i);
401358 if (!vdata.validity.RowIsValid(idx)) {
401359 state.AddNull();
401360 } else if (data[idx].GetSize() == 0) {
401361 state.AddEmptyString();
401362 } else {
401363 throw FatalException("FSST: no encoder found even though there are values to encode");
401364 }
401365 }
401366 return;
401367 }
401368
401369 // Compress buffers
401370 size_t compress_buffer_size = MaxValue<size_t>(total_size * 2 + 7, 1);
401371 vector<unsigned char *> strings_out(total_count, nullptr);
401372 vector<size_t> sizes_out(total_count, 0);
401373 vector<unsigned char> compress_buffer(compress_buffer_size, 0);
401374
401375 auto res = duckdb_fsst_compress(
401376 state.fsst_encoder, /* IN: encoder obtained from duckdb_fsst_create(). */
401377 total_count, /* IN: number of strings in batch to compress. */
401378 &sizes_in[0], /* IN: byte-lengths of the inputs */
401379 &strings_in[0], /* IN: input string start pointers. */
401380 compress_buffer_size, /* IN: byte-length of output buffer. */
401381 &compress_buffer[0], /* OUT: memory buffer to put the compressed strings in (one after the other). */
401382 &sizes_out[0], /* OUT: byte-lengths of the compressed strings. */
401383 &strings_out[0] /* OUT: output string start pointers. Will all point into [output,output+size). */
401384 );
401385
401386 if (res != total_count) {
401387 throw FatalException("FSST compression failed to compress all strings");
401388 }
401389
401390 // Push the compressed strings to the compression state one by one
401391 idx_t compressed_idx = 0;
401392 for (idx_t i = 0; i < count; i++) {
401393 auto idx = vdata.sel->get_index(i);
401394 if (!vdata.validity.RowIsValid(idx)) {
401395 state.AddNull();
401396 } else if (data[idx].GetSize() == 0) {
401397 state.AddEmptyString();
401398 } else {
401399 state.UpdateState(data[idx], strings_out[compressed_idx], sizes_out[compressed_idx]);
401400 compressed_idx++;
401401 }
401402 }
401403}

◆ FinalizeCompress()

void duckdb::FSSTStorage::FinalizeCompress ( CompressionState & state_p)
static
401405 {
401406 auto &state = state_p.Cast<FSSTCompressionState>();
401407 state.Flush(true);
401408}

◆ StringInitScan()

unique_ptr< SegmentScanState > duckdb::FSSTStorage::StringInitScan ( const QueryContext & context,
ColumnSegment & segment )
static
401463 {
401464 auto block_size = segment.GetBlockSize();
401465 auto string_block_limit = StringUncompressed::GetStringBlockLimit(block_size);
401466 auto state = make_uniq<FSSTScanState>(string_block_limit);
401467 auto &buffer_manager = BufferManager::GetBufferManager(segment.db);
401468 state->handle = buffer_manager.Pin(segment.block);
401469 auto base_ptr = state->handle.Ptr() + segment.GetBlockOffset();
401470
401471 state->duckdb_fsst_decoder = make_buffer<duckdb_fsst_decoder_t>();
401472 auto decoder = reinterpret_cast<duckdb_fsst_decoder_t *>(state->duckdb_fsst_decoder.get());
401473 auto retval = ParseFSSTSegmentHeader(base_ptr, decoder, &state->current_width, block_size);
401474 if (!retval) {
401475 state->duckdb_fsst_decoder = nullptr;
401476 }
401477 state->duckdb_fsst_decoder_ptr = state->duckdb_fsst_decoder.get();
401478
401479 const auto &stats = segment.stats.statistics;
401480 if (stats.GetStatsType() == StatisticsType::STRING_STATS && StringStats::HasMaxStringLength(stats)) {
401481 state->all_values_inlined = StringStats::MaxStringLength(stats) <= string_t::INLINE_LENGTH;
401482 }
401483
401484 return std::move(state);
401485}
static DUCKDB_API uint32_t MaxStringLength(const BaseStatistics &stats)
Returns the maximum string length, or throws an exception if !HasMaxStringLength().
Definition duckdb.cpp:424560
static DUCKDB_API bool HasMaxStringLength(const BaseStatistics &stats)
Whether or not the statistics have a maximum string length defined.
Definition duckdb.cpp:424553

◆ StringScanPartial()

template<bool ALLOW_FSST_VECTORS>
void duckdb::FSSTStorage::StringScanPartial ( ColumnSegment & segment,
ColumnScanState & state,
idx_t scan_count,
Vector & result,
idx_t result_offset )
static
401534 {
401535 auto &scan_state = state.scan_state->Cast<FSSTScanState>();
401536 auto start = state.GetPositionInSegment();
401537
401538 bool enable_fsst_vectors;
401539 if (ALLOW_FSST_VECTORS) {
401540 enable_fsst_vectors = Settings::Get<EnableFSSTVectorsSetting>(segment.db);
401541 } else {
401542 enable_fsst_vectors = false;
401543 }
401544
401545 auto baseptr = scan_state.handle.Ptr() + segment.GetBlockOffset();
401546 auto dict = GetDictionary(segment, scan_state.handle);
401547 auto base_data = data_ptr_cast(baseptr + sizeof(fsst_compression_header_t));
401548 string_t *result_data;
401549
401550 if (scan_count == 0) {
401551 return;
401552 }
401553
401554 if (enable_fsst_vectors) {
401555 D_ASSERT(result_offset == 0);
401556 if (scan_state.duckdb_fsst_decoder) {
401557 D_ASSERT(result_offset == 0 || result.GetVectorType() == VectorType::FSST_VECTOR);
401558 result.SetVectorType(VectorType::FSST_VECTOR);
401559 auto string_block_limit = StringUncompressed::GetStringBlockLimit(segment.GetBlockSize());
401560 FSSTVector::RegisterDecoder(result, scan_state.duckdb_fsst_decoder, string_block_limit);
401561 result_data = FSSTVector::GetCompressedData<string_t>(result);
401562 } else {
401563 D_ASSERT(result.GetVectorType() == VectorType::FLAT_VECTOR);
401564 result_data = FlatVector::GetData<string_t>(result);
401565 }
401566 } else {
401567 D_ASSERT(result.GetVectorType() == VectorType::FLAT_VECTOR);
401568 result_data = FlatVector::GetData<string_t>(result);
401569 }
401570
401571 auto offsets = StartScan(scan_state, base_data, start, scan_count);
401572 auto &bitunpack_buffer = scan_state.bitunpack_buffer;
401573 auto &delta_decode_buffer = scan_state.delta_decode_buffer;
401574 if (enable_fsst_vectors) {
401575 // Lookup decompressed offsets in dict
401576 for (idx_t i = 0; i < scan_count; i++) {
401577 uint32_t string_length = bitunpack_buffer[i + offsets.scan_offset];
401578 result_data[i] = UncompressedStringStorage::FetchStringFromDict(
401579 segment, dict.end, result, baseptr,
401580 UnsafeNumericCast<int32_t>(delta_decode_buffer[i + offsets.unused_delta_decoded_values]),
401581 string_length);
401582 FSSTVector::SetCount(result, scan_count);
401583 }
401584 } else {
401585 // Just decompress
401586 auto &str_buffer = StringVector::GetStringBuffer(result);
401587 for (idx_t i = 0; i < scan_count; i++) {
401588 result_data[i + result_offset] = scan_state.DecompressString(dict, baseptr, offsets, i, str_buffer);
401589 }
401590 }
401591 EndScan(scan_state, offsets, start, scan_count);
401592}
::uint32_t uint32_t
static DUCKDB_API void SetCount(Vector &vector, idx_t count)
Setting the string count is required to be able to correctly flatten the vector.
Definition duckdb.cpp:138030
static DUCKDB_API VectorStringBuffer & GetStringBuffer(Vector &vector)
Returns a reference to the underlying VectorStringBuffer - throws an error if vector is not of type V...
Definition duckdb.cpp:137905

◆ StringScan()

void duckdb::FSSTStorage::StringScan ( ColumnSegment & segment,
ColumnScanState & state,
idx_t scan_count,
Vector & result )
static
401594 {
401595 StringScanPartial<true>(segment, state, scan_count, result, 0);
401596}

◆ StringFetchRow()

void duckdb::FSSTStorage::StringFetchRow ( ColumnSegment & segment,
ColumnFetchState & state,
row_t row_id,
Vector & result,
idx_t result_idx )
static
401627 {
401628 auto &buffer_manager = BufferManager::GetBufferManager(segment.db);
401629 auto handle = buffer_manager.Pin(segment.block);
401630 auto base_ptr = handle.Ptr() + segment.GetBlockOffset();
401631 auto base_data = data_ptr_cast(base_ptr + sizeof(fsst_compression_header_t));
401632 auto dict = GetDictionary(segment, handle);
401633
401634 duckdb_fsst_decoder_t decoder;
401635 bitpacking_width_t width;
401636 auto block_size = segment.GetBlockSize();
401637 auto have_symbol_table = ParseFSSTSegmentHeader(base_ptr, &decoder, &width, block_size);
401638
401639 auto result_data = FlatVector::GetData<string_t>(result);
401640 if (!have_symbol_table) {
401641 // There is no FSST symtable. This is only the case for empty strings or NULLs. We emit an empty string.
401642 result_data[result_idx] = string_t(nullptr, 0);
401643 return;
401644 }
401645
401646 // We basically just do a scan of 1 which is kinda expensive as we need to repeatedly delta decode until we
401647 // reach the row we want, we could consider a more clever caching trick if this is slow
401648 auto offsets = CalculateBpDeltaOffsets(-1, UnsafeNumericCast<idx_t>(row_id), 1);
401649
401650 auto bitunpack_buffer = unique_ptr<uint32_t[]>(new uint32_t[offsets.total_bitunpack_count]);
401651 BitUnpackRange(base_data, data_ptr_cast(bitunpack_buffer.get()), offsets.total_bitunpack_count,
401652 offsets.bitunpack_start_row, width);
401653 auto delta_decode_buffer = unique_ptr<uint32_t[]>(new uint32_t[offsets.total_delta_decode_count]);
401654 DeltaDecodeIndices(bitunpack_buffer.get() + offsets.bitunpack_alignment_offset, delta_decode_buffer.get(),
401655 offsets.total_delta_decode_count, 0);
401656
401657 uint32_t string_length = bitunpack_buffer[offsets.scan_offset];
401658
401659 string_t compressed_string = UncompressedStringStorage::FetchStringFromDict(
401660 segment, dict.end, result, base_ptr,
401661 UnsafeNumericCast<int32_t>(delta_decode_buffer[offsets.unused_delta_decoded_values]), string_length);
401662
401663 auto &str_buffer = StringVector::GetStringBuffer(result);
401664 result_data[result_idx] = FSSTPrimitives::DecompressValue((void *)&decoder, str_buffer, compressed_string.GetData(),
401665 compressed_string.GetSize());
401666}

◆ Select()

void duckdb::FSSTStorage::Select ( ColumnSegment & segment,
ColumnScanState & state,
idx_t vector_count,
Vector & result,
const SelectionVector & sel,
idx_t sel_count )
static
401602 {
401603 auto &scan_state = state.scan_state->Cast<FSSTScanState>();
401604 auto start = state.GetPositionInSegment();
401605
401606 auto baseptr = scan_state.handle.Ptr() + segment.GetBlockOffset();
401607 auto dict = GetDictionary(segment, scan_state.handle);
401608 auto base_data = data_ptr_cast(baseptr + sizeof(fsst_compression_header_t));
401609
401610 D_ASSERT(result.GetVectorType() == VectorType::FLAT_VECTOR);
401611
401612 auto &str_buffer = StringVector::GetStringBuffer(result);
401613 auto offsets = StartScan(scan_state, base_data, start, vector_count);
401614 auto result_data = FlatVector::GetData<string_t>(result);
401615
401616 for (idx_t i = 0; i < sel_count; i++) {
401617 idx_t index = sel.get_index(i);
401618 result_data[i] = scan_state.DecompressString(dict, baseptr, offsets, index, str_buffer);
401619 }
401620 EndScan(scan_state, offsets, start, vector_count);
401621}
index

◆ SetDictionary()

void duckdb::FSSTStorage::SetDictionary ( ColumnSegment & segment,
BufferHandle & handle,
StringDictionaryContainer container )
static
401689 {
401690 auto header_ptr = reinterpret_cast<fsst_compression_header_t *>(handle.Ptr() + segment.GetBlockOffset());
401691 Store<uint32_t>(container.size, data_ptr_cast(&header_ptr->dict_size));
401692 Store<uint32_t>(container.end, data_ptr_cast(&header_ptr->dict_end));
401693}

◆ GetDictionary()

StringDictionaryContainer duckdb::FSSTStorage::GetDictionary ( ColumnSegment & segment,
BufferHandle & handle )
static
401695 {
401696 auto header_ptr = reinterpret_cast<fsst_compression_header_t *>(handle.Ptr() + segment.GetBlockOffset());
401697 StringDictionaryContainer container;
401698 container.size = Load<uint32_t>(data_ptr_cast(&header_ptr->dict_size));
401699 container.end = Load<uint32_t>(data_ptr_cast(&header_ptr->dict_end));
401700 return container;
401701}

◆ FetchStringPointer()

char * duckdb::FSSTStorage::FetchStringPointer ( StringDictionaryContainer dict,
data_ptr_t baseptr,
int32_t dict_offset )
static
401703 {
401704 if (dict_offset == 0) {
401705 return nullptr;
401706 }
401707
401708 auto dict_end = baseptr + dict.end;
401709 auto dict_pos = dict_end - dict_offset;
401710 return char_ptr_cast(dict_pos);
401711}

◆ CalculateBpDeltaOffsets()

bp_delta_offsets_t duckdb::FSSTStorage::CalculateBpDeltaOffsets ( int64_t last_known_row,
idx_t start,
idx_t scan_count )
static
401728 {
401729 D_ASSERT((idx_t)(last_known_row + 1) <= start);
401730 bp_delta_offsets_t result;
401731
401732 result.delta_decode_start_row = (idx_t)(last_known_row + 1);
401733 result.bitunpack_alignment_offset =
401734 result.delta_decode_start_row % BitpackingPrimitives::BITPACKING_ALGORITHM_GROUP_SIZE;
401735 result.bitunpack_start_row = result.delta_decode_start_row - result.bitunpack_alignment_offset;
401736 result.unused_delta_decoded_values = start - result.delta_decode_start_row;
401737 result.scan_offset = result.bitunpack_alignment_offset + result.unused_delta_decoded_values;
401738 result.total_delta_decode_count = scan_count + result.unused_delta_decoded_values;
401739 result.total_bitunpack_count =
401740 BitpackingPrimitives::RoundUpToAlgorithmGroupSize<idx_t>(scan_count + result.scan_offset);
401741
401742 D_ASSERT(result.total_delta_decode_count + result.bitunpack_alignment_offset <= result.total_bitunpack_count);
401743 return result;
401744}

◆ ParseFSSTSegmentHeader()

bool duckdb::FSSTStorage::ParseFSSTSegmentHeader ( data_ptr_t base_ptr,
duckdb_fsst_decoder_t * decoder_out,
bitpacking_width_t * width_out,
const idx_t block_size )
static
401715 {
401716 auto header_ptr = reinterpret_cast<fsst_compression_header_t *>(base_ptr);
401717 auto fsst_symbol_table_offset = Load<uint32_t>(data_ptr_cast(&header_ptr->fsst_symbol_table_offset));
401718 if (fsst_symbol_table_offset > block_size) {
401719 throw InternalException("invalid fsst_symbol_table_offset in FSSTStorage::ParseFSSTSegmentHeader");
401720 }
401721 *width_out = (bitpacking_width_t)(Load<uint32_t>(data_ptr_cast(&header_ptr->bitpacking_width)));
401722 return duckdb_fsst_import(decoder_out, base_ptr + fsst_symbol_table_offset);
401723}

◆ StartScan()

bp_delta_offsets_t duckdb::FSSTStorage::StartScan ( FSSTScanState & scan_state,
data_ptr_t base_data,
idx_t start,
idx_t vector_count )
static
401504 {
401505 if (start == 0 || scan_state.last_known_row >= (int64_t)start) {
401506 scan_state.ResetStoredDelta();
401507 }
401508
401509 auto offsets = CalculateBpDeltaOffsets(scan_state.last_known_row, start, scan_count);
401510
401511 if (scan_state.bitunpack_buffer_capacity < offsets.total_bitunpack_count) {
401512 scan_state.bitunpack_buffer = make_unsafe_uniq_array<uint32_t>(offsets.total_bitunpack_count);
401513 scan_state.bitunpack_buffer_capacity = offsets.total_bitunpack_count;
401514 }
401515 BitUnpackRange(base_data, data_ptr_cast(scan_state.bitunpack_buffer.get()), offsets.total_bitunpack_count,
401516 offsets.bitunpack_start_row, scan_state.current_width);
401517 if (scan_state.delta_decode_capacity < offsets.total_delta_decode_count) {
401518 scan_state.delta_decode_buffer = make_unsafe_uniq_array<uint32_t>(offsets.total_delta_decode_count);
401519 scan_state.delta_decode_capacity = offsets.total_delta_decode_count;
401520 }
401521 DeltaDecodeIndices(scan_state.bitunpack_buffer.get() + offsets.bitunpack_alignment_offset,
401522 scan_state.delta_decode_buffer.get(), offsets.total_delta_decode_count,
401523 scan_state.last_known_index);
401524 return offsets;
401525}

◆ EndScan()

void duckdb::FSSTStorage::EndScan ( FSSTScanState & scan_state,
bp_delta_offsets_t & offsets,
idx_t start,
idx_t scan_count )
static
401527 {
401528 scan_state.StoreLastDelta(scan_state.delta_decode_buffer[scan_count + offsets.unused_delta_decoded_values - 1],
401529 UnsafeNumericCast<int64_t>(start + scan_count - 1));
401530}

The documentation for this struct was generated from the following file: