Skip to content

Commit 16116d4

Browse files
committed
Add custom toaster for compression
1 parent 6286ecf commit 16116d4

5 files changed

Lines changed: 695 additions & 5 deletions

File tree

tsl/src/compression/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ set(SOURCES
77
${CMAKE_CURRENT_SOURCE_DIR}/compression_dml.c
88
${CMAKE_CURRENT_SOURCE_DIR}/compression_scankey.c
99
${CMAKE_CURRENT_SOURCE_DIR}/compression_storage.c
10+
${CMAKE_CURRENT_SOURCE_DIR}/compression_toast.c
1011
${CMAKE_CURRENT_SOURCE_DIR}/create.c
1112
${CMAKE_CURRENT_SOURCE_DIR}/recompress.c)
1213
target_sources(${TSL_LIBRARY_NAME} PRIVATE ${SOURCES})

tsl/src/compression/compression.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
#include "chunk_insert_state.h"
4343
#include "compression.h"
4444
#include "compression/sparse_index_bloom1.h"
45+
#include "compression_toast.h"
4546
#include "continuous_aggs/insert.h"
4647
#include "create.h"
4748
#include "custom_type_cache.h"
@@ -1778,11 +1779,7 @@ row_compressor_flush(RowCompressor *row_compressor, BulkWriter *writer, bool cha
17781779
}
17791780

17801781
Assert(writer->bistate != NULL);
1781-
heap_insert(writer->out_rel,
1782-
compressed_tuple,
1783-
writer->mycid,
1784-
writer->insert_options /*=options*/,
1785-
writer->bistate);
1782+
compression_heap_insert(writer, compressed_tuple);
17861783
if (writer->indexstate->ri_NumIndices > 0)
17871784
{
17881785
ts_catalog_index_insert(writer->indexstate, compressed_tuple);
@@ -2015,6 +2012,7 @@ bulk_writer_close(BulkWriter *writer)
20152012
{
20162013
CatalogCloseIndexes(writer->indexstate);
20172014
}
2015+
compression_toast_writer_close(writer);
20182016
FreeExecutorState(writer->estate);
20192017
}
20202018

tsl/src/compression/compression.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,16 @@ typedef struct BulkWriter
155155
CommandId mycid;
156156
BulkInsertState bistate;
157157
int insert_options; /* heap insert options */
158+
/*
159+
* Toast relation/indexes for compression_toast_save_datum_multi(),
160+
* opened lazily on first use and closed by
161+
* compression_toast_writer_close(). NULL/0 if never toasted.
162+
*/
163+
Relation toast_rel;
164+
Relation *toast_indexes;
165+
int num_toast_indexes;
166+
int toast_valid_index;
167+
BulkInsertState toast_bistate;
158168
} BulkWriter;
159169

160170
typedef struct RowDecompressor

0 commit comments

Comments
 (0)