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,258 @@
|
|
|
1
|
+
#include "compressed.h"
|
|
2
|
+
#include "wire_format.h"
|
|
3
|
+
#include "output.h"
|
|
4
|
+
#include "clickhouse/exceptions.h"
|
|
5
|
+
|
|
6
|
+
#include <city.h>
|
|
7
|
+
#include <lz4.h>
|
|
8
|
+
#include <exception>
|
|
9
|
+
#include <zstd.h>
|
|
10
|
+
#include <stdexcept>
|
|
11
|
+
#include <system_error>
|
|
12
|
+
|
|
13
|
+
namespace {
|
|
14
|
+
constexpr size_t HEADER_SIZE = 9;
|
|
15
|
+
|
|
16
|
+
// see DB::CompressionMethodByte from src/Compression/CompressionInfo.h of ClickHouse project
|
|
17
|
+
enum class CompressionMethodByte : uint8_t {
|
|
18
|
+
NONE = 0x02,
|
|
19
|
+
LZ4 = 0x82,
|
|
20
|
+
ZSTD = 0x90,
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
// Documentation says that compression is faster when output buffer is larger than LZ4_compressBound/ZSTD_compressBound estimation.
|
|
24
|
+
constexpr size_t EXTRA_COMPRESS_BUFFER_SIZE = 4096;
|
|
25
|
+
constexpr size_t DBMS_MAX_COMPRESSED_SIZE = 0x40000000ULL; // 1GB
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
namespace clickhouse {
|
|
29
|
+
|
|
30
|
+
CompressedInput::CompressedInput(InputStream* input)
|
|
31
|
+
: input_(input)
|
|
32
|
+
{
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
CompressedInput::~CompressedInput() {
|
|
36
|
+
if (!mem_.Exhausted()) {
|
|
37
|
+
#if __cplusplus < 201703L
|
|
38
|
+
if (!std::uncaught_exception()) {
|
|
39
|
+
#else
|
|
40
|
+
if (!std::uncaught_exceptions()) {
|
|
41
|
+
#endif
|
|
42
|
+
throw CompressionError("some data was not read");
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
size_t CompressedInput::DoNext(const void** ptr, size_t len) {
|
|
48
|
+
if (mem_.Exhausted()) {
|
|
49
|
+
if (!Decompress()) {
|
|
50
|
+
return 0;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return mem_.Next(ptr, len);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
bool CompressedInput::Decompress() {
|
|
58
|
+
uint128 hash;
|
|
59
|
+
uint32_t compressed = 0;
|
|
60
|
+
uint32_t original = 0;
|
|
61
|
+
uint8_t method = 0;
|
|
62
|
+
|
|
63
|
+
if (!WireFormat::ReadFixed(*input_, &hash)) {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
if (!WireFormat::ReadFixed(*input_, &method)) {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (method != static_cast<uint8_t>(CompressionMethodByte::LZ4) && method != static_cast<uint8_t>(CompressionMethodByte::ZSTD)) {
|
|
71
|
+
throw CompressionError("unsupported compression method " + std::to_string((method)));
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (!WireFormat::ReadFixed(*input_, &compressed)) {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
if (!WireFormat::ReadFixed(*input_, &original)) {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (compressed > DBMS_MAX_COMPRESSED_SIZE) {
|
|
82
|
+
throw CompressionError("compressed data too big");
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
Buffer tmp(compressed);
|
|
86
|
+
|
|
87
|
+
// Data header
|
|
88
|
+
{
|
|
89
|
+
BufferOutput out(&tmp);
|
|
90
|
+
out.Write(&method, sizeof(method));
|
|
91
|
+
out.Write(&compressed, sizeof(compressed));
|
|
92
|
+
out.Write(&original, sizeof(original));
|
|
93
|
+
out.Flush();
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (!WireFormat::ReadBytes(*input_, tmp.data() + HEADER_SIZE, compressed - HEADER_SIZE)) {
|
|
97
|
+
return false;
|
|
98
|
+
} else {
|
|
99
|
+
if (hash != CityHash128((const char*)tmp.data(), compressed)) {
|
|
100
|
+
throw CompressionError("data was corrupted");
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
data_ = Buffer(original);
|
|
105
|
+
|
|
106
|
+
switch (method) {
|
|
107
|
+
case static_cast<uint8_t>(CompressionMethodByte::LZ4): {
|
|
108
|
+
if (LZ4_decompress_safe((const char*)tmp.data() + HEADER_SIZE, (char*)data_.data(), static_cast<int>(compressed - HEADER_SIZE), original) < 0) {
|
|
109
|
+
throw CompressionError("can't decompress LZ4-encoded data");
|
|
110
|
+
} else {
|
|
111
|
+
mem_.Reset(data_.data(), original);
|
|
112
|
+
}
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
case static_cast<uint8_t>(CompressionMethodByte::ZSTD): {
|
|
117
|
+
size_t res = ZSTD_decompress((char*)data_.data(), original, (const char*)tmp.data() + HEADER_SIZE, static_cast<int>(compressed - HEADER_SIZE));
|
|
118
|
+
|
|
119
|
+
if (ZSTD_isError(res)) {
|
|
120
|
+
throw CompressionError("can't decompress ZSTD-encoded data, ZSTD error: " + std::string(ZSTD_getErrorName(res)));
|
|
121
|
+
} else {
|
|
122
|
+
mem_.Reset(data_.data(), original);
|
|
123
|
+
}
|
|
124
|
+
return true;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
case static_cast<uint8_t>(CompressionMethodByte::NONE): {
|
|
128
|
+
throw CompressionError("compression method not defined" + std::to_string((method)));
|
|
129
|
+
}
|
|
130
|
+
default: {
|
|
131
|
+
throw CompressionError("Unknown or unsupported compression method " + std::to_string((method)));
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return true;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
CompressedOutput::CompressedOutput(OutputStream * destination, size_t max_compressed_chunk_size, CompressionMethod method)
|
|
140
|
+
: destination_(destination)
|
|
141
|
+
, max_compressed_chunk_size_(max_compressed_chunk_size)
|
|
142
|
+
, method_(method)
|
|
143
|
+
{
|
|
144
|
+
PreallocateCompressBuffer(max_compressed_chunk_size);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
CompressedOutput::~CompressedOutput() { }
|
|
148
|
+
|
|
149
|
+
size_t CompressedOutput::DoWrite(const void* data, size_t len) {
|
|
150
|
+
const size_t original_len = len;
|
|
151
|
+
// what if len > max_compressed_chunk_size_ ?
|
|
152
|
+
const size_t max_chunk_size = max_compressed_chunk_size_ > 0 ? max_compressed_chunk_size_ : len;
|
|
153
|
+
if (max_chunk_size > max_compressed_chunk_size_) {
|
|
154
|
+
PreallocateCompressBuffer(len);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
while (len > 0) {
|
|
158
|
+
auto to_compress = std::min(len, max_chunk_size);
|
|
159
|
+
Compress(data, to_compress);
|
|
160
|
+
|
|
161
|
+
len -= to_compress;
|
|
162
|
+
data = reinterpret_cast<const char*>(data) + to_compress;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
return original_len - len;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
void CompressedOutput::DoFlush() {
|
|
169
|
+
destination_->Flush();
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
void CompressedOutput::Compress(const void * data, size_t len) {
|
|
173
|
+
switch (method_) {
|
|
174
|
+
case clickhouse::CompressionMethod::LZ4: {
|
|
175
|
+
const auto compressed_size = LZ4_compress_default(
|
|
176
|
+
(const char*)data,
|
|
177
|
+
(char*)compressed_buffer_.data() + HEADER_SIZE,
|
|
178
|
+
static_cast<int>(len),
|
|
179
|
+
static_cast<int>(compressed_buffer_.size() - HEADER_SIZE));
|
|
180
|
+
if (compressed_size <= 0)
|
|
181
|
+
throw CompressionError("Failed to compress chunk of " + std::to_string(len) + " bytes, "
|
|
182
|
+
"LZ4 error: " + std::to_string(compressed_size));
|
|
183
|
+
|
|
184
|
+
{
|
|
185
|
+
auto header = compressed_buffer_.data();
|
|
186
|
+
WriteUnaligned(header, CompressionMethodByte::LZ4);
|
|
187
|
+
// Compressed data size with header
|
|
188
|
+
WriteUnaligned(header + 1, static_cast<uint32_t>(compressed_size + HEADER_SIZE));
|
|
189
|
+
// Original data size
|
|
190
|
+
WriteUnaligned(header + 5, static_cast<uint32_t>(len));
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
WireFormat::WriteFixed(*destination_, CityHash128((const char*)compressed_buffer_.data(), compressed_size + HEADER_SIZE));
|
|
194
|
+
WireFormat::WriteBytes(*destination_, compressed_buffer_.data(), compressed_size + HEADER_SIZE);
|
|
195
|
+
break;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
case clickhouse::CompressionMethod::ZSTD: {
|
|
199
|
+
const size_t compressed_size = ZSTD_compress(
|
|
200
|
+
(char*)compressed_buffer_.data() + HEADER_SIZE,
|
|
201
|
+
static_cast<int>(compressed_buffer_.size() - HEADER_SIZE),
|
|
202
|
+
(const char*)data,
|
|
203
|
+
static_cast<int>(len),
|
|
204
|
+
ZSTD_fast);
|
|
205
|
+
if (ZSTD_isError(compressed_size))
|
|
206
|
+
throw CompressionError("Failed to compress chunk of " + std::to_string(len) + " bytes, "
|
|
207
|
+
"ZSTD error: " + std::string(ZSTD_getErrorName(compressed_size)));
|
|
208
|
+
|
|
209
|
+
{
|
|
210
|
+
auto header = compressed_buffer_.data();
|
|
211
|
+
WriteUnaligned(header, CompressionMethodByte::ZSTD);
|
|
212
|
+
// Compressed data size with header
|
|
213
|
+
WriteUnaligned(header + 1, static_cast<uint32_t>(compressed_size + HEADER_SIZE));
|
|
214
|
+
// Original data size
|
|
215
|
+
WriteUnaligned(header + 5, static_cast<uint32_t>(len));
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
WireFormat::WriteFixed(*destination_, CityHash128((const char*)compressed_buffer_.data(), compressed_size + HEADER_SIZE));
|
|
219
|
+
WireFormat::WriteBytes(*destination_, compressed_buffer_.data(), compressed_size + HEADER_SIZE);
|
|
220
|
+
break;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
case clickhouse::CompressionMethod::None: {
|
|
224
|
+
throw CompressionError("no compression defined");
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
destination_->Flush();
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
void CompressedOutput::PreallocateCompressBuffer(size_t input_size) {
|
|
232
|
+
switch (method_) {
|
|
233
|
+
case clickhouse::CompressionMethod::LZ4: {
|
|
234
|
+
const auto estimated_compressed_buffer_size = LZ4_compressBound(static_cast<int>(input_size));
|
|
235
|
+
if (estimated_compressed_buffer_size <= 0)
|
|
236
|
+
throw CompressionError("Failed to estimate compressed buffer size, LZ4 error: " + std::to_string(estimated_compressed_buffer_size));
|
|
237
|
+
|
|
238
|
+
compressed_buffer_.resize(estimated_compressed_buffer_size + HEADER_SIZE + EXTRA_COMPRESS_BUFFER_SIZE);
|
|
239
|
+
break;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
case clickhouse::CompressionMethod::ZSTD: {
|
|
243
|
+
const size_t estimated_compressed_buffer_size = ZSTD_compressBound(static_cast<int>(input_size));
|
|
244
|
+
if (ZSTD_isError(estimated_compressed_buffer_size))
|
|
245
|
+
throw CompressionError("Failed to estimate compressed buffer size, ZSTD error: " + std::string(ZSTD_getErrorName(estimated_compressed_buffer_size)));
|
|
246
|
+
|
|
247
|
+
compressed_buffer_.resize(estimated_compressed_buffer_size + HEADER_SIZE + EXTRA_COMPRESS_BUFFER_SIZE);
|
|
248
|
+
break;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
case clickhouse::CompressionMethod::None: {
|
|
252
|
+
/// do nothing
|
|
253
|
+
break;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include "input.h"
|
|
4
|
+
#include "output.h"
|
|
5
|
+
#include "buffer.h"
|
|
6
|
+
|
|
7
|
+
#include "clickhouse/client.h"
|
|
8
|
+
|
|
9
|
+
namespace clickhouse {
|
|
10
|
+
|
|
11
|
+
class CompressedInput : public ZeroCopyInput {
|
|
12
|
+
public:
|
|
13
|
+
explicit CompressedInput(InputStream* input);
|
|
14
|
+
~CompressedInput() override;
|
|
15
|
+
|
|
16
|
+
protected:
|
|
17
|
+
size_t DoNext(const void** ptr, size_t len) override;
|
|
18
|
+
|
|
19
|
+
bool Decompress();
|
|
20
|
+
|
|
21
|
+
private:
|
|
22
|
+
InputStream* const input_;
|
|
23
|
+
|
|
24
|
+
Buffer data_;
|
|
25
|
+
ArrayInput mem_;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
class CompressedOutput : public OutputStream {
|
|
29
|
+
public:
|
|
30
|
+
explicit CompressedOutput(OutputStream* destination, size_t max_compressed_chunk_size = 0, CompressionMethod method = CompressionMethod::LZ4);
|
|
31
|
+
~CompressedOutput() override;
|
|
32
|
+
|
|
33
|
+
protected:
|
|
34
|
+
size_t DoWrite(const void* data, size_t len) override;
|
|
35
|
+
void DoFlush() override;
|
|
36
|
+
|
|
37
|
+
private:
|
|
38
|
+
void Compress(const void * data, size_t len);
|
|
39
|
+
void PreallocateCompressBuffer(size_t input_size);
|
|
40
|
+
|
|
41
|
+
private:
|
|
42
|
+
OutputStream * destination_;
|
|
43
|
+
const size_t max_compressed_chunk_size_;
|
|
44
|
+
Buffer compressed_buffer_;
|
|
45
|
+
CompressionMethod method_;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#include "endpoints_iterator.h"
|
|
2
|
+
#include <clickhouse/client.h>
|
|
3
|
+
|
|
4
|
+
namespace clickhouse {
|
|
5
|
+
|
|
6
|
+
RoundRobinEndpointsIterator::RoundRobinEndpointsIterator(const std::vector<Endpoint>& _endpoints)
|
|
7
|
+
: endpoints (_endpoints)
|
|
8
|
+
, current_index (endpoints.size() - 1ull)
|
|
9
|
+
{
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
Endpoint RoundRobinEndpointsIterator::Next()
|
|
13
|
+
{
|
|
14
|
+
current_index = (current_index + 1ull) % endpoints.size();
|
|
15
|
+
return endpoints[current_index];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
RoundRobinEndpointsIterator::~RoundRobinEndpointsIterator() = default;
|
|
19
|
+
|
|
20
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include "clickhouse/client.h"
|
|
4
|
+
#include <vector>
|
|
5
|
+
|
|
6
|
+
namespace clickhouse {
|
|
7
|
+
|
|
8
|
+
struct ClientOptions;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Base class for iterating through endpoints.
|
|
12
|
+
*/
|
|
13
|
+
class EndpointsIteratorBase
|
|
14
|
+
{
|
|
15
|
+
public:
|
|
16
|
+
virtual ~EndpointsIteratorBase() = default;
|
|
17
|
+
|
|
18
|
+
virtual Endpoint Next() = 0;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
class RoundRobinEndpointsIterator : public EndpointsIteratorBase
|
|
22
|
+
{
|
|
23
|
+
public:
|
|
24
|
+
explicit RoundRobinEndpointsIterator(const std::vector<Endpoint>& opts);
|
|
25
|
+
Endpoint Next() override;
|
|
26
|
+
|
|
27
|
+
~RoundRobinEndpointsIterator() override;
|
|
28
|
+
|
|
29
|
+
private:
|
|
30
|
+
const std::vector<Endpoint>& endpoints;
|
|
31
|
+
size_t current_index;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
#include "input.h"
|
|
2
|
+
|
|
3
|
+
#include <algorithm>
|
|
4
|
+
#include <memory.h>
|
|
5
|
+
|
|
6
|
+
namespace clickhouse {
|
|
7
|
+
|
|
8
|
+
bool ZeroCopyInput::Skip(size_t bytes) {
|
|
9
|
+
while (bytes > 0) {
|
|
10
|
+
const void* ptr;
|
|
11
|
+
size_t len = Next(&ptr, bytes);
|
|
12
|
+
|
|
13
|
+
if (len == 0) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
bytes -= len;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
size_t ZeroCopyInput::DoRead(void* buf, size_t len) {
|
|
24
|
+
const void* ptr;
|
|
25
|
+
size_t result = DoNext(&ptr, len);
|
|
26
|
+
|
|
27
|
+
if (result) {
|
|
28
|
+
memcpy(buf, ptr, result);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return result;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
ArrayInput::ArrayInput() noexcept
|
|
35
|
+
: data_(nullptr)
|
|
36
|
+
, len_(0)
|
|
37
|
+
{
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
ArrayInput::ArrayInput(const void* buf, size_t len) noexcept
|
|
41
|
+
: data_(static_cast<const uint8_t*>(buf))
|
|
42
|
+
, len_(len)
|
|
43
|
+
{
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
ArrayInput::~ArrayInput() = default;
|
|
47
|
+
|
|
48
|
+
size_t ArrayInput::DoNext(const void** ptr, size_t len) {
|
|
49
|
+
len = std::min(len_, len);
|
|
50
|
+
|
|
51
|
+
*ptr = data_;
|
|
52
|
+
len_ -= len;
|
|
53
|
+
data_ += len;
|
|
54
|
+
|
|
55
|
+
return len;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
BufferedInput::BufferedInput(std::unique_ptr<InputStream> source, size_t buflen)
|
|
60
|
+
: source_(std::move(source))
|
|
61
|
+
, array_input_(nullptr, 0)
|
|
62
|
+
, buffer_(buflen)
|
|
63
|
+
{
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
BufferedInput::~BufferedInput() = default;
|
|
67
|
+
|
|
68
|
+
void BufferedInput::Reset() {
|
|
69
|
+
array_input_.Reset(nullptr, 0);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
size_t BufferedInput::DoNext(const void** ptr, size_t len) {
|
|
73
|
+
if (array_input_.Exhausted()) {
|
|
74
|
+
array_input_.Reset(
|
|
75
|
+
buffer_.data(), source_->Read(buffer_.data(), buffer_.size())
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return array_input_.Next(ptr, len);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
size_t BufferedInput::DoRead(void* buf, size_t len) {
|
|
83
|
+
if (array_input_.Exhausted()) {
|
|
84
|
+
if (len > buffer_.size() / 2) {
|
|
85
|
+
return source_->Read(buf, len);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
array_input_.Reset(
|
|
89
|
+
buffer_.data(), source_->Read(buffer_.data(), buffer_.size())
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return array_input_.Read(buf, len);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <cstddef>
|
|
4
|
+
#include <cstdint>
|
|
5
|
+
#include <vector>
|
|
6
|
+
#include <memory>
|
|
7
|
+
|
|
8
|
+
namespace clickhouse {
|
|
9
|
+
|
|
10
|
+
class InputStream {
|
|
11
|
+
public:
|
|
12
|
+
virtual ~InputStream() noexcept (false)
|
|
13
|
+
{ }
|
|
14
|
+
|
|
15
|
+
/// Reads one byte from the stream.
|
|
16
|
+
inline bool ReadByte(uint8_t* byte) {
|
|
17
|
+
return DoRead(byte, sizeof(uint8_t)) == sizeof(uint8_t);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/// Reads some data from the stream.
|
|
21
|
+
inline size_t Read(void* buf, size_t len) {
|
|
22
|
+
return DoRead(buf, len);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Skips a number of bytes. Returns false if an underlying read error occurs.
|
|
26
|
+
virtual bool Skip(size_t bytes) = 0;
|
|
27
|
+
|
|
28
|
+
protected:
|
|
29
|
+
virtual size_t DoRead(void* buf, size_t len) = 0;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class ZeroCopyInput : public InputStream {
|
|
34
|
+
public:
|
|
35
|
+
inline size_t Next(const void** buf, size_t len) {
|
|
36
|
+
return DoNext(buf, len);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
bool Skip(size_t bytes) override;
|
|
40
|
+
|
|
41
|
+
protected:
|
|
42
|
+
virtual size_t DoNext(const void** ptr, size_t len) = 0;
|
|
43
|
+
|
|
44
|
+
size_t DoRead(void* buf, size_t len) override;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* A ZeroCopyInput stream backed by an in-memory array of bytes.
|
|
50
|
+
*/
|
|
51
|
+
class ArrayInput : public ZeroCopyInput {
|
|
52
|
+
public:
|
|
53
|
+
ArrayInput() noexcept;
|
|
54
|
+
ArrayInput(const void* buf, size_t len) noexcept;
|
|
55
|
+
~ArrayInput() override;
|
|
56
|
+
|
|
57
|
+
/// Number of bytes available in the stream.
|
|
58
|
+
inline size_t Avail() const noexcept {
|
|
59
|
+
return len_;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/// Current read position in the memory block used by this stream.
|
|
63
|
+
inline const uint8_t* Data() const noexcept {
|
|
64
|
+
return data_;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/// Whether there is more data in the stream.
|
|
68
|
+
inline bool Exhausted() const noexcept {
|
|
69
|
+
return !Avail();
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
inline void Reset(const void* buf, size_t len) noexcept {
|
|
73
|
+
data_ = static_cast<const uint8_t*>(buf);
|
|
74
|
+
len_ = len;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
private:
|
|
78
|
+
size_t DoNext(const void** ptr, size_t len) override;
|
|
79
|
+
|
|
80
|
+
private:
|
|
81
|
+
const uint8_t* data_;
|
|
82
|
+
size_t len_;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
class BufferedInput : public ZeroCopyInput {
|
|
87
|
+
public:
|
|
88
|
+
BufferedInput(std::unique_ptr<InputStream> source, size_t buflen = 8192);
|
|
89
|
+
~BufferedInput() override;
|
|
90
|
+
|
|
91
|
+
void Reset();
|
|
92
|
+
|
|
93
|
+
protected:
|
|
94
|
+
size_t DoRead(void* buf, size_t len) override;
|
|
95
|
+
size_t DoNext(const void** ptr, size_t len) override;
|
|
96
|
+
|
|
97
|
+
private:
|
|
98
|
+
std::unique_ptr<InputStream> const source_;
|
|
99
|
+
ArrayInput array_input_;
|
|
100
|
+
std::vector<uint8_t> buffer_;
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include "uuid.h"
|
|
4
|
+
|
|
5
|
+
#include <string>
|
|
6
|
+
|
|
7
|
+
namespace clickhouse::open_telemetry {
|
|
8
|
+
|
|
9
|
+
/// See https://www.w3.org/TR/trace-context/ for trace_flags definition
|
|
10
|
+
enum TraceFlags : uint8_t {
|
|
11
|
+
TRACE_FLAG_NONE = 0,
|
|
12
|
+
TRACE_FLAG_SAMPLED = 1,
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/// The runtime info we need to create new OpenTelemetry spans.
|
|
16
|
+
struct TracingContext {
|
|
17
|
+
UUID trace_id{};
|
|
18
|
+
uint64_t span_id = 0;
|
|
19
|
+
std::string tracestate;
|
|
20
|
+
uint8_t trace_flags = TRACE_FLAG_NONE;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
} // namespace clickhouse::open_telemetry
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
#include "output.h"
|
|
2
|
+
|
|
3
|
+
#include <algorithm>
|
|
4
|
+
#include <assert.h>
|
|
5
|
+
#include <memory.h>
|
|
6
|
+
|
|
7
|
+
namespace clickhouse {
|
|
8
|
+
|
|
9
|
+
size_t ZeroCopyOutput::DoWrite(const void* data, size_t len) {
|
|
10
|
+
const size_t original_len = len;
|
|
11
|
+
while (len > 0) {
|
|
12
|
+
void* ptr;
|
|
13
|
+
size_t result = DoNext(&ptr, len);
|
|
14
|
+
|
|
15
|
+
if (result) {
|
|
16
|
+
memcpy(ptr, data, result);
|
|
17
|
+
len -= result;
|
|
18
|
+
data = static_cast<const uint8_t*>(data) + result;
|
|
19
|
+
} else {
|
|
20
|
+
break;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return original_len - len;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
ArrayOutput::ArrayOutput(void* buf, size_t len)
|
|
29
|
+
: buf_(static_cast<uint8_t*>(buf))
|
|
30
|
+
, end_(buf_ + len)
|
|
31
|
+
, buffer_size_(len)
|
|
32
|
+
{
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
ArrayOutput::~ArrayOutput() = default;
|
|
36
|
+
|
|
37
|
+
size_t ArrayOutput::DoNext(void** data, size_t len) {
|
|
38
|
+
len = std::min(len, Avail());
|
|
39
|
+
|
|
40
|
+
*data = buf_;
|
|
41
|
+
buf_ += len;
|
|
42
|
+
|
|
43
|
+
return len;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
BufferOutput::BufferOutput(Buffer* buf)
|
|
48
|
+
: buf_(buf)
|
|
49
|
+
, pos_(0)
|
|
50
|
+
{
|
|
51
|
+
assert(buf_);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
BufferOutput::~BufferOutput()
|
|
55
|
+
{ }
|
|
56
|
+
|
|
57
|
+
size_t BufferOutput::DoNext(void** data, size_t len) {
|
|
58
|
+
if (pos_ + len > buf_->size()) {
|
|
59
|
+
buf_->resize(pos_ + len);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
*data = buf_->data() + pos_;
|
|
63
|
+
pos_ += len;
|
|
64
|
+
|
|
65
|
+
return len;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
BufferedOutput::BufferedOutput(std::unique_ptr<OutputStream> destination, size_t buflen)
|
|
70
|
+
: destination_(std::move(destination))
|
|
71
|
+
, buffer_(buflen)
|
|
72
|
+
, array_output_(buffer_.data(), buflen)
|
|
73
|
+
{
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
BufferedOutput::~BufferedOutput() { }
|
|
77
|
+
|
|
78
|
+
void BufferedOutput::Reset() {
|
|
79
|
+
array_output_.Reset(buffer_.data(), buffer_.size());
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
void BufferedOutput::DoFlush() {
|
|
83
|
+
if (array_output_.Data() != buffer_.data()) {
|
|
84
|
+
size_t len = array_output_.Data() - buffer_.data();
|
|
85
|
+
const uint8_t* buf = buffer_.data();
|
|
86
|
+
while (len > 0) {
|
|
87
|
+
const size_t written = destination_->Write(buf, len);
|
|
88
|
+
buf += written;
|
|
89
|
+
len -= written;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
destination_->Flush();
|
|
93
|
+
|
|
94
|
+
array_output_.Reset(buffer_.data(), buffer_.size());
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
size_t BufferedOutput::DoNext(void** data, size_t len) {
|
|
99
|
+
if (array_output_.Avail() < len) {
|
|
100
|
+
Flush();
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return array_output_.Next(data, len);
|
|
104
|
+
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
size_t BufferedOutput::DoWrite(const void* data, size_t len) {
|
|
108
|
+
if (array_output_.Avail() < len) {
|
|
109
|
+
Flush();
|
|
110
|
+
|
|
111
|
+
if (len > buffer_.size() / 2) {
|
|
112
|
+
return destination_->Write(data, len);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return array_output_.Write(data, len);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
}
|