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,255 @@
|
|
|
1
|
+
#include "decimal.h"
|
|
2
|
+
|
|
3
|
+
namespace
|
|
4
|
+
{
|
|
5
|
+
using namespace clickhouse;
|
|
6
|
+
|
|
7
|
+
#ifdef ABSL_HAVE_INTRINSIC_INT128
|
|
8
|
+
template <typename T>
|
|
9
|
+
inline bool addOverflow(const Int128 & l, const T & r, Int128 * result)
|
|
10
|
+
{
|
|
11
|
+
__int128 res;
|
|
12
|
+
const auto ret_value = __builtin_add_overflow(static_cast<__int128>(l), static_cast<__int128>(r), &res);
|
|
13
|
+
|
|
14
|
+
*result = res;
|
|
15
|
+
return ret_value;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
template <typename T>
|
|
19
|
+
inline bool mulOverflow(const Int128 & l, const T & r, Int128 * result)
|
|
20
|
+
{
|
|
21
|
+
__int128 res;
|
|
22
|
+
const auto ret_value = __builtin_mul_overflow(static_cast<__int128>(l), static_cast<__int128>(r), &res);
|
|
23
|
+
|
|
24
|
+
*result = res;
|
|
25
|
+
return ret_value;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
#else
|
|
29
|
+
template <typename T>
|
|
30
|
+
inline bool getSignBit(const T & v)
|
|
31
|
+
{
|
|
32
|
+
return v < static_cast<T>(0);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
inline bool getSignBit(const Int128 & v)
|
|
36
|
+
{
|
|
37
|
+
// static constexpr Int128 zero {};
|
|
38
|
+
// return v < zero;
|
|
39
|
+
|
|
40
|
+
// Sign of the whole absl::int128 value is determined by sign of higher 64 bits.
|
|
41
|
+
return absl::Int128High64(v) < 0;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
inline bool addOverflow(const Int128 & l, const Int128 & r, Int128 * result)
|
|
45
|
+
{
|
|
46
|
+
// *result = l + r;
|
|
47
|
+
// const auto result_sign = getSignBit(*result);
|
|
48
|
+
// return l_sign == r_sign && l_sign != result_sign;
|
|
49
|
+
|
|
50
|
+
// Based on code from:
|
|
51
|
+
// https://wiki.sei.cmu.edu/confluence/display/c/INT32-C.+Ensure+that+operations+on+signed+integers+do+not+result+in+overflow#INT32C.Ensurethatoperationsonsignedintegersdonotresultinoverflow-CompliantSolution
|
|
52
|
+
const auto r_positive = !getSignBit(r);
|
|
53
|
+
|
|
54
|
+
if ((r_positive && (l > (std::numeric_limits<Int128>::max() - r))) ||
|
|
55
|
+
(!r_positive && (l < (std::numeric_limits<Int128>::min() - r)))) {
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
*result = l + r;
|
|
59
|
+
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
template <typename T>
|
|
64
|
+
inline bool mulOverflow(const Int128 & l, const T & r, Int128 * result)
|
|
65
|
+
{
|
|
66
|
+
// Based on code from:
|
|
67
|
+
// https://wiki.sei.cmu.edu/confluence/display/c/INT32-C.+Ensure+that+operations+on+signed+integers+do+not+result+in+overflow#INT32C.Ensurethatoperationsonsignedintegersdonotresultinoverflow-CompliantSolution.3
|
|
68
|
+
const auto l_positive = !getSignBit(l);
|
|
69
|
+
const auto r_positive = !getSignBit(r);
|
|
70
|
+
|
|
71
|
+
if (l_positive) {
|
|
72
|
+
if (r_positive) {
|
|
73
|
+
if (r != 0 && l > (std::numeric_limits<Int128>::max() / r)) {
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
} else {
|
|
77
|
+
if (l != 0 && r < (std::numeric_limits<Int128>::min() / l)) {
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
} else {
|
|
82
|
+
if (r_positive) {
|
|
83
|
+
if (r != 0 && l < (std::numeric_limits<Int128>::min() / r)) {
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
} else {
|
|
87
|
+
if (l != 0 && (r < (std::numeric_limits<Int128>::max() / l))) {
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
*result = l * r;
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
#endif
|
|
97
|
+
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
namespace clickhouse {
|
|
101
|
+
|
|
102
|
+
ColumnDecimal::ColumnDecimal(size_t precision, size_t scale)
|
|
103
|
+
: Column(Type::CreateDecimal(precision, scale))
|
|
104
|
+
{
|
|
105
|
+
if (precision <= 9) {
|
|
106
|
+
data_ = std::make_shared<ColumnInt32>();
|
|
107
|
+
} else if (precision <= 18) {
|
|
108
|
+
data_ = std::make_shared<ColumnInt64>();
|
|
109
|
+
} else {
|
|
110
|
+
data_ = std::make_shared<ColumnInt128>();
|
|
111
|
+
}
|
|
112
|
+
data_type_code_ = data_->Type()->GetCode();
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
ColumnDecimal::ColumnDecimal(TypeRef type, ColumnRef data)
|
|
116
|
+
: Column(type),
|
|
117
|
+
data_(data),
|
|
118
|
+
data_type_code_(data_->Type()->GetCode())
|
|
119
|
+
{
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
void ColumnDecimal::Append(const Int128& value) {
|
|
123
|
+
switch (data_type_code_) {
|
|
124
|
+
case Type::Int32:
|
|
125
|
+
static_cast<ColumnInt32*>(data_.get())->Append(static_cast<int32_t>(value));
|
|
126
|
+
break;
|
|
127
|
+
case Type::Int64:
|
|
128
|
+
static_cast<ColumnInt64*>(data_.get())->Append(static_cast<int64_t>(value));
|
|
129
|
+
break;
|
|
130
|
+
default:
|
|
131
|
+
static_cast<ColumnInt128*>(data_.get())->Append(static_cast<Int128>(value));
|
|
132
|
+
break;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
void ColumnDecimal::Append(const std::string& value) {
|
|
137
|
+
Int128 int_value = 0;
|
|
138
|
+
auto c = value.begin();
|
|
139
|
+
auto end = value.end();
|
|
140
|
+
bool sign = true;
|
|
141
|
+
bool has_dot = false;
|
|
142
|
+
|
|
143
|
+
size_t zeros = 0;
|
|
144
|
+
|
|
145
|
+
while (c != end) {
|
|
146
|
+
if (*c == '-') {
|
|
147
|
+
sign = false;
|
|
148
|
+
if (c != value.begin()) {
|
|
149
|
+
break;
|
|
150
|
+
}
|
|
151
|
+
} else if (*c == '.' && !has_dot) {
|
|
152
|
+
size_t distance = std::distance(c, end) - 1;
|
|
153
|
+
auto scale = type_->As<DecimalType>()->GetScale();
|
|
154
|
+
|
|
155
|
+
if (distance <= scale) {
|
|
156
|
+
zeros = scale - distance;
|
|
157
|
+
} else {
|
|
158
|
+
std::advance(end, scale - distance);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
has_dot = true;
|
|
162
|
+
} else if (*c >= '0' && *c <= '9') {
|
|
163
|
+
if (mulOverflow(int_value, 10, &int_value) ||
|
|
164
|
+
addOverflow(int_value, *c - '0', &int_value)) {
|
|
165
|
+
throw AssertionError("value is too big for 128-bit integer");
|
|
166
|
+
}
|
|
167
|
+
} else {
|
|
168
|
+
throw ValidationError(std::string("unexpected symbol '") + (*c) + "' in decimal value");
|
|
169
|
+
}
|
|
170
|
+
++c;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
if (c != end) {
|
|
174
|
+
throw ValidationError("unexpected symbol '-' in decimal value");
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
while (zeros) {
|
|
178
|
+
if (mulOverflow(int_value, 10, &int_value)) {
|
|
179
|
+
throw AssertionError("value is too big for 128-bit integer");
|
|
180
|
+
}
|
|
181
|
+
--zeros;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
Append(sign ? int_value : -int_value);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
Int128 ColumnDecimal::At(size_t i) const {
|
|
188
|
+
switch (data_type_code_) {
|
|
189
|
+
case Type::Int32:
|
|
190
|
+
return static_cast<Int128>(static_cast<const ColumnInt32*>(data_.get())->At(i));
|
|
191
|
+
case Type::Int64:
|
|
192
|
+
return static_cast<Int128>(static_cast<const ColumnInt64*>(data_.get())->At(i));
|
|
193
|
+
case Type::Int128:
|
|
194
|
+
return static_cast<const ColumnInt128*>(data_.get())->At(i);
|
|
195
|
+
default:
|
|
196
|
+
throw ValidationError("Invalid data_ column type in ColumnDecimal");
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
void ColumnDecimal::Reserve(size_t new_cap) {
|
|
201
|
+
data_->Reserve(new_cap);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
void ColumnDecimal::Append(ColumnRef column) {
|
|
205
|
+
if (auto col = column->As<ColumnDecimal>()) {
|
|
206
|
+
data_->Append(col->data_);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
bool ColumnDecimal::LoadBody(InputStream * input, size_t rows) {
|
|
211
|
+
return data_->LoadBody(input, rows);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
void ColumnDecimal::SaveBody(OutputStream* output) {
|
|
215
|
+
data_->SaveBody(output);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
void ColumnDecimal::Clear() {
|
|
219
|
+
data_->Clear();
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
size_t ColumnDecimal::Size() const {
|
|
223
|
+
return data_->Size();
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
ColumnRef ColumnDecimal::Slice(size_t begin, size_t len) const {
|
|
227
|
+
// coundn't use std::make_shared since this c-tor is private
|
|
228
|
+
return ColumnRef{new ColumnDecimal(type_, data_->Slice(begin, len))};
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
ColumnRef ColumnDecimal::CloneEmpty() const {
|
|
232
|
+
// coundn't use std::make_shared since this c-tor is private
|
|
233
|
+
return ColumnRef{new ColumnDecimal(type_, data_->CloneEmpty())};
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
void ColumnDecimal::Swap(Column& other) {
|
|
237
|
+
auto & col = dynamic_cast<ColumnDecimal &>(other);
|
|
238
|
+
data_.swap(col.data_);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
ItemView ColumnDecimal::GetItem(size_t index) const {
|
|
242
|
+
return ItemView{GetType().GetCode(), data_->GetItem(index)};
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
size_t ColumnDecimal::GetScale() const
|
|
246
|
+
{
|
|
247
|
+
return type_->As<DecimalType>()->GetScale();
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
size_t ColumnDecimal::GetPrecision() const
|
|
251
|
+
{
|
|
252
|
+
return type_->As<DecimalType>()->GetPrecision();
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include "column.h"
|
|
4
|
+
#include "numeric.h"
|
|
5
|
+
|
|
6
|
+
namespace clickhouse {
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Represents a column of decimal type.
|
|
10
|
+
*/
|
|
11
|
+
class ColumnDecimal : public Column {
|
|
12
|
+
public:
|
|
13
|
+
using ValueType = Int128;
|
|
14
|
+
|
|
15
|
+
ColumnDecimal(size_t precision, size_t scale);
|
|
16
|
+
|
|
17
|
+
void Append(const Int128& value);
|
|
18
|
+
void Append(const std::string& value);
|
|
19
|
+
|
|
20
|
+
Int128 At(size_t i) const;
|
|
21
|
+
inline auto operator[](size_t i) const { return At(i); }
|
|
22
|
+
|
|
23
|
+
public:
|
|
24
|
+
/// Increase the capacity of the column for large block insertion.
|
|
25
|
+
void Reserve(size_t new_cap) override;
|
|
26
|
+
void Append(ColumnRef column) override;
|
|
27
|
+
bool LoadBody(InputStream* input, size_t rows) override;
|
|
28
|
+
void SaveBody(OutputStream* output) override;
|
|
29
|
+
void Clear() override;
|
|
30
|
+
size_t Size() const override;
|
|
31
|
+
ColumnRef Slice(size_t begin, size_t len) const override;
|
|
32
|
+
ColumnRef CloneEmpty() const override;
|
|
33
|
+
void Swap(Column& other) override;
|
|
34
|
+
ItemView GetItem(size_t index) const override;
|
|
35
|
+
|
|
36
|
+
size_t GetScale() const;
|
|
37
|
+
size_t GetPrecision() const;
|
|
38
|
+
|
|
39
|
+
private:
|
|
40
|
+
/// Depending on a precision it can be one of:
|
|
41
|
+
/// - ColumnInt32
|
|
42
|
+
/// - ColumnInt64
|
|
43
|
+
/// - ColumnInt128
|
|
44
|
+
ColumnRef data_;
|
|
45
|
+
Type::Code data_type_code_;
|
|
46
|
+
|
|
47
|
+
explicit ColumnDecimal(TypeRef type, ColumnRef data);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
#include "enum.h"
|
|
2
|
+
#include "utils.h"
|
|
3
|
+
|
|
4
|
+
#include "../base/input.h"
|
|
5
|
+
#include "../base/output.h"
|
|
6
|
+
#include "../base/wire_format.h"
|
|
7
|
+
|
|
8
|
+
namespace clickhouse {
|
|
9
|
+
|
|
10
|
+
template <typename T>
|
|
11
|
+
ColumnEnum<T>::ColumnEnum(TypeRef type)
|
|
12
|
+
: Column(type)
|
|
13
|
+
{
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
template <typename T>
|
|
17
|
+
ColumnEnum<T>::ColumnEnum(TypeRef type, const std::vector<T>& data)
|
|
18
|
+
: Column(type)
|
|
19
|
+
, data_(data)
|
|
20
|
+
{
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
template <typename T>
|
|
24
|
+
ColumnEnum<T>::ColumnEnum(TypeRef type, std::vector<T>&& data)
|
|
25
|
+
: Column(type)
|
|
26
|
+
, data_(std::move(data))
|
|
27
|
+
{
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
template <typename T>
|
|
31
|
+
void ColumnEnum<T>::Append(const T& value, bool checkValue) {
|
|
32
|
+
if (checkValue) {
|
|
33
|
+
// TODO: type_->HasEnumValue(value), "Enum type doesn't have value " + std::to_string(value);
|
|
34
|
+
}
|
|
35
|
+
data_.push_back(value);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
template <typename T>
|
|
39
|
+
void ColumnEnum<T>::Append(const std::string& name) {
|
|
40
|
+
data_.push_back(static_cast<T>(type_->As<EnumType>()->GetEnumValue(name)));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
template <typename T>
|
|
44
|
+
void ColumnEnum<T>::Clear() {
|
|
45
|
+
data_.clear();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
template <typename T>
|
|
49
|
+
const T& ColumnEnum<T>::At(size_t n) const {
|
|
50
|
+
return data_.at(n);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
template <typename T>
|
|
54
|
+
std::string_view ColumnEnum<T>::NameAt(size_t n) const {
|
|
55
|
+
return type_->As<EnumType>()->GetEnumName(data_.at(n));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
template <typename T>
|
|
59
|
+
void ColumnEnum<T>::SetAt(size_t n, const T& value, bool checkValue) {
|
|
60
|
+
if (checkValue) {
|
|
61
|
+
// TODO: type_->HasEnumValue(value), "Enum type doesn't have value " + std::to_string(value);
|
|
62
|
+
}
|
|
63
|
+
data_.at(n) = value;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
template <typename T>
|
|
67
|
+
void ColumnEnum<T>::SetNameAt(size_t n, const std::string& name) {
|
|
68
|
+
data_.at(n) = static_cast<T>(type_->As<EnumType>()->GetEnumValue(name));
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
template<typename T>
|
|
72
|
+
void ColumnEnum<T>::Reserve(size_t new_cap) {
|
|
73
|
+
data_.reserve(new_cap);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
template <typename T>
|
|
77
|
+
void ColumnEnum<T>::Append(ColumnRef column) {
|
|
78
|
+
if (auto col = column->As<ColumnEnum<T>>()) {
|
|
79
|
+
data_.insert(data_.end(), col->data_.begin(), col->data_.end());
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
template <typename T>
|
|
84
|
+
bool ColumnEnum<T>::LoadBody(InputStream* input, size_t rows) {
|
|
85
|
+
data_.resize(rows);
|
|
86
|
+
return WireFormat::ReadBytes(*input, data_.data(), data_.size() * sizeof(T));
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
template <typename T>
|
|
90
|
+
void ColumnEnum<T>::SaveBody(OutputStream* output) {
|
|
91
|
+
WireFormat::WriteBytes(*output, data_.data(), data_.size() * sizeof(T));
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
template <typename T>
|
|
95
|
+
size_t ColumnEnum<T>::Size() const {
|
|
96
|
+
return data_.size();
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
template <typename T>
|
|
100
|
+
ColumnRef ColumnEnum<T>::Slice(size_t begin, size_t len) const {
|
|
101
|
+
return std::make_shared<ColumnEnum<T>>(type_, SliceVector(data_, begin, len));
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
template <typename T>
|
|
105
|
+
ColumnRef ColumnEnum<T>::CloneEmpty() const {
|
|
106
|
+
return std::make_shared<ColumnEnum<T>>(type_);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
template <typename T>
|
|
110
|
+
void ColumnEnum<T>::Swap(Column& other) {
|
|
111
|
+
auto & col = dynamic_cast<ColumnEnum<T> &>(other);
|
|
112
|
+
data_.swap(col.data_);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
template <typename T>
|
|
116
|
+
ItemView ColumnEnum<T>::GetItem(size_t index) const {
|
|
117
|
+
return ItemView{type_->GetCode(), data_[index]};
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
template class ColumnEnum<int8_t>;
|
|
121
|
+
template class ColumnEnum<int16_t>;
|
|
122
|
+
|
|
123
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include "column.h"
|
|
4
|
+
|
|
5
|
+
namespace clickhouse {
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
template <typename T>
|
|
9
|
+
class ColumnEnum : public Column {
|
|
10
|
+
public:
|
|
11
|
+
using ValueType = T;
|
|
12
|
+
|
|
13
|
+
ColumnEnum(TypeRef type);
|
|
14
|
+
ColumnEnum(TypeRef type, const std::vector<T>& data);
|
|
15
|
+
ColumnEnum(TypeRef type, std::vector<T>&& data);
|
|
16
|
+
|
|
17
|
+
/// Appends one element to the end of column.
|
|
18
|
+
void Append(const T& value, bool checkValue = false);
|
|
19
|
+
void Append(const std::string& name);
|
|
20
|
+
|
|
21
|
+
/// Returns element at given row number.
|
|
22
|
+
const T& At(size_t n) const;
|
|
23
|
+
std::string_view NameAt(size_t n) const;
|
|
24
|
+
|
|
25
|
+
/// Returns element at given row number.
|
|
26
|
+
inline const T& operator[] (size_t n) const { return At(n); }
|
|
27
|
+
|
|
28
|
+
/// Set element at given row number.
|
|
29
|
+
void SetAt(size_t n, const T& value, bool checkValue = false);
|
|
30
|
+
void SetNameAt(size_t n, const std::string& name);
|
|
31
|
+
|
|
32
|
+
public:
|
|
33
|
+
/// Increase the capacity of the column for large block insertion.
|
|
34
|
+
void Reserve(size_t new_cap) override;
|
|
35
|
+
|
|
36
|
+
/// Appends content of given column to the end of current one.
|
|
37
|
+
void Append(ColumnRef column) override;
|
|
38
|
+
|
|
39
|
+
/// Loads column data from input stream.
|
|
40
|
+
bool LoadBody(InputStream* input, size_t rows) override;
|
|
41
|
+
|
|
42
|
+
/// Saves column data to output stream.
|
|
43
|
+
void SaveBody(OutputStream* output) override;
|
|
44
|
+
|
|
45
|
+
/// Clear column data.
|
|
46
|
+
void Clear() override;
|
|
47
|
+
|
|
48
|
+
/// Returns count of rows in the column.
|
|
49
|
+
size_t Size() const override;
|
|
50
|
+
|
|
51
|
+
/// Makes slice of the current column.
|
|
52
|
+
ColumnRef Slice(size_t begin, size_t len) const override;
|
|
53
|
+
ColumnRef CloneEmpty() const override;
|
|
54
|
+
void Swap(Column& other) override;
|
|
55
|
+
|
|
56
|
+
ItemView GetItem(size_t index) const override;
|
|
57
|
+
|
|
58
|
+
private:
|
|
59
|
+
std::vector<T> data_;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
using ColumnEnum8 = ColumnEnum<int8_t>;
|
|
63
|
+
using ColumnEnum16 = ColumnEnum<int16_t>;
|
|
64
|
+
|
|
65
|
+
}
|