Skip to content

CO: Support RLE with Zstandard - #67

Open
Smyatkin-Maxim wants to merge 1 commit into
REL_2_STABLEfrom
zstd_rle_support
Open

CO: Support RLE with Zstandard#67
Smyatkin-Maxim wants to merge 1 commit into
REL_2_STABLEfrom
zstd_rle_support

Conversation

@Smyatkin-Maxim

Copy link
Copy Markdown

When we gonna upgrade from gp6 to cloudberry we gonna need to be able to read those zstd encoded RLEs, so I've cherry-picked the original commit from gp6 here.

This is a backport of 7X PR: #17147, with conflicts resolved:
(1) USE_ZSTD is replaced with HAVE_ZSTD
(2) Test changes:
    using ao_column -> with (appendonly=true, orientation=column)
    ALTER TABLE ALTER COLUMN ENCODING is not supported on 6X, so the
    test is taken out.

Original commit message follows:

This addresses #12721.

Zstandard is superior to Zlib in terms of both compression speed and
disk footprint. So offer users the ability to rely on it. To enjoy the
benefits of Zstandard compression in column-oriented tables users can
create tables with compresslevel=5|6.

Example:
create table co_rle_zstd(i int encoding(compresstype=rle_type,
compresslevel=5)) using ao_column;
convert existing tables to the new compress levels as well.

Compresslevels 5 and 6 invoke zstd compression with zstd levels 1 and 3
respectively. Since zstd level 3 is the default and the recommended
level, compresslevel = 6 should cover most cases and is highly
encouraged.

Notes:

(1) Since zstd level = 1 can readily beat zlib level = 9 in terms of
speed (and disk footprint), it can easily fit into our scheme for
compresslevels (lower implies higher speed)

(2) More levels can be provided in the future for zstd, as per demand.

@leborchuk leborchuk left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OMG, let's support it here too. LGTM


#define RLE_MAX_LEVEL (4)

#endif /* HAVE_LIBZSTD */

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe

Suggested change
#endif /* HAVE_LIBZSTD */
#endif /* USE_ZSTD */

uint8 *sourceData,
int32 sourceLen,
uint8 *compressedBuffer,
int32 compressedBufferWithOverrrunLen,

@Vlasdislav Vlasdislav Sep 11, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo. rrr -> rr

Suggested change
int32 compressedBufferWithOverrunLen,

@Smyatkin-Maxim

Smyatkin-Maxim commented Sep 11, 2026

Copy link
Copy Markdown
Author

Tests are failing due to this cherry-pick, will fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants