Commit Graph
103 Commits
Author SHA1 Message Date
Alexey MilovidovandClaude Opus 4.8 0d49daabc7 Add ZXC compression codec
Integrate zxc (https://github.com/hellobertrand/zxc), an asymmetric LZ codec
built for very fast decompression, as a new general-purpose codec
`CODEC(ZXC[(level)])` (levels 1..7, default 3, compression method byte 0x9e).

`ZXC` trades slow compression for fast decompression at a ratio between `LZ4`
and `ZSTD`, which suits the compress-once/read-many pattern of analytical
columns and decodes especially fast on modern ARM cores.

- `contrib/zxc` submodule plus a curated `contrib/zxc-cmake` build that mirrors
  zxc's per-ISA variant objects with runtime dispatch, without its own
  `-march=native`/LTO/PGO defaults (ClickHouse manages its own flags).
- `CompressionCodecZXC` uses zxc's one-shot frame API with zxc's internal
  checksum disabled, since ClickHouse already checksums every compressed block.
- Documentation and a stateless roundtrip test (all levels plus error handling).

Note: `contrib/zxc` points at the upstream repository as a placeholder; before
merging it must be replaced with a fork under github.com/ClickHouse.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
2026-07-15 20:23:14 +00:00
Alexey MilovidovandClaude Opus 4.8 98fa1b2eb0 SZ3: reject lossy codec on untyped streams and validate config before decompression
Two safety fixes against crafted input and misuse, plus the corresponding
contrib/sz3 fork bump:

- Lossy codecs (SZ3) reinterpret the raw bytes as floating-point values, so they
  must not be applied where the column data type is unknown. CompressionFactory
  now rejects a lossy codec built without a data type (after the only_generic
  filter, so structural substreams are unaffected). This closes the silent
  corruption of the marks and primary key when 'marks_compression_codec' or
  'primary_key_compression_codec' is set to SZ3.

- Before decompressing, the codec parses and validates the SZ3 configuration:
  only the interpolation/Lorenzo algorithms and the lossless fallback are
  accepted (a crafted block can otherwise dispatch into ALGO_BIOMD/ALGO_BIOMDXTC
  or the OpenMP path, whose decoders are not hardened), the element count must
  match the trusted uncompressed size, and OpenMP decompression is rejected.

The contrib/sz3 fork is bumped to add SZ_load_config (parse the config without
dispatching) and bounds checks on the generic decompressor, the quantizer and
predictors, and the Huffman tree reconstruction.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
2026-06-30 02:38:12 +00:00
Alexey MilovidovandClaude Opus 4.8 b30569de91 Revive SZ3 compression codec
This reverts the removal of the SZ3 lossy floating-point compression
codec done in https://github.com/ClickHouse/ClickHouse/pull/84358
(itself a revert of https://github.com/ClickHouse/ClickHouse/pull/83088),
and adapts it to the current `master`, finishing the work that the
fuzzer crashes (https://github.com/ClickHouse/ClickHouse/issues/84345)
had left unfinished.

`SZ3` is an experimental, error-bounded lossy codec for `Float32`,
`Float64`, `Array(Float32)` and `Array(Float64)` columns. It requires
`SET allow_experimental_codecs = 1`.

Changes needed to revive it on top of `master`:

- Method byte: the original `SZ3` used `0x9c`, but that byte is now
  taken by the `ALP` codec, so `SZ3` is assigned the next free byte
  `0x9d`. The `SZ3` was never part of a stable release, so no persisted
  data depends on the old byte.
- `doDecompressData` now returns `UInt32` (the base class signature
  changed) and the codec registration was moved to the shared
  `registerCompressionCodecs.h`.
- Re-integrated the vector-dimension and lossy-offset handling into the
  refactored `MergeTreeDataPartWriterCompact`/`Wide`/`OnDisk`.
- `flake.nix` and the `aspell` dictionary entries are not restored,
  because both were removed from `master` in the meantime.
- `SZ3` is intentionally not re-added to the BuzzHouse codec fuzzer: its
  codec generator is now type-aware and only emits lossless codecs, and
  `SZ3` is lossy, which would produce false oracle mismatches.

Hardening of `doDecompressData` against corrupted input (the reason for
the original revert):

- The trusted `uncompressed_size` is now enforced. The previous code
  ignored it and let SZ3 write `config.num` (taken from the untrusted
  compressed data) elements into `dest`, which is only `uncompressed_size`
  bytes long - a heap buffer overflow. The decompressed element count is
  now validated against `uncompressed_size` before decompression.
- The float width is validated and `uncompressed_size` must be a multiple
  of it.
- The serialized `SZ3::Config` is parsed from a zero-padded copy of the
  data, after validating the dimension count and bit width, to avoid
  out-of-bounds reads, and `config.size_est()` is checked against the
  compressed size to prevent the payload-size underflow inside
  `SZ_decompress`.

Closes: https://github.com/ClickHouse/ClickHouse/issues/84345

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
2026-06-29 04:23:04 +00:00
Alexey MilovidovandClaude Opus 4.8 4c6367d093 Fix style check: annotate the catch-all in getCodecDocumentations as Ok
The style check flags `catch (...)` blocks that silently swallow exceptions
unless they handle the exception or carry a comment containing 'Ok'. Move the
explanation onto the `catch (...)` line in the `Ok:` form so the intentional skip
of non-instantiable codecs is recognized.

CI report:
https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=108346&sha=e9ffede0b3a768279738729bf02b8d6bb82426e0&name_0=PR&name_1=Style%20check

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
2026-06-24 03:07:42 +00:00
Alexey MilovidovandClaude Opus 4.8 899fc280c7 Fix Fast test: skip non-instantiable codecs in system.documentation
`getCodecDocumentations` instantiates every registered codec to read its
`getDescription`. In a build without SSL support the encryption codecs register
a creator that throws `OPENSSL_ERROR`, so reading `system.documentation` failed
on such builds (e.g. the Fast test). Skip codecs that cannot be instantiated in
the current build configuration instead of failing the whole query.

CI report:
https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=108346&sha=3711d43b01ccbbf1ec55238720a451fa34885525&name_0=PR&name_1=Fast%20test

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
2026-06-24 02:44:09 +00:00
Alexey MilovidovandClaude Opus 4.8 92104f2309 Fix style check: use memory-tracking containers in CompressionFactory
The std-container lint for `src/Compression` requires the `-WithMemoryTracking`
container aliases. Use `VectorWithMemoryTracking` and `UnorderedMapWithMemoryTracking`
for the additions made for `system.documentation`.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
2026-06-24 00:34:56 +00:00
Alexey MilovidovandClaude Opus 4.8 0c48a0027e Add source column and more entities to system.documentation
Extend `system.documentation` with a `source` column holding the path of the
source file where each entity's documentation is defined, relative to the
repository root. The path is captured automatically at the construction site of
every `Documentation`/`FunctionDocumentation` object via `std::source_location`
(and normalized to be repository-relative regardless of build path mapping), and
is provided explicitly for the entity groups documented in a single source file.

Also document additional kinds of entities: compression codecs (`Compression
Codec`), profile events (`Profile Event`), current metrics (`Current Metric`),
asynchronous metrics (`Asynchronous Metric`), and the system tables themselves
(`System Table`). For system tables the documentation is the table comment
together with the list of its columns (name, type and description); for settings
of any kind the documentation now also includes the type and default value.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
2026-06-24 00:20:12 +00:00
Alexey Milovidov ab6cd89b58 Merge remote-tracking branch 'origin/master' into fix-compiler-warnings
# Conflicts:
#	src/AggregateFunctions/fuzzers/aggregate_function_state_deserialization_fuzzer.cpp
#	src/Client/BuzzHouse/AST/SQLProtoStr.cpp
#	src/Functions/UserDefined/UserDefinedWebAssembly.cpp
#	src/IO/examples/parse_int_perf.cpp
#	src/Processors/QueryPlan/Optimizations/removeUnusedColumns.cpp
#	src/TableFunctions/TableFunctionMergeTreeAnalyzeIndexes.cpp
2026-05-29 02:17:22 +00:00
Nikita TaranovandClaude Opus 4.7 06739aa854 Convert std containers in src/Compression to *WithMemoryTracking aliases
Swap std::vector, std::map, std::set, std::unordered_map, std::list to the
corresponding *WithMemoryTracking aliases in src/Compression. Mark a few
spots as STYLE_CHECK_ALLOW_STD_CONTAINERS where the type is bound to
IFactoryWithAliases::InnerMap covariance or referenced in a documentation
comment block. Add src/Compression to the directories linted by
check_cpp.sh.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
2026-05-21 13:56:16 +00:00
Alexey MilovidovandClaude Opus 4.6 8b47d200d5 Enable -Wmissing-prototypes compiler warning
Add `static` to file-local functions and forward declarations
for cross-TU functions to satisfy `-Wmissing-prototypes`.

This ensures all functions have visible prototypes before their
definitions, improving code quality and catching accidental
linkage issues.

Reference: https://github.com/ClickHouse/ClickHouse/issues/76944

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
2026-03-27 20:11:07 +00:00
Raúl MarínandClaude Opus 4.6 5aba172381 Move getAllRegisteredNames to .cpp files, fix value sub-expression handling, add corner case tests
- Move `getAllRegisteredNames` implementations from headers to .cpp files
  for `CompressionCodecFactory`, `MergeTreeIndexFactory`,
  `DictionaryFactory`, and `DictionarySourceFactory`.
- Fix double-counting of opening parenthesis when a dictionary value
  is a function call — the deferred bareword handler now emits the
  paren and continues instead of falling through.
- Add test cases for function calls in dict values, nested parens,
  and dict keywords outside dictionary context.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
2026-03-11 18:26:51 +01:00
Nazarii Piontkoandrienath 62a16fe6c4 Revert "Revert "Add ALP Codec"" 2026-03-03 18:25:43 +00:00
Alexey MilovidovandGitHub 19aacee54e Revert "Add ALP Codec" 2026-03-02 23:57:36 +01:00
rienath e78d8d14c9 Merge remote-tracking branch 'origin/master' into feature/alp 2026-02-05 12:55:00 +00:00
Nikolai Kochetov f4aa968b13 Use intrusive ptr for AST 2026-01-11 13:36:32 +01:00
Nazarii Piontko af7ae3b452 merge: master into feature/alp 2025-12-28 21:43:51 +01:00
Robert Schulze 034e9714a6 Remove QPL and QAT 2025-12-15 11:45:50 +00:00
Nazarii Piontko 3fd07de605 feat: initial ALP codec implementation 2025-12-01 00:06:52 +01:00
Raúl Marín 1e4c727dc0 Revert "Revert "Revert "Add SZ3 compression codec"""
This reverts commit 29032aedc2.
2025-07-24 11:53:40 +02:00
Konstantin VedernikovandGitHub 29032aedc2 Revert "Revert "Add SZ3 compression codec"" 2025-07-02 16:18:31 +02:00
Alexander TokmakovandGitHub ddddf0c043 Revert "Add SZ3 compression codec" 2025-07-02 15:31:10 +02:00
Robert Schulze c976f4efe2 Merge remote-tracking branch 'ClickHouse/master' into sz_attempt_2 2025-06-26 12:24:06 +00:00
Jimmy Aguilar Mena cc56c6e6c2 CR3 @rschu1ze
Remove `is_delta_compression`
2025-06-12 19:55:55 +02:00
Jimmy Aguilar Mena cdc81d8129 CR2 @rschu1ze
(getNotes -> getDescription): Function renamed
Fix some typos
Re-expose the `method_byte` as suggested by @alexey-milovidov
2025-06-12 00:08:02 +02:00
Jimmy Aguilar Mena 1edf0087fb CR suggestions from @rschu1ze and @novikd 2025-06-12 00:08:02 +02:00
Jimmy Aguilar Mena d294cc910d Add documentation column "notes" to the system.codecs table
Add a new virtual function getNotes that returns documentation for the codec taken from:
https://kb.altinity.com/altinity-kb-schema-design/codecs/

* src/Compression/ICompressionCodec.h (getData) : New interface function. And update in all derived classes.
2025-06-12 00:08:02 +02:00
Jimmy Aguilar Mena 59ff306706 Introspect the list of codecs and their properties.
* src/Storages/System/StorageSystemCodecs.{h,cpp} : New files with the new table class.
* src/Storages/System/StorageSystemCodecs.{h,cpp} (getMutableColumns) : New function to get columns information accessing the private members in CompressionCodecFactory
* src/Storages/System/attachSystemTables.cpp : Attach the new table to system.
2025-06-12 00:08:02 +02:00
Robert SchulzeandKonstantin Vedernikov 7c3844aec3 Some fixups 2025-05-28 20:26:21 +00:00
Konstantin Vedernikov 53c85446fb first version 2025-05-28 20:25:54 +00:00
Nikita Mikhailov 2fb8de68af Better 2025-03-14 20:04:45 +01:00
Nikita Mikhailov b600314abb Rename method and add another one 2025-03-14 19:57:10 +01:00
Nikita Mikhailov 050135d5c9 Remove queryToString 2025-03-14 19:57:10 +01:00
Robert SchulzeandKonstantin Bogdanov 012f6cd9da Revert "Remove idxd-config library which has an incompatible license"
This reverts commit 92a44372b3.
2025-02-17 04:44:02 +01:00
Alexey Milovidov 10e0219250 Remove idxd-config library which has incompatible license 2024-10-23 21:45:39 +02:00
Konstantin Bogdanov 67c1e89d90 Apply linter changes 2024-10-06 12:29:20 +02:00
Robert Schulze eec5fe087c Fix CMake for QATlib 2024-08-09 08:50:52 +00:00
Robert Schulze a497a23914 Fix CMake for QPL 2024-08-09 08:44:22 +00:00
Antonio Andelic 4a9daa202d Remove Keeper standalone build 2024-07-01 11:24:45 +02:00
Maksim Kita ec6c276a92 Temporary data use temporary_files_codec setting 2024-03-19 19:07:45 +03:00
Robert Schulze 0f51e32bb5 Rename from ZSTDQPL to ZSTD_QPL 2024-01-07 17:47:31 +00:00
jinjunzh 5e1b048e52 refine ZSTDQAT code name 2023-12-13 11:02:06 -05:00
jinjunzh f302ba0e31 Implement hardware-assisted(QAT) ZSTD compression 2023-12-05 17:47:18 -05:00
seshWCS b0a229592f Cosmetic 2023-09-05 12:37:31 +00:00
seshWCS 4a1d67dd3c Qpl 2023-09-05 12:35:39 +00:00
Александр НамandGitHub 9a71bce1f5 Merge branch 'ClickHouse:master' into gcddelta-codec 2023-09-02 00:51:49 +03:00
kssenii 3f20d1f578 Rename 2023-09-01 12:55:58 +02:00
Александр Нам f533eeaf95 Moved registerCodecGCD to ifndef 2023-08-08 17:26:01 +00:00
Александр Нам 0a4c3f1dac Fix 2023-08-08 15:16:31 +00:00
Александр Нам 90d0c48108 Edited codec-files 2023-08-07 16:43:46 +00:00
kssenii ecfbf1e304 Remove dependency from DB::Context in readers 2023-05-02 21:45:27 +02:00