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,221 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include "column.h"
|
|
4
|
+
#include "numeric.h"
|
|
5
|
+
#include "nullable.h"
|
|
6
|
+
|
|
7
|
+
#include <functional>
|
|
8
|
+
#include <string>
|
|
9
|
+
#include <unordered_map>
|
|
10
|
+
#include <utility>
|
|
11
|
+
|
|
12
|
+
namespace clickhouse {
|
|
13
|
+
|
|
14
|
+
template <typename NestedColumnType>
|
|
15
|
+
class ColumnLowCardinalityT;
|
|
16
|
+
|
|
17
|
+
namespace details {
|
|
18
|
+
|
|
19
|
+
/** LowCardinalityHashKey used as key in unique items hashmap to abstract away key value
|
|
20
|
+
* (type of which depends on dictionary column) and to reduce likelehood of collisions.
|
|
21
|
+
*
|
|
22
|
+
* In order to dramatically reduce collision rate, we use 2 different hashes from 2 different hash functions.
|
|
23
|
+
* First hash is used in hashtable (to calculate item position).
|
|
24
|
+
* Second one is used as part of key value and accessed via `operator==()` upon collision resolution/detection.
|
|
25
|
+
*/
|
|
26
|
+
using LowCardinalityHashKey = std::pair<std::uint64_t, std::uint64_t>;
|
|
27
|
+
|
|
28
|
+
struct LowCardinalityHashKeyHash {
|
|
29
|
+
inline std::size_t operator()(const LowCardinalityHashKey &hash_key) const noexcept {
|
|
30
|
+
return hash_key.first;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/*
|
|
37
|
+
* LC column contains an "invisible" default item at the beginning of the collection. [default, ...]
|
|
38
|
+
* If the nested type is Nullable, it contains a null-item at the beginning and a default item at the second position. [null, default, ...]
|
|
39
|
+
* Null map is not serialized in LC columns. Instead, nulls are tracked by having an index of 0.
|
|
40
|
+
* */
|
|
41
|
+
class ColumnLowCardinality : public Column {
|
|
42
|
+
public:
|
|
43
|
+
using UniqueItems = std::unordered_map<details::LowCardinalityHashKey, size_t /*dictionary index*/, details::LowCardinalityHashKeyHash>;
|
|
44
|
+
|
|
45
|
+
template <typename T>
|
|
46
|
+
friend class ColumnLowCardinalityT;
|
|
47
|
+
|
|
48
|
+
private:
|
|
49
|
+
// IMPLEMENTATION NOTE: ColumnLowCardinalityT takes reference to underlying dictionary column object,
|
|
50
|
+
// so make sure to NOT change address of the dictionary object (with reset(), swap()) or with anything else.
|
|
51
|
+
ColumnRef dictionary_column_;
|
|
52
|
+
ColumnRef index_column_;
|
|
53
|
+
UniqueItems unique_items_map_;
|
|
54
|
+
|
|
55
|
+
public:
|
|
56
|
+
ColumnLowCardinality(ColumnLowCardinality&& col) = default;
|
|
57
|
+
// c-tor makes a deep copy of the dictionary_column.
|
|
58
|
+
explicit ColumnLowCardinality(ColumnRef dictionary_column);
|
|
59
|
+
explicit ColumnLowCardinality(std::shared_ptr<ColumnNullable> dictionary_column);
|
|
60
|
+
|
|
61
|
+
template <typename T>
|
|
62
|
+
explicit ColumnLowCardinality(std::shared_ptr<ColumnNullableT<T>> dictionary_column)
|
|
63
|
+
: ColumnLowCardinality(dictionary_column->template As<ColumnNullable>())
|
|
64
|
+
{}
|
|
65
|
+
|
|
66
|
+
~ColumnLowCardinality();
|
|
67
|
+
|
|
68
|
+
/// Increase the capacity of the column for large block insertion.
|
|
69
|
+
void Reserve(size_t new_cap) override;
|
|
70
|
+
|
|
71
|
+
/// Appends another LowCardinality column to the end of this one, updating dictionary.
|
|
72
|
+
void Append(ColumnRef /*column*/) override;
|
|
73
|
+
|
|
74
|
+
bool LoadPrefix(InputStream* input, size_t rows) override;
|
|
75
|
+
|
|
76
|
+
/// Loads column data from input stream.
|
|
77
|
+
bool LoadBody(InputStream* input, size_t rows) override;
|
|
78
|
+
|
|
79
|
+
/// Saves column prefix to output stream.
|
|
80
|
+
void SavePrefix(OutputStream* output) override;
|
|
81
|
+
|
|
82
|
+
/// Saves column data to output stream.
|
|
83
|
+
void SaveBody(OutputStream* output) override;
|
|
84
|
+
|
|
85
|
+
/// Clear column data.
|
|
86
|
+
void Clear() override;
|
|
87
|
+
|
|
88
|
+
/// Returns count of rows in the column.
|
|
89
|
+
size_t Size() const override;
|
|
90
|
+
|
|
91
|
+
/// Makes slice of current column, with compacted dictionary
|
|
92
|
+
ColumnRef Slice(size_t begin, size_t len) const override;
|
|
93
|
+
ColumnRef CloneEmpty() const override;
|
|
94
|
+
void Swap(Column& other) override;
|
|
95
|
+
ItemView GetItem(size_t index) const override;
|
|
96
|
+
|
|
97
|
+
size_t GetDictionarySize() const;
|
|
98
|
+
TypeRef GetNestedType() const;
|
|
99
|
+
|
|
100
|
+
protected:
|
|
101
|
+
std::uint64_t getDictionaryIndex(std::uint64_t item_index) const;
|
|
102
|
+
void appendIndex(std::uint64_t item_index);
|
|
103
|
+
void removeLastIndex();
|
|
104
|
+
ColumnRef GetDictionary();
|
|
105
|
+
|
|
106
|
+
void AppendUnsafe(const ItemView &);
|
|
107
|
+
|
|
108
|
+
private:
|
|
109
|
+
void Setup(ColumnRef dictionary_column);
|
|
110
|
+
void AppendNullItem();
|
|
111
|
+
void AppendDefaultItem();
|
|
112
|
+
|
|
113
|
+
Type::Code index_type_code_;
|
|
114
|
+
|
|
115
|
+
public:
|
|
116
|
+
static details::LowCardinalityHashKey computeHashKey(const ItemView &);
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
/** Type-aware wrapper that provides simple convenience interface for accessing/appending individual items.
|
|
120
|
+
*/
|
|
121
|
+
template <typename DictionaryColumnType>
|
|
122
|
+
class ColumnLowCardinalityT : public ColumnLowCardinality {
|
|
123
|
+
|
|
124
|
+
DictionaryColumnType& typed_dictionary_;
|
|
125
|
+
const Type::Code type_;
|
|
126
|
+
|
|
127
|
+
public:
|
|
128
|
+
using WrappedColumnType = DictionaryColumnType;
|
|
129
|
+
// Type this column takes as argument of Append and returns with At() and operator[]
|
|
130
|
+
using ValueType = typename DictionaryColumnType::ValueType;
|
|
131
|
+
|
|
132
|
+
explicit ColumnLowCardinalityT(ColumnLowCardinality&& col)
|
|
133
|
+
: ColumnLowCardinality(std::move(col))
|
|
134
|
+
, typed_dictionary_(dynamic_cast<DictionaryColumnType &>(*GetDictionary()))
|
|
135
|
+
, type_(GetTypeCode(typed_dictionary_))
|
|
136
|
+
{
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
template <typename ...Args>
|
|
140
|
+
explicit ColumnLowCardinalityT(Args &&... args)
|
|
141
|
+
: ColumnLowCardinalityT(std::make_shared<DictionaryColumnType>(std::forward<Args>(args)...))
|
|
142
|
+
{}
|
|
143
|
+
|
|
144
|
+
// Create LC<T> column from existing T-column, making a deep copy of all contents.
|
|
145
|
+
explicit ColumnLowCardinalityT(std::shared_ptr<DictionaryColumnType> dictionary_col)
|
|
146
|
+
: ColumnLowCardinality(dictionary_col)
|
|
147
|
+
, typed_dictionary_(dynamic_cast<DictionaryColumnType &>(*GetDictionary()))
|
|
148
|
+
, type_(GetTypeCode(typed_dictionary_))
|
|
149
|
+
{}
|
|
150
|
+
|
|
151
|
+
/// Extended interface to simplify reading/adding individual items.
|
|
152
|
+
|
|
153
|
+
/// Returns element at given row number.
|
|
154
|
+
inline ValueType At(size_t n) const {
|
|
155
|
+
return typed_dictionary_.At(getDictionaryIndex(n));
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/// Returns element at given row number.
|
|
159
|
+
inline ValueType operator [] (size_t n) const {
|
|
160
|
+
return typed_dictionary_[getDictionaryIndex(n)];
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// so the non-virtual Append below doesn't shadow Append() from base class when compiled with older compilers.
|
|
164
|
+
using ColumnLowCardinality::Append;
|
|
165
|
+
|
|
166
|
+
inline void Append(const ValueType & value) {
|
|
167
|
+
if constexpr (IsNullable<WrappedColumnType>) {
|
|
168
|
+
if (value.has_value()) {
|
|
169
|
+
AppendUnsafe(ItemView{type_, *value});
|
|
170
|
+
} else {
|
|
171
|
+
AppendUnsafe(ItemView{});
|
|
172
|
+
}
|
|
173
|
+
} else {
|
|
174
|
+
AppendUnsafe(ItemView{type_, value});
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
template <typename T>
|
|
179
|
+
inline void AppendMany(const T& container) {
|
|
180
|
+
for (const auto & item : container) {
|
|
181
|
+
Append(item);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/** Create a ColumnLowCardinalityT from a ColumnLowCardinality, without copying data and offsets, but by
|
|
186
|
+
* 'stealing' those from `col`.
|
|
187
|
+
*
|
|
188
|
+
* Ownership of column internals is transferred to returned object, original (argument) object
|
|
189
|
+
* MUST NOT BE USED IN ANY WAY, it is only safe to dispose it.
|
|
190
|
+
*
|
|
191
|
+
* Throws an exception if `col` is of wrong type, it is safe to use original col in this case.
|
|
192
|
+
* This is a static method to make such conversion verbose.
|
|
193
|
+
*/
|
|
194
|
+
static auto Wrap(ColumnLowCardinality&& col) {
|
|
195
|
+
return std::make_shared<ColumnLowCardinalityT<WrappedColumnType>>(std::move(col));
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
static auto Wrap(Column&& col) { return Wrap(std::move(dynamic_cast<ColumnLowCardinality&&>(col))); }
|
|
199
|
+
|
|
200
|
+
// Helper to simplify integration with other APIs
|
|
201
|
+
static auto Wrap(ColumnRef&& col) { return Wrap(std::move(*col->AsStrict<ColumnLowCardinality>())); }
|
|
202
|
+
|
|
203
|
+
ColumnRef Slice(size_t begin, size_t size) const override {
|
|
204
|
+
return Wrap(ColumnLowCardinality::Slice(begin, size));
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
ColumnRef CloneEmpty() const override { return Wrap(ColumnLowCardinality::CloneEmpty()); }
|
|
208
|
+
|
|
209
|
+
private:
|
|
210
|
+
|
|
211
|
+
template <typename T>
|
|
212
|
+
static auto GetTypeCode(T& column) {
|
|
213
|
+
if constexpr (IsNullable<T>) {
|
|
214
|
+
return GetTypeCode(*column.Nested()->template AsStrict<typename T::NestedColumnType>());
|
|
215
|
+
} else {
|
|
216
|
+
return column.Type()->GetCode();
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include "column.h"
|
|
4
|
+
#include "lowcardinality.h"
|
|
5
|
+
|
|
6
|
+
#include <cassert>
|
|
7
|
+
|
|
8
|
+
namespace clickhouse {
|
|
9
|
+
|
|
10
|
+
class OutputStream;
|
|
11
|
+
class CodedInputStream;
|
|
12
|
+
|
|
13
|
+
/** Adapts any ColumnType to be serialized\deserialized as LowCardinality,
|
|
14
|
+
* and to be castable to ColumnType via ColumnPtr->As<ColumnType>().
|
|
15
|
+
*
|
|
16
|
+
* It helps to ease migration of the old codebases, which can't afford to switch
|
|
17
|
+
* to using ColumnLowCardinalityT or ColumnLowCardinality directly,
|
|
18
|
+
* but still want to benefit from smaller on-wire LowCardinality bandwidth footprint.
|
|
19
|
+
*
|
|
20
|
+
* Not intended to be used by users directly.
|
|
21
|
+
*
|
|
22
|
+
* @see ClientOptions, CreateColumnByType
|
|
23
|
+
*/
|
|
24
|
+
template <typename AdaptedColumnType>
|
|
25
|
+
class
|
|
26
|
+
[[deprecated("Makes implementation of LC(X) harder and code uglier. Will be removed in next major release (3.0) ")]]
|
|
27
|
+
LowCardinalitySerializationAdaptor : public AdaptedColumnType
|
|
28
|
+
{
|
|
29
|
+
public:
|
|
30
|
+
using AdaptedColumnType::AdaptedColumnType;
|
|
31
|
+
|
|
32
|
+
bool LoadPrefix(InputStream* input, size_t rows) override {
|
|
33
|
+
auto new_data_column = this->Slice(0, 0)->template As<AdaptedColumnType>();
|
|
34
|
+
ColumnLowCardinalityT<AdaptedColumnType> low_cardinality_col(new_data_column);
|
|
35
|
+
|
|
36
|
+
return low_cardinality_col.LoadPrefix(input, rows);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/// Loads column data from input stream.
|
|
40
|
+
bool LoadBody(InputStream* input, size_t rows) override {
|
|
41
|
+
auto new_data_column = this->CloneEmpty()->template As<AdaptedColumnType>();
|
|
42
|
+
|
|
43
|
+
ColumnLowCardinalityT<AdaptedColumnType> low_cardinality_col(new_data_column);
|
|
44
|
+
if (!low_cardinality_col.LoadBody(input, rows))
|
|
45
|
+
return false;
|
|
46
|
+
|
|
47
|
+
// It safe to reuse `flat_data_column` later since ColumnLowCardinalityT makes a deep copy, but still check just in case.
|
|
48
|
+
assert(new_data_column->Size() == 0);
|
|
49
|
+
|
|
50
|
+
for (size_t i = 0; i < low_cardinality_col.Size(); ++i)
|
|
51
|
+
new_data_column->Append(low_cardinality_col[i]);
|
|
52
|
+
|
|
53
|
+
this->Swap(*new_data_column);
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/// Saves column data to output stream.
|
|
58
|
+
void SaveBody(OutputStream* output) override {
|
|
59
|
+
ColumnLowCardinalityT<AdaptedColumnType>(this->template As<AdaptedColumnType>()).SaveBody(output);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
#include "map.h"
|
|
2
|
+
|
|
3
|
+
#include <stdexcept>
|
|
4
|
+
|
|
5
|
+
#include "../exceptions.h"
|
|
6
|
+
#include "utils.h"
|
|
7
|
+
|
|
8
|
+
namespace {
|
|
9
|
+
|
|
10
|
+
using namespace clickhouse;
|
|
11
|
+
|
|
12
|
+
TypeRef GetMapType(const Type& data_type) {
|
|
13
|
+
auto array = data_type.As<ArrayType>();
|
|
14
|
+
if (!array) {
|
|
15
|
+
throw ValidationError("Wrong type " + data_type.GetName() + " of data for map");
|
|
16
|
+
}
|
|
17
|
+
auto tuple = array->GetItemType()->As<TupleType>();
|
|
18
|
+
if (!tuple) {
|
|
19
|
+
throw ValidationError("Wrong type " + data_type.GetName() + " of data for map");
|
|
20
|
+
}
|
|
21
|
+
auto types = tuple->GetTupleType();
|
|
22
|
+
if (types.size() != 2) {
|
|
23
|
+
throw ValidationError("Wrong type " + data_type.GetName() + " of data for map");
|
|
24
|
+
}
|
|
25
|
+
return Type::CreateMap(types[0], types[1]);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
} // namespace
|
|
29
|
+
|
|
30
|
+
namespace clickhouse {
|
|
31
|
+
|
|
32
|
+
ColumnMap::ColumnMap(ColumnRef data)
|
|
33
|
+
: Column(GetMapType(data->GetType())), data_(data->As<ColumnArray>()) {
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
void ColumnMap::Reserve(size_t new_cap) {
|
|
37
|
+
data_->Reserve(new_cap);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
void ColumnMap::Clear() {
|
|
41
|
+
data_->Clear();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
void ColumnMap::Append(ColumnRef column) {
|
|
45
|
+
if (auto col = column->As<ColumnMap>()) {
|
|
46
|
+
data_->Append(col->data_);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
bool ColumnMap::LoadPrefix(InputStream* input, size_t rows) {
|
|
51
|
+
return data_->LoadPrefix(input, rows);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
bool ColumnMap::LoadBody(InputStream* input, size_t rows) {
|
|
55
|
+
return data_->LoadBody(input, rows);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
void ColumnMap::SavePrefix(OutputStream* output) {
|
|
59
|
+
data_->SavePrefix(output);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
void ColumnMap::SaveBody(OutputStream* output) {
|
|
63
|
+
data_->SaveBody(output);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
size_t ColumnMap::Size() const {
|
|
67
|
+
return data_->Size();
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
ColumnRef ColumnMap::Slice(size_t begin, size_t len) const {
|
|
71
|
+
return std::make_shared<ColumnMap>(data_->Slice(begin, len));
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
ColumnRef ColumnMap::CloneEmpty() const {
|
|
75
|
+
return std::make_shared<ColumnMap>(data_->CloneEmpty());
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
void ColumnMap::Swap(Column& other) {
|
|
79
|
+
auto& col = dynamic_cast<ColumnMap&>(other);
|
|
80
|
+
data_.swap(col.data_);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
ColumnRef ColumnMap::GetAsColumn(size_t n) const {
|
|
84
|
+
return data_->GetAsColumn(n);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
} // namespace clickhouse
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include "../base/projected_iterator.h"
|
|
4
|
+
#include "array.h"
|
|
5
|
+
#include "column.h"
|
|
6
|
+
#include "tuple.h"
|
|
7
|
+
|
|
8
|
+
#include <functional>
|
|
9
|
+
#include <map>
|
|
10
|
+
|
|
11
|
+
namespace clickhouse {
|
|
12
|
+
|
|
13
|
+
template <typename KeyColumnType, typename ValueColumnType>
|
|
14
|
+
class ColumnMapT;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Represents column of Map(K, V).
|
|
18
|
+
*/
|
|
19
|
+
class ColumnMap : public Column {
|
|
20
|
+
public:
|
|
21
|
+
/** Create a map of given type, with actual values and offsets.
|
|
22
|
+
*
|
|
23
|
+
* Both `data` and `offsets` are used (and modified) internally bye ColumnArray.
|
|
24
|
+
* Users are strongly advised against modifying contents of `data` or `offsets` afterwards.
|
|
25
|
+
*/
|
|
26
|
+
explicit ColumnMap(ColumnRef data);
|
|
27
|
+
|
|
28
|
+
/// Increase the capacity of the column for large block insertion.
|
|
29
|
+
void Reserve(size_t new_cap) override;
|
|
30
|
+
|
|
31
|
+
/// Appends content of given column to the end of current one.
|
|
32
|
+
void Append(ColumnRef column) override;
|
|
33
|
+
|
|
34
|
+
/// Loads column prefix from input stream.
|
|
35
|
+
bool LoadPrefix(InputStream* input, size_t rows) override;
|
|
36
|
+
|
|
37
|
+
/// Loads column data from input stream.
|
|
38
|
+
bool LoadBody(InputStream* input, size_t rows) override;
|
|
39
|
+
|
|
40
|
+
/// Saves column prefix to output stream.
|
|
41
|
+
void SavePrefix(OutputStream* output) override;
|
|
42
|
+
|
|
43
|
+
/// Saves column data to output stream.
|
|
44
|
+
void SaveBody(OutputStream* output) override;
|
|
45
|
+
|
|
46
|
+
/// Clear column data .
|
|
47
|
+
void Clear() override;
|
|
48
|
+
|
|
49
|
+
/// Returns count of rows in the column.
|
|
50
|
+
size_t Size() const override;
|
|
51
|
+
|
|
52
|
+
/// Makes slice of the current column.
|
|
53
|
+
ColumnRef Slice(size_t, size_t) const override;
|
|
54
|
+
ColumnRef CloneEmpty() const override;
|
|
55
|
+
void Swap(Column&) override;
|
|
56
|
+
|
|
57
|
+
/// Converts map at pos n to column.
|
|
58
|
+
/// Type of row is tuple {key, value}.
|
|
59
|
+
ColumnRef GetAsColumn(size_t n) const;
|
|
60
|
+
|
|
61
|
+
protected:
|
|
62
|
+
template <typename K, typename V>
|
|
63
|
+
friend class ColumnMapT;
|
|
64
|
+
|
|
65
|
+
ColumnMap(ColumnMap&& map);
|
|
66
|
+
|
|
67
|
+
private:
|
|
68
|
+
std::shared_ptr<ColumnArray> data_;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
template <typename K, typename V>
|
|
72
|
+
class ColumnMapT : public ColumnMap {
|
|
73
|
+
public:
|
|
74
|
+
using KeyColumnType = K;
|
|
75
|
+
using ValueColumnType = V;
|
|
76
|
+
using Key = std::decay_t<decltype(std::declval<KeyColumnType>().At(0))>;
|
|
77
|
+
using Value = std::decay_t<decltype(std::declval<ValueColumnType>().At(0))>;
|
|
78
|
+
using TupleColumnType = ColumnTupleT<KeyColumnType, ValueColumnType>;
|
|
79
|
+
using ArrayColumnType = ColumnArrayT<TupleColumnType>;
|
|
80
|
+
|
|
81
|
+
ColumnMapT(ColumnRef data)
|
|
82
|
+
: ColumnMap(data), typed_data_(data->AsStrict<ColumnArrayT<TupleColumnType>>()) {}
|
|
83
|
+
|
|
84
|
+
ColumnMapT(std::shared_ptr<KeyColumnType> keys, std::shared_ptr<ValueColumnType> values)
|
|
85
|
+
: ColumnMap(std::make_shared<ArrayColumnType>(std::make_shared<TupleColumnType>(
|
|
86
|
+
std::make_tuple(std::move(keys), std::move(values))))),
|
|
87
|
+
typed_data_(data_->template As<ArrayColumnType>()) {}
|
|
88
|
+
|
|
89
|
+
ColumnRef Slice(size_t begin, size_t len) const override {
|
|
90
|
+
return std::make_shared<ColumnMapT<K, V>>(typed_data_->Slice(begin, len));
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
ColumnRef CloneEmpty() const override {
|
|
94
|
+
return std::make_shared<ColumnMapT<K, V>>(typed_data_->CloneEmpty());
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
void Swap(Column& other) override {
|
|
98
|
+
auto& col = dynamic_cast<ColumnMapT<K, V>&>(other);
|
|
99
|
+
col.typed_data_.swap(typed_data_);
|
|
100
|
+
ColumnMap::Swap(other);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/// A single (row) value of the Map-column i.e. read-only map.
|
|
104
|
+
/// It has a linear time complexity to access items
|
|
105
|
+
/// Because data base type has same structure
|
|
106
|
+
/// "This lookup works now with a linear complexity."
|
|
107
|
+
/// https://clickhouse.com/docs/en/sql-reference/data-types/map
|
|
108
|
+
/// Convert it to a suitable container required to access more than one element
|
|
109
|
+
|
|
110
|
+
class MapValueView {
|
|
111
|
+
const typename ArrayColumnType::ArrayValueView data_;
|
|
112
|
+
|
|
113
|
+
public:
|
|
114
|
+
using ValueType = std::pair<Key, Value>;
|
|
115
|
+
|
|
116
|
+
MapValueView(typename ArrayColumnType::ArrayValueView data) : data_(std::move(data)) {}
|
|
117
|
+
|
|
118
|
+
inline auto operator[](const Key& key) const { return (*Find(key)).second; }
|
|
119
|
+
|
|
120
|
+
inline auto At(const Key& key) const {
|
|
121
|
+
auto it = Find(key);
|
|
122
|
+
if (it == end()) throw ValidationError("ColumnMap value key not found");
|
|
123
|
+
return (*it).second;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
class Iterator {
|
|
127
|
+
typename ArrayColumnType::ArrayValueView::Iterator data_iterator_;
|
|
128
|
+
|
|
129
|
+
public:
|
|
130
|
+
Iterator() = default;
|
|
131
|
+
|
|
132
|
+
Iterator(typename ArrayColumnType::ArrayValueView::Iterator data_iterator)
|
|
133
|
+
: data_iterator_(data_iterator) {}
|
|
134
|
+
|
|
135
|
+
using ValueType = std::pair<Key, Value>;
|
|
136
|
+
using difference_type = size_t;
|
|
137
|
+
using value_type = ValueType;
|
|
138
|
+
using pointer = void;
|
|
139
|
+
using reference = ValueType&;
|
|
140
|
+
using iterator_category = std::forward_iterator_tag;
|
|
141
|
+
|
|
142
|
+
inline auto operator*() const {
|
|
143
|
+
auto tuple = *data_iterator_;
|
|
144
|
+
return ValueType{std::get<0>(tuple), std::get<1>(tuple)};
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
inline Iterator& operator++() {
|
|
148
|
+
++data_iterator_;
|
|
149
|
+
return *this;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
inline bool operator==(const Iterator& other) const {
|
|
153
|
+
return this->data_iterator_ == other.data_iterator_;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
inline bool operator!=(const Iterator& other) const { return !(*this == other); }
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
// minimalistic stl-like container interface, hence the lowercase
|
|
160
|
+
inline Iterator begin() const { return Iterator{data_.begin()}; }
|
|
161
|
+
|
|
162
|
+
inline Iterator cbegin() const { return Iterator{data_.cbegin()}; }
|
|
163
|
+
|
|
164
|
+
inline Iterator end() const { return Iterator{data_.end()}; }
|
|
165
|
+
|
|
166
|
+
inline Iterator cend() const { return Iterator{data_.cend()}; }
|
|
167
|
+
|
|
168
|
+
inline size_t size() const { return data_.size(); }
|
|
169
|
+
|
|
170
|
+
// It is ugly to have both size() and Size(), but it is for compatitability with both STL
|
|
171
|
+
// and rest of the clickhouse-cpp.
|
|
172
|
+
inline size_t Size() const { return data_.Size(); }
|
|
173
|
+
|
|
174
|
+
inline size_t Count(const Key& key) const {
|
|
175
|
+
size_t result = 0;
|
|
176
|
+
for (auto item : data_) {
|
|
177
|
+
if (std::get<0>(item) == key) {
|
|
178
|
+
++result;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return result;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
inline Iterator Find(const Key& key) const {
|
|
185
|
+
for (auto it = data_.begin(); it != data_.end(); ++it) {
|
|
186
|
+
if (std::get<0>(*it) == key) {
|
|
187
|
+
return Iterator{it};
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return end();
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
inline bool operator==(const MapValueView& other) const {
|
|
194
|
+
if (size() != other.size()) {
|
|
195
|
+
return false;
|
|
196
|
+
}
|
|
197
|
+
const auto make_index = [](const auto& data) {
|
|
198
|
+
std::vector<size_t> result{data.Size()};
|
|
199
|
+
std::generate(result.begin(), result.end(), [i = 0] () mutable {return i++;});
|
|
200
|
+
std::sort(result.begin(), result.end(), [&data](size_t l, size_t r) {return data[l] < data[r];});
|
|
201
|
+
return result;
|
|
202
|
+
};
|
|
203
|
+
const auto index = make_index(data_);
|
|
204
|
+
for (const auto& val : other.data_) {
|
|
205
|
+
if (!std::binary_search(index.begin(), index.end(), val,
|
|
206
|
+
[&data = data_](const auto& l, size_t r) {return l < data[r];})) {
|
|
207
|
+
return false;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
return true;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
inline bool operator!=(const MapValueView& other) const { return !(*this == other); }
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
inline auto At(size_t index) const { return MapValueView{typed_data_->At(index)}; }
|
|
217
|
+
|
|
218
|
+
inline auto operator[](size_t index) const { return At(index); }
|
|
219
|
+
|
|
220
|
+
using ColumnMap::Append;
|
|
221
|
+
|
|
222
|
+
inline void Append(const MapValueView& value) { typed_data_->Append(value.data_); }
|
|
223
|
+
|
|
224
|
+
inline void Append(const std::vector<std::tuple<Key, Value>>& tuples) {
|
|
225
|
+
typed_data_->Append(tuples.begin(), tuples.end());
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
template <typename T>
|
|
229
|
+
inline void Append(const T& value) {
|
|
230
|
+
using BaseIter = decltype(value.begin());
|
|
231
|
+
using KeyOfT = decltype(std::declval<BaseIter>()->first);
|
|
232
|
+
using ValOfT = decltype(std::declval<BaseIter>()->second);
|
|
233
|
+
using Functor = std::function<std::tuple<KeyOfT, ValOfT>(const BaseIter&)>;
|
|
234
|
+
using Iterator = ProjectedIterator<Functor, BaseIter>;
|
|
235
|
+
|
|
236
|
+
Functor functor = [](const BaseIter& i) {
|
|
237
|
+
return std::make_tuple(std::cref(i->first), std::cref(i->second));
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
typed_data_->Append(Iterator{value.begin(), functor}, Iterator{value.end(), functor});
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
static auto Wrap(ColumnMap&& col) {
|
|
244
|
+
auto data = ArrayColumnType::Wrap(std::move(col.data_));
|
|
245
|
+
return std::make_shared<ColumnMapT<K, V>>(std::move(data));
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
static auto Wrap(Column&& col) { return Wrap(std::move(dynamic_cast<ColumnMap&&>(col))); }
|
|
249
|
+
|
|
250
|
+
// Helper to simplify integration with other APIs
|
|
251
|
+
static auto Wrap(ColumnRef&& col) { return Wrap(std::move(*col->AsStrict<ColumnMap>())); }
|
|
252
|
+
|
|
253
|
+
private:
|
|
254
|
+
std::shared_ptr<ArrayColumnType> typed_data_;
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
} // namespace clickhouse
|