Class CompressionMethod
java.lang.Object
dev.frostlake.functions.scalar.encoding.CompressionMethod
The
method argument of COMPRESS / DECOMPRESS_STRING /
DECOMPRESS_BINARY: an algorithm name with an optional compression level in parentheses,
e.g. 'zlib', 'ZLIB(1)', ' zstd '.
The accepted shape was live-verified against Snowflake:
- the name is case-insensitive and surrounding whitespace is ignored (
' SNAPPY ','snappy\t'both work) — whitespace inside the name is not ('sn appy'is rejected); - the level is an optional
(n)suffix, whitespace-tolerant inside the parentheses ('zlib( 1 )'), wherenis a non-negative decimal integer that fits in a signed 32-bit int —'zlib(2147483647)'is accepted,'zlib(2147483648)'is not; leading zeros are fine ('zlib(01)'is level 1); - level
0means "the method's default", identical to omitting the level; - a level above the algorithm's maximum clamps rather than erroring (
'zlib(10)'behaves as'zlib(9)'); - anything else — a negative level, a non-integer level, empty or unbalanced parentheses, an
unknown name — is reported as an unknown method, quoting the whole original string
lowercased but NOT trimmed:
COMPRESS(x, ' DEFLATE ')fails withUnknown compression method ' deflate '(SQLSTATE 42P19, error 100194).
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intSnowflake's "use the algorithm's default level" sentinel;method(0)means the same. -
Method Summary
Modifier and TypeMethodDescriptionintlevel()The requested level, orDEFAULT_LEVELwhen none was given.static CompressionMethodParses themethodargument, or throws Snowflake's unknown-method error.raw()The method text exactly as written, for the decompression-failure message.
-
Field Details
-
DEFAULT_LEVEL
public static final int DEFAULT_LEVELSnowflake's "use the algorithm's default level" sentinel;method(0)means the same.- See Also:
-
-
Method Details
-
parse
Parses themethodargument, or throws Snowflake's unknown-method error.- Parameters:
raw- the method text exactly as the caller wrote it — it is echoed verbatim in a decompression failure and lowercased in the unknown-method error
-
algorithm
-
level
public int level()The requested level, orDEFAULT_LEVELwhen none was given. -
raw
The method text exactly as written, for the decompression-failure message.
-