clickhouse-native 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/ext/clickhouse_native/client.cpp +847 -0
- data/ext/clickhouse_native/extconf.rb +101 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/.clang-format +11 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/.git +1 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/.gitattributes +63 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/.github/CODEOWNERS +1 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/.github/workflows/linux.yml +139 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/.github/workflows/macos.yml +87 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/.github/workflows/windows_mingw.yml +102 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/.github/workflows/windows_msvc.yml +74 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/.gitignore +280 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/.travis.yml +62 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/CMakeLists.txt +157 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/LICENSE +206 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/README.md +260 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/CMakeLists.txt +246 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/buffer.h +10 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/compressed.cpp +258 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/compressed.h +48 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/endpoints_iterator.cpp +20 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/endpoints_iterator.h +34 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/input.cpp +96 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/input.h +103 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/open_telemetry.h +23 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/output.cpp +119 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/output.h +142 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/platform.cpp +1 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/platform.h +33 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/projected_iterator.h +55 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/singleton.h +11 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/socket.cpp +489 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/socket.h +177 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/sslsocket.cpp +307 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/sslsocket.h +111 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/string_utils.h +28 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/string_view.h +142 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/uuid.h +10 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/wire_format.cpp +177 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/wire_format.h +79 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/block.cpp +134 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/block.h +114 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/client.cpp +1269 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/client.h +320 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/array.cpp +175 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/array.h +321 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/column.cpp +24 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/column.h +107 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/date.cpp +365 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/date.h +245 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/decimal.cpp +255 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/decimal.h +50 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/enum.cpp +123 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/enum.h +65 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/factory.cpp +285 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/factory.h +14 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/geo.cpp +108 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/geo.h +79 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/ip4.cpp +117 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/ip4.h +71 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/ip6.cpp +108 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/ip6.h +66 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/itemview.cpp +101 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/itemview.h +86 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/lowcardinality.cpp +527 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/lowcardinality.h +221 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/lowcardinalityadaptor.h +63 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/map.cpp +87 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/map.h +257 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/nothing.h +87 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/nullable.cpp +109 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/nullable.h +153 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/numeric.cpp +126 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/numeric.h +88 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/string.cpp +333 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/string.h +145 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/time.cpp +155 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/time.h +118 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/tuple.cpp +106 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/tuple.h +178 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/utils.h +41 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/uuid.cpp +80 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/uuid.h +58 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/error_codes.h +595 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/exceptions.h +66 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/protocol.h +54 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/query.cpp +25 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/query.h +246 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/server_exception.h +16 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/types/type_parser.cpp +314 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/types/type_parser.h +89 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/types/types.cpp +484 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/types/types.h +397 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/version.h +14 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/cmake/Findcityhash.cmake +26 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/cmake/Findlz4.cmake +39 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/cmake/Findzstd.cmake +39 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/cmake/cpp17.cmake +8 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/cmake/openssl.cmake +8 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/cmake/subdirs.cmake +5 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/cmake/version.cmake +87 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/absl/absl/CMakeLists.txt +9 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/absl/absl/base/attributes.h +682 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/absl/absl/base/config.h +714 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/absl/absl/base/internal/bits.h +219 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/absl/absl/base/macros.h +147 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/absl/absl/base/optimization.h +241 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/absl/absl/base/options.h +238 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/absl/absl/base/policy_checks.h +111 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/absl/absl/base/port.h +26 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/absl/absl/numeric/int128.cc +390 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/absl/absl/numeric/int128.h +1092 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/absl/absl/numeric/int128_have_intrinsic.inc +302 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/absl/absl/numeric/int128_no_intrinsic.inc +308 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/cityhash/cityhash/BUCK +13 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/cityhash/cityhash/CMakeLists.txt +7 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/cityhash/cityhash/COPYING +19 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/cityhash/cityhash/city.cc +469 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/cityhash/cityhash/city.h +90 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/cityhash/cityhash/citycrc.h +43 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/cityhash/cityhash/config.h +118 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/BUCK +14 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/CMakeLists.txt +4 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/LICENSE +28 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/README.md +1 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/gtest-death-test.h +346 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/gtest-matchers.h +930 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/gtest-message.h +219 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/gtest-param-test.h +507 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/gtest-printers.h +1029 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/gtest-spi.h +238 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/gtest-test-part.h +184 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/gtest-typed-test.h +329 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/gtest.h +2495 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/gtest_pred_impl.h +359 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/gtest_prod.h +61 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/internal/custom/README.md +56 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/internal/custom/gtest-port.h +37 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/internal/custom/gtest-printers.h +42 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/internal/custom/gtest.h +37 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/internal/gtest-death-test-internal.h +304 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/internal/gtest-filepath.h +211 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/internal/gtest-internal.h +1560 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/internal/gtest-param-util.h +947 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/internal/gtest-port-arch.h +114 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/internal/gtest-port.h +2389 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/internal/gtest-string.h +175 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/internal/gtest-type-util.h +183 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/src/gtest-all.cc +48 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/src/gtest-death-test.cc +1644 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/src/gtest-filepath.cc +369 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/src/gtest-internal-inl.h +1221 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/src/gtest-matchers.cc +97 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/src/gtest-port.cc +1433 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/src/gtest-printers.cc +533 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/src/gtest-test-part.cc +108 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/src/gtest-typed-test.cc +107 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/src/gtest.cc +6746 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/src/gtest_main.cc +54 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/lz4/lz4/BUCK +13 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/lz4/lz4/CMakeLists.txt +8 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/lz4/lz4/LICENSE +24 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/lz4/lz4/lz4.c +2402 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/lz4/lz4/lz4.h +764 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/lz4/lz4/lz4hc.c +1554 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/lz4/lz4/lz4hc.h +438 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/BUCK +232 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/CMakeLists.txt +115 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/LICENSE +30 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/allocations.h +55 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/bits.h +200 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/bitstream.h +437 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/compiler.h +358 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/cpu.h +213 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/debug.c +24 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/debug.h +107 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/entropy_common.c +340 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/error_private.c +63 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/error_private.h +159 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/fse.h +639 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/fse_decompress.c +311 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/huf.h +273 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/mem.h +435 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/pool.c +371 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/pool.h +90 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/portability_macros.h +156 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/threading.c +176 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/threading.h +150 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/xxhash.c +24 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/xxhash.h +5686 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/zstd_common.c +48 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/zstd_deps.h +111 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/zstd_internal.h +392 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/zstd_trace.h +163 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/clevels.h +134 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/fse_compress.c +624 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/hist.c +181 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/hist.h +75 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/huf_compress.c +1435 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_compress.c +7032 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_compress_internal.h +1532 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_compress_literals.c +235 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_compress_literals.h +39 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_compress_sequences.c +442 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_compress_sequences.h +54 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_compress_superblock.c +577 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_compress_superblock.h +32 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_cwksp.h +742 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_double_fast.c +758 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_double_fast.h +39 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_fast.c +960 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_fast.h +38 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_lazy.c +2157 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_lazy.h +127 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_ldm.c +724 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_ldm.h +117 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_ldm_geartab.h +106 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_opt.c +1472 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_opt.h +56 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstdmt_compress.c +1867 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstdmt_compress.h +113 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/decompress/huf_decompress.c +1882 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/decompress/huf_decompress_amd64.S +576 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/decompress/zstd_ddict.c +244 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/decompress/zstd_ddict.h +44 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/decompress/zstd_decompress.c +2355 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/decompress/zstd_decompress_block.c +2192 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/decompress/zstd_decompress_block.h +73 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/decompress/zstd_decompress_internal.h +238 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/dictBuilder/cover.c +1257 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/dictBuilder/cover.h +158 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/dictBuilder/divsufsort.c +1913 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/dictBuilder/divsufsort.h +67 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/dictBuilder/fastcover.c +766 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/dictBuilder/zdict.c +1127 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/legacy/zstd_legacy.h +422 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/legacy/zstd_v01.c +2125 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/legacy/zstd_v01.h +94 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/legacy/zstd_v02.c +3477 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/legacy/zstd_v02.h +93 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/legacy/zstd_v03.c +3117 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/legacy/zstd_v03.h +93 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/legacy/zstd_v04.c +3605 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/legacy/zstd_v04.h +142 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/legacy/zstd_v05.c +4004 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/legacy/zstd_v05.h +162 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/legacy/zstd_v06.c +4113 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/legacy/zstd_v06.h +172 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/legacy/zstd_v07.c +4498 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/legacy/zstd_v07.h +187 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/zdict.h +474 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/zstd.h +3020 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/zstd_errors.h +114 -0
- data/lib/clickhouse_native/clickhouse_native.bundle +0 -0
- data/lib/clickhouse_native/client.rb +50 -0
- data/lib/clickhouse_native/errors.rb +23 -0
- data/lib/clickhouse_native/pool.rb +49 -0
- data/lib/clickhouse_native/version.rb +3 -0
- data/lib/clickhouse_native.rb +8 -0
- metadata +369 -0
|
@@ -0,0 +1,527 @@
|
|
|
1
|
+
#include "lowcardinality.h"
|
|
2
|
+
|
|
3
|
+
#include "string.h"
|
|
4
|
+
#include "nullable.h"
|
|
5
|
+
#include "../base/wire_format.h"
|
|
6
|
+
|
|
7
|
+
#include <city.h>
|
|
8
|
+
|
|
9
|
+
#include <functional>
|
|
10
|
+
#include <string_view>
|
|
11
|
+
#include <type_traits>
|
|
12
|
+
#include <cmath>
|
|
13
|
+
|
|
14
|
+
#include <cassert>
|
|
15
|
+
|
|
16
|
+
namespace {
|
|
17
|
+
using namespace clickhouse;
|
|
18
|
+
|
|
19
|
+
enum KeySerializationVersion {
|
|
20
|
+
SharedDictionariesWithAdditionalKeys = 1,
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
enum IndexType {
|
|
24
|
+
UInt8 = 0,
|
|
25
|
+
UInt16,
|
|
26
|
+
UInt32,
|
|
27
|
+
UInt64,
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
constexpr uint64_t IndexTypeMask = 0b11111111;
|
|
31
|
+
|
|
32
|
+
enum IndexFlag {
|
|
33
|
+
/// Need to read dictionary if it wasn't.
|
|
34
|
+
NeedGlobalDictionaryBit = 1u << 8u,
|
|
35
|
+
/// Need to read additional keys. Additional keys are stored before indexes as value N and N keys after them.
|
|
36
|
+
HasAdditionalKeysBit = 1u << 9u,
|
|
37
|
+
/// Need to update dictionary. It means that previous granule has different dictionary.
|
|
38
|
+
NeedUpdateDictionary = 1u << 10u
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
ColumnRef createIndexColumn(IndexType type) {
|
|
42
|
+
switch (type) {
|
|
43
|
+
case IndexType::UInt8:
|
|
44
|
+
return std::make_shared<ColumnUInt8>();
|
|
45
|
+
case IndexType::UInt16:
|
|
46
|
+
return std::make_shared<ColumnUInt16>();
|
|
47
|
+
case IndexType::UInt32:
|
|
48
|
+
return std::make_shared<ColumnUInt32>();
|
|
49
|
+
case IndexType::UInt64:
|
|
50
|
+
return std::make_shared<ColumnUInt64>();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
throw ValidationError("Invalid LowCardinality index type value: " + std::to_string(static_cast<uint64_t>(type)));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
IndexType indexTypeFromIndexColumn(const Column & index_column) {
|
|
57
|
+
switch (index_column.Type()->GetCode()) {
|
|
58
|
+
case Type::UInt8:
|
|
59
|
+
return IndexType::UInt8;
|
|
60
|
+
case Type::UInt16:
|
|
61
|
+
return IndexType::UInt16;
|
|
62
|
+
case Type::UInt32:
|
|
63
|
+
return IndexType::UInt32;
|
|
64
|
+
case Type::UInt64:
|
|
65
|
+
return IndexType::UInt64;
|
|
66
|
+
default:
|
|
67
|
+
throw ValidationError("Invalid index column type for LowCardinality column:" + index_column.Type()->GetName());
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
template <typename ResultColumnType, typename ColumnType>
|
|
72
|
+
inline const ResultColumnType & column_down_cast(const ColumnType & c) {
|
|
73
|
+
return dynamic_cast<const ResultColumnType &>(c);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
template <typename ResultColumnType, typename ColumnType>
|
|
77
|
+
inline ResultColumnType & column_down_cast(ColumnType & c) {
|
|
78
|
+
return dynamic_cast<ResultColumnType &>(c);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// std::visit-ish function to avoid including <variant> header, which is not present in older version of XCode.
|
|
82
|
+
template <typename Vizitor, typename ColumnType>
|
|
83
|
+
inline auto VisitIndexColumn(Vizitor && vizitor, ColumnType && col) {
|
|
84
|
+
switch (col.Type()->GetCode()) {
|
|
85
|
+
case Type::UInt8:
|
|
86
|
+
return vizitor(column_down_cast<ColumnUInt8>(col));
|
|
87
|
+
case Type::UInt16:
|
|
88
|
+
return vizitor(column_down_cast<ColumnUInt16>(col));
|
|
89
|
+
case Type::UInt32:
|
|
90
|
+
return vizitor(column_down_cast<ColumnUInt32>(col));
|
|
91
|
+
case Type::UInt64:
|
|
92
|
+
return vizitor(column_down_cast<ColumnUInt64>(col));
|
|
93
|
+
default:
|
|
94
|
+
throw ValidationError("Invalid index column type " + col.GetType().GetName());
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// A special NULL-item, which is expected at pos(0) in dictionary,
|
|
99
|
+
// note that we distinguish empty string from NULL-value.
|
|
100
|
+
inline auto GetNullItemForDictionary(const ColumnRef dictionary) {
|
|
101
|
+
if (auto n = dictionary->As<ColumnNullable>()) {
|
|
102
|
+
return ItemView {};
|
|
103
|
+
} else {
|
|
104
|
+
return ItemView{dictionary->Type()->GetCode(), std::string_view{}};
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// A special default item, which is expected at pos(0) in dictionary,
|
|
109
|
+
// note that we distinguish empty string from NULL-value.
|
|
110
|
+
inline ItemView GetDefaultItemForDictionary(const ColumnRef dictionary) {
|
|
111
|
+
if (auto n = dictionary->As<ColumnNullable>()) {
|
|
112
|
+
return GetDefaultItemForDictionary(n->Nested());
|
|
113
|
+
} else {
|
|
114
|
+
return ItemView{dictionary->Type()->GetCode(), std::string_view{}};
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
void AppendToDictionary(Column& dictionary, const ItemView & item);
|
|
119
|
+
|
|
120
|
+
inline void AppendNullableToDictionary(ColumnNullable& nullable, const ItemView & item) {
|
|
121
|
+
auto nested = nullable.Nested();
|
|
122
|
+
|
|
123
|
+
const bool isNullValue = item.type == Type::Void;
|
|
124
|
+
|
|
125
|
+
if (isNullValue) {
|
|
126
|
+
AppendToDictionary(*nested, GetNullItemForDictionary(nested));
|
|
127
|
+
} else {
|
|
128
|
+
const auto nestedType = nested->GetType().GetCode();
|
|
129
|
+
if (nestedType != item.type) {
|
|
130
|
+
throw ValidationError("Invalid value. Type expected: " + nested->GetType().GetName());
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
AppendToDictionary(*nested, item);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
nullable.Append(isNullValue);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
inline void AppendToDictionary(Column& dictionary, const ItemView & item) {
|
|
140
|
+
switch (dictionary.GetType().GetCode()) {
|
|
141
|
+
case Type::FixedString:
|
|
142
|
+
column_down_cast<ColumnFixedString>(dictionary).Append(item.get<std::string_view>());
|
|
143
|
+
return;
|
|
144
|
+
case Type::String:
|
|
145
|
+
column_down_cast<ColumnString>(dictionary).Append(item.get<std::string_view>());
|
|
146
|
+
return;
|
|
147
|
+
case Type::Nullable:
|
|
148
|
+
AppendNullableToDictionary(column_down_cast<ColumnNullable>(dictionary), item);
|
|
149
|
+
return;
|
|
150
|
+
default:
|
|
151
|
+
throw ValidationError("Unexpected dictionary column type: " + dictionary.GetType().GetName());
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
namespace clickhouse {
|
|
158
|
+
ColumnLowCardinality::ColumnLowCardinality(ColumnRef dictionary_column)
|
|
159
|
+
: Column(Type::CreateLowCardinality(dictionary_column->Type())),
|
|
160
|
+
dictionary_column_(dictionary_column->CloneEmpty()), // safe way to get an column of the same type.
|
|
161
|
+
index_column_(std::make_shared<ColumnUInt32>()),
|
|
162
|
+
index_type_code_(Type::UInt32)
|
|
163
|
+
{
|
|
164
|
+
Setup(dictionary_column);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
ColumnLowCardinality::ColumnLowCardinality(std::shared_ptr<ColumnNullable> dictionary_column)
|
|
168
|
+
: Column(Type::CreateLowCardinality(dictionary_column->Type())),
|
|
169
|
+
dictionary_column_(dictionary_column->CloneEmpty()), // safe way to get an column of the same type.
|
|
170
|
+
index_column_(std::make_shared<ColumnUInt32>()),
|
|
171
|
+
index_type_code_(Type::UInt32)
|
|
172
|
+
{
|
|
173
|
+
AppendNullItem();
|
|
174
|
+
Setup(dictionary_column);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
ColumnLowCardinality::~ColumnLowCardinality()
|
|
178
|
+
{}
|
|
179
|
+
|
|
180
|
+
void ColumnLowCardinality::Reserve(size_t new_cap) {
|
|
181
|
+
// Assumption is that dictionary must be smaller than index.
|
|
182
|
+
// NOTE(vnemkov): Formula below (`ceil(sqrt(x))`) is a gut-feeling-good-enough estimation,
|
|
183
|
+
// feel free to replace/adjust if you have better one suported by actual data.
|
|
184
|
+
dictionary_column_->Reserve(static_cast<size_t>(ceil(sqrt(static_cast<double>(new_cap)))));
|
|
185
|
+
index_column_->Reserve(new_cap + 2); // + 1 for null item (at pos 0), + 1 for default item (at pos 1)
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
void ColumnLowCardinality::Setup(ColumnRef dictionary_column) {
|
|
189
|
+
AppendDefaultItem();
|
|
190
|
+
|
|
191
|
+
if (dictionary_column->Size() != 0) {
|
|
192
|
+
// Add values, updating index_column_ and unique_items_map_.
|
|
193
|
+
|
|
194
|
+
// TODO: it would be possible to eliminate copying
|
|
195
|
+
// by adding InsertUnsafe(pos, ItemView) method to a Column
|
|
196
|
+
// (to insert null-item at pos 0),
|
|
197
|
+
// but that is too much work for now.
|
|
198
|
+
for (size_t i = 0; i < dictionary_column->Size(); ++i) {
|
|
199
|
+
AppendUnsafe(dictionary_column->GetItem(i));
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
std::uint64_t ColumnLowCardinality::getDictionaryIndex(std::uint64_t item_index) const {
|
|
205
|
+
switch (index_type_code_) {
|
|
206
|
+
case Type::UInt8:
|
|
207
|
+
return static_cast<const ColumnUInt8&>(*index_column_)[item_index];
|
|
208
|
+
case Type::UInt16:
|
|
209
|
+
return static_cast<const ColumnUInt16&>(*index_column_)[item_index];
|
|
210
|
+
case Type::UInt32:
|
|
211
|
+
return static_cast<const ColumnUInt32&>(*index_column_)[item_index];
|
|
212
|
+
case Type::UInt64:
|
|
213
|
+
return static_cast<const ColumnUInt64&>(*index_column_)[item_index];
|
|
214
|
+
default:
|
|
215
|
+
throw ValidationError("Invalid index column type");
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
void ColumnLowCardinality::appendIndex(std::uint64_t item_index) {
|
|
220
|
+
// TODO (nemkov): handle case when index should go from UInt8 to UInt16, etc.
|
|
221
|
+
switch (index_type_code_) {
|
|
222
|
+
case Type::UInt8:
|
|
223
|
+
static_cast<ColumnUInt8&>(*index_column_).Append(static_cast<uint8_t>(item_index));
|
|
224
|
+
break;
|
|
225
|
+
case Type::UInt16:
|
|
226
|
+
static_cast<ColumnUInt16&>(*index_column_).Append(static_cast<uint16_t>(item_index));
|
|
227
|
+
break;
|
|
228
|
+
case Type::UInt32:
|
|
229
|
+
static_cast<ColumnUInt32&>(*index_column_).Append(static_cast<uint32_t>(item_index));
|
|
230
|
+
break;
|
|
231
|
+
case Type::UInt64:
|
|
232
|
+
static_cast<ColumnUInt64&>(*index_column_).Append(static_cast<uint64_t>(item_index));
|
|
233
|
+
break;
|
|
234
|
+
default:
|
|
235
|
+
throw ValidationError("Invalid index column type");
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
void ColumnLowCardinality::removeLastIndex() {
|
|
240
|
+
switch (index_type_code_) {
|
|
241
|
+
case Type::UInt8: {
|
|
242
|
+
auto& col = static_cast<ColumnUInt8&>(*index_column_);
|
|
243
|
+
col.Erase(col.Size() - 1);
|
|
244
|
+
break;
|
|
245
|
+
}
|
|
246
|
+
case Type::UInt16: {
|
|
247
|
+
auto& col = static_cast<ColumnUInt16&>(*index_column_);
|
|
248
|
+
col.Erase(col.Size() - 1);
|
|
249
|
+
break;
|
|
250
|
+
}
|
|
251
|
+
case Type::UInt32: {
|
|
252
|
+
auto& col = static_cast<ColumnUInt32&>(*index_column_);
|
|
253
|
+
col.Erase(col.Size() - 1);
|
|
254
|
+
break;
|
|
255
|
+
}
|
|
256
|
+
case Type::UInt64: {
|
|
257
|
+
auto& col = static_cast<ColumnUInt64&>(*index_column_);
|
|
258
|
+
col.Erase(col.Size() - 1);
|
|
259
|
+
break;
|
|
260
|
+
}
|
|
261
|
+
default:
|
|
262
|
+
throw ValidationError("Invalid index column type");
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
details::LowCardinalityHashKey ColumnLowCardinality::computeHashKey(const ItemView & item) {
|
|
267
|
+
static const auto hasher = std::hash<ItemView::DataType>{};
|
|
268
|
+
if (item.type == Type::Void) {
|
|
269
|
+
// to distinguish NULL of ColumnNullable and empty string.
|
|
270
|
+
return {0u, 0u};
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
const auto hash1 = hasher(item.data);
|
|
274
|
+
const auto hash2 = CityHash64(item.data.data(), item.data.size());
|
|
275
|
+
|
|
276
|
+
return details::LowCardinalityHashKey{hash1, hash2};
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
ColumnRef ColumnLowCardinality::GetDictionary() {
|
|
280
|
+
return dictionary_column_;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
void ColumnLowCardinality::Append(ColumnRef col) {
|
|
284
|
+
// Append values from col only if it is either
|
|
285
|
+
// - exactly same type as `this`: LowCardinality wrapping same dictionary type
|
|
286
|
+
// - same type as dictionary column
|
|
287
|
+
|
|
288
|
+
auto c = col->As<ColumnLowCardinality>();
|
|
289
|
+
// If not LowCardinality of same dictionary type
|
|
290
|
+
if (!c || !dictionary_column_->Type()->IsEqual(c->dictionary_column_->Type())) {
|
|
291
|
+
// If not column of the same type as dictionary type
|
|
292
|
+
if (!dictionary_column_->Type()->IsEqual(col->GetType())) {
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
for (size_t i = 0; i < col->Size(); ++i) {
|
|
298
|
+
AppendUnsafe(col->GetItem(i));
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
namespace {
|
|
303
|
+
|
|
304
|
+
auto Load(ColumnRef new_dictionary_column, InputStream& input, size_t rows) {
|
|
305
|
+
// This code tries to follow original implementation of ClickHouse's LowCardinality serialization with
|
|
306
|
+
// NativeBlockOutputStream::writeData() for DataTypeLowCardinality
|
|
307
|
+
// (see corresponding serializeBinaryBulkStateSuffix, serializeBinaryBulkStatePrefix, and serializeBinaryBulkWithMultipleStreams),
|
|
308
|
+
// but with certain simplifications: no shared dictionaries, no on-the-fly dictionary updates.
|
|
309
|
+
//
|
|
310
|
+
// As for now those features are not used in client-server protocol and minimal implementation suffices,
|
|
311
|
+
// however some day they may.
|
|
312
|
+
|
|
313
|
+
uint64_t index_serialization_type;
|
|
314
|
+
if (!WireFormat::ReadFixed(input, &index_serialization_type))
|
|
315
|
+
throw ProtocolError("Failed to read index serializaton type.");
|
|
316
|
+
|
|
317
|
+
auto new_index_column = createIndexColumn(static_cast<IndexType>(index_serialization_type & IndexTypeMask));
|
|
318
|
+
if (index_serialization_type & IndexFlag::NeedGlobalDictionaryBit)
|
|
319
|
+
throw UnimplementedError("Global dictionary is not supported.");
|
|
320
|
+
|
|
321
|
+
if ((index_serialization_type & IndexFlag::HasAdditionalKeysBit) == 0)
|
|
322
|
+
throw ValidationError("HasAdditionalKeysBit is missing.");
|
|
323
|
+
|
|
324
|
+
uint64_t number_of_keys;
|
|
325
|
+
if (!WireFormat::ReadFixed(input, &number_of_keys))
|
|
326
|
+
throw ProtocolError("Failed to read number of rows in dictionary column.");
|
|
327
|
+
|
|
328
|
+
auto dataColumn = new_dictionary_column;
|
|
329
|
+
if (auto nullable = new_dictionary_column->As<ColumnNullable>()) {
|
|
330
|
+
dataColumn = nullable->Nested();
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
if (!dataColumn->LoadBody(&input, number_of_keys))
|
|
334
|
+
throw ProtocolError("Failed to read values of dictionary column.");
|
|
335
|
+
|
|
336
|
+
uint64_t number_of_rows;
|
|
337
|
+
if (!WireFormat::ReadFixed(input, &number_of_rows))
|
|
338
|
+
throw ProtocolError("Failed to read number of rows in index column.");
|
|
339
|
+
|
|
340
|
+
if (number_of_rows != rows)
|
|
341
|
+
throw AssertionError("LowCardinality column must be read in full.");
|
|
342
|
+
|
|
343
|
+
new_index_column->LoadBody(&input, number_of_rows);
|
|
344
|
+
|
|
345
|
+
if (auto nullable = new_dictionary_column->As<ColumnNullable>()) {
|
|
346
|
+
nullable->Append(true);
|
|
347
|
+
for(std::size_t i = 1; i < dataColumn->Size(); i++) {
|
|
348
|
+
nullable->Append(false);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
ColumnLowCardinality::UniqueItems new_unique_items_map;
|
|
353
|
+
for (size_t i = 0; i < dataColumn->Size(); ++i) {
|
|
354
|
+
const auto key = ColumnLowCardinality::computeHashKey(new_dictionary_column->GetItem(i));
|
|
355
|
+
new_unique_items_map.emplace(key, i);
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
// suffix
|
|
359
|
+
// NOP
|
|
360
|
+
|
|
361
|
+
return std::make_tuple(new_dictionary_column, new_index_column, new_unique_items_map);
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
bool ColumnLowCardinality::LoadPrefix(InputStream* input, size_t) {
|
|
367
|
+
uint64_t key_version;
|
|
368
|
+
|
|
369
|
+
if (!WireFormat::ReadFixed(*input, &key_version))
|
|
370
|
+
throw ProtocolError("Failed to read key serialization version.");
|
|
371
|
+
|
|
372
|
+
if (key_version != KeySerializationVersion::SharedDictionariesWithAdditionalKeys)
|
|
373
|
+
throw ProtocolError("Invalid key serialization version value.");
|
|
374
|
+
|
|
375
|
+
return true;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
bool ColumnLowCardinality::LoadBody(InputStream* input, size_t rows) {
|
|
379
|
+
try {
|
|
380
|
+
auto [new_dictionary, new_index, new_unique_items_map] = ::Load(dictionary_column_->CloneEmpty(), *input, rows);
|
|
381
|
+
|
|
382
|
+
dictionary_column_->Swap(*new_dictionary);
|
|
383
|
+
index_column_.swap(new_index);
|
|
384
|
+
unique_items_map_.swap(new_unique_items_map);
|
|
385
|
+
index_type_code_ = index_column_->Type()->GetCode();
|
|
386
|
+
|
|
387
|
+
return true;
|
|
388
|
+
} catch (...) {
|
|
389
|
+
return false;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
void ColumnLowCardinality::SavePrefix(OutputStream* output) {
|
|
394
|
+
const auto version = static_cast<uint64_t>(KeySerializationVersion::SharedDictionariesWithAdditionalKeys);
|
|
395
|
+
WireFormat::WriteFixed(*output, version);
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
void ColumnLowCardinality::SaveBody(OutputStream* output) {
|
|
399
|
+
const uint64_t index_serialization_type = indexTypeFromIndexColumn(*index_column_) | IndexFlag::HasAdditionalKeysBit;
|
|
400
|
+
WireFormat::WriteFixed(*output, index_serialization_type);
|
|
401
|
+
|
|
402
|
+
const uint64_t number_of_keys = dictionary_column_->Size();
|
|
403
|
+
WireFormat::WriteFixed(*output, number_of_keys);
|
|
404
|
+
|
|
405
|
+
if (auto columnNullable = dictionary_column_->As<ColumnNullable>()) {
|
|
406
|
+
columnNullable->Nested()->SaveBody(output);
|
|
407
|
+
} else {
|
|
408
|
+
dictionary_column_->SaveBody(output);
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
const uint64_t number_of_rows = index_column_->Size();
|
|
412
|
+
WireFormat::WriteFixed(*output, number_of_rows);
|
|
413
|
+
|
|
414
|
+
index_column_->SaveBody(output);
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
void ColumnLowCardinality::Clear() {
|
|
418
|
+
index_column_->Clear();
|
|
419
|
+
dictionary_column_->Clear();
|
|
420
|
+
unique_items_map_.clear();
|
|
421
|
+
|
|
422
|
+
if (auto columnNullable = dictionary_column_->As<ColumnNullable>()) {
|
|
423
|
+
AppendNullItem();
|
|
424
|
+
}
|
|
425
|
+
AppendDefaultItem();
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
size_t ColumnLowCardinality::Size() const {
|
|
429
|
+
return index_column_->Size();
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
ColumnRef ColumnLowCardinality::Slice(size_t begin, size_t len) const {
|
|
433
|
+
begin = std::min(begin, Size());
|
|
434
|
+
len = std::min(len, Size() - begin);
|
|
435
|
+
|
|
436
|
+
auto result = std::make_shared<ColumnLowCardinality>(dictionary_column_->CloneEmpty());
|
|
437
|
+
|
|
438
|
+
for (size_t i = begin; i < begin + len; ++i)
|
|
439
|
+
result->AppendUnsafe(this->GetItem(i));
|
|
440
|
+
|
|
441
|
+
return result;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
ColumnRef ColumnLowCardinality::CloneEmpty() const {
|
|
445
|
+
return std::make_shared<ColumnLowCardinality>(dictionary_column_->CloneEmpty());
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
void ColumnLowCardinality::Swap(Column& other) {
|
|
449
|
+
auto & col = dynamic_cast<ColumnLowCardinality &>(other);
|
|
450
|
+
if (!dictionary_column_->Type()->IsEqual(col.dictionary_column_->Type()))
|
|
451
|
+
throw ValidationError("Can't swap() LowCardinality columns of different types.");
|
|
452
|
+
|
|
453
|
+
// It is important here not to swap pointers to dictionary object,
|
|
454
|
+
// but swap contents of dictionaries, so the object inside shared_ptr stays the same
|
|
455
|
+
// (needed for ColumnLowCardinalityT)
|
|
456
|
+
dictionary_column_->Swap(*col.dictionary_column_);
|
|
457
|
+
|
|
458
|
+
index_column_.swap(col.index_column_);
|
|
459
|
+
unique_items_map_.swap(col.unique_items_map_);
|
|
460
|
+
std::swap(index_type_code_, col.index_type_code_);
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
ItemView ColumnLowCardinality::GetItem(size_t index) const {
|
|
464
|
+
const auto dictionaryIndex = getDictionaryIndex(index);
|
|
465
|
+
|
|
466
|
+
if (auto nullable = dictionary_column_->As<ColumnNullable>()) {
|
|
467
|
+
const auto isNull = dictionaryIndex == 0u;
|
|
468
|
+
|
|
469
|
+
if (isNull) {
|
|
470
|
+
return GetNullItemForDictionary(nullable);
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
return dictionary_column_->GetItem(dictionaryIndex);
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
// No checks regarding value type or validity of value is made.
|
|
478
|
+
void ColumnLowCardinality::AppendUnsafe(const ItemView & value) {
|
|
479
|
+
const auto key = computeHashKey(value);
|
|
480
|
+
const auto initial_index_size = index_column_->Size();
|
|
481
|
+
// If the value is unique, then we are going to append it to a dictionary, hence new index is Size().
|
|
482
|
+
auto [iterator, is_new_item] = unique_items_map_.try_emplace(key, dictionary_column_->Size());
|
|
483
|
+
try {
|
|
484
|
+
// Order is important, adding to dictionary last, since it is much (MUCH!!!!) harder
|
|
485
|
+
// to remove item from dictionary column than from index column
|
|
486
|
+
// (also, there is currently no API to do that).
|
|
487
|
+
// Hence in catch-block we assume that dictionary wasn't modified on exception
|
|
488
|
+
// and there is nothing to rollback.
|
|
489
|
+
|
|
490
|
+
appendIndex(iterator->second);
|
|
491
|
+
if (is_new_item) {
|
|
492
|
+
AppendToDictionary(*dictionary_column_, value);
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
catch (...) {
|
|
496
|
+
if (index_column_->Size() != initial_index_size)
|
|
497
|
+
removeLastIndex();
|
|
498
|
+
if (is_new_item)
|
|
499
|
+
unique_items_map_.erase(iterator);
|
|
500
|
+
|
|
501
|
+
throw;
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
void ColumnLowCardinality::AppendNullItem()
|
|
506
|
+
{
|
|
507
|
+
const auto null_item = GetNullItemForDictionary(dictionary_column_);
|
|
508
|
+
AppendToDictionary(*dictionary_column_, null_item);
|
|
509
|
+
unique_items_map_.emplace(computeHashKey(null_item), 0);
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
void ColumnLowCardinality::AppendDefaultItem()
|
|
513
|
+
{
|
|
514
|
+
const auto defaultItem = GetDefaultItemForDictionary(dictionary_column_);
|
|
515
|
+
unique_items_map_.emplace(computeHashKey(defaultItem), dictionary_column_->Size());
|
|
516
|
+
AppendToDictionary(*dictionary_column_, defaultItem);
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
size_t ColumnLowCardinality::GetDictionarySize() const {
|
|
520
|
+
return dictionary_column_->Size();
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
TypeRef ColumnLowCardinality::GetNestedType() const {
|
|
524
|
+
return dictionary_column_->Type();
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
}
|