Skip to content

Commit

Permalink
no need to copy strings to a heap, we have already copied the data to…
Browse files Browse the repository at this point in the history
… the segment, the map is only ever referenced while the segment is alive, so we can safely reference data from the segment
  • Loading branch information
Tishj committed Jan 7, 2025
1 parent 12d1051 commit d5aea48
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ struct DictionaryCompressionCompressState : public DictionaryCompressionState {
data_ptr_t current_end_ptr;

// Buffers and map for current segment
StringHeap heap;
string_map_t<uint32_t> current_string_map;
vector<uint32_t> index_buffer;
vector<uint32_t> selection_buffer;
Expand Down
7 changes: 4 additions & 3 deletions src/storage/compression/dictionary/compression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ namespace duckdb {
DictionaryCompressionCompressState::DictionaryCompressionCompressState(ColumnDataCheckpointData &checkpoint_data_p,
const CompressionInfo &info)
: DictionaryCompressionState(info), checkpoint_data(checkpoint_data_p),
function(checkpoint_data.GetCompressionFunction(CompressionType::COMPRESSION_DICTIONARY)),
heap(BufferAllocator::Get(checkpoint_data.GetDatabase())) {
function(checkpoint_data.GetCompressionFunction(CompressionType::COMPRESSION_DICTIONARY)) {
CreateEmptySegment(checkpoint_data.GetRowGroup().start);
}

Expand Down Expand Up @@ -72,7 +71,9 @@ void DictionaryCompressionCompressState::AddNewString(string_t str) {
if (str.IsInlined()) {
current_string_map.insert({str, index_buffer.size() - 1});
} else {
current_string_map.insert({heap.AddBlob(str), index_buffer.size() - 1});
string_t dictionary_string((const char *)dict_pos, UnsafeNumericCast<uint32_t>(str.GetSize())); // NOLINT
D_ASSERT(!dictionary_string.IsInlined());
current_string_map.insert({dictionary_string, index_buffer.size() - 1});
}
DictionaryCompression::SetDictionary(*current_segment, current_handle, current_dictionary);

Expand Down

0 comments on commit d5aea48

Please sign in to comment.