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,25 @@
|
|
|
1
|
+
#include "query.h"
|
|
2
|
+
|
|
3
|
+
namespace clickhouse {
|
|
4
|
+
|
|
5
|
+
const std::string Query::default_query_id = {};
|
|
6
|
+
|
|
7
|
+
Query::Query()
|
|
8
|
+
{ }
|
|
9
|
+
|
|
10
|
+
Query::Query(const char* query, const char* query_id)
|
|
11
|
+
: query_(query)
|
|
12
|
+
, query_id_(query_id ? std::string(query_id): default_query_id)
|
|
13
|
+
{
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
Query::Query(const std::string& query, const std::string& query_id)
|
|
17
|
+
: query_(query)
|
|
18
|
+
, query_id_(query_id)
|
|
19
|
+
{
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
Query::~Query()
|
|
23
|
+
{ }
|
|
24
|
+
|
|
25
|
+
}
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include "block.h"
|
|
4
|
+
#include "server_exception.h"
|
|
5
|
+
|
|
6
|
+
#include "base/open_telemetry.h"
|
|
7
|
+
|
|
8
|
+
#include <cstdint>
|
|
9
|
+
#include <functional>
|
|
10
|
+
#include <memory>
|
|
11
|
+
#include <optional>
|
|
12
|
+
#include <string>
|
|
13
|
+
#include <unordered_map>
|
|
14
|
+
|
|
15
|
+
namespace clickhouse {
|
|
16
|
+
|
|
17
|
+
struct QuerySettingsField {
|
|
18
|
+
enum Flags : uint64_t
|
|
19
|
+
{
|
|
20
|
+
IMPORTANT = 0x01,
|
|
21
|
+
CUSTOM = 0x02,
|
|
22
|
+
OBSOLETE = 0x04,
|
|
23
|
+
};
|
|
24
|
+
std::string value;
|
|
25
|
+
uint64_t flags{0};
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
using QuerySettings = std::unordered_map<std::string, QuerySettingsField>;
|
|
29
|
+
using QueryParamValue = std::optional<std::string>;
|
|
30
|
+
using QueryParams = std::unordered_map<std::string, QueryParamValue>;
|
|
31
|
+
|
|
32
|
+
struct Profile {
|
|
33
|
+
uint64_t rows = 0;
|
|
34
|
+
uint64_t blocks = 0;
|
|
35
|
+
uint64_t bytes = 0;
|
|
36
|
+
uint64_t rows_before_limit = 0;
|
|
37
|
+
bool applied_limit = false;
|
|
38
|
+
bool calculated_rows_before_limit = false;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
struct Progress {
|
|
43
|
+
uint64_t rows = 0;
|
|
44
|
+
uint64_t bytes = 0;
|
|
45
|
+
uint64_t total_rows = 0;
|
|
46
|
+
uint64_t written_rows = 0;
|
|
47
|
+
uint64_t written_bytes = 0;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
class QueryEvents {
|
|
52
|
+
public:
|
|
53
|
+
virtual ~QueryEvents()
|
|
54
|
+
{ }
|
|
55
|
+
|
|
56
|
+
/// Some data was received.
|
|
57
|
+
virtual void OnData(const Block& block) = 0;
|
|
58
|
+
virtual bool OnDataCancelable(const Block& block) = 0;
|
|
59
|
+
|
|
60
|
+
virtual void OnServerException(const Exception& e) = 0;
|
|
61
|
+
|
|
62
|
+
virtual void OnProfile(const Profile& profile) = 0;
|
|
63
|
+
|
|
64
|
+
virtual void OnProgress(const Progress& progress) = 0;
|
|
65
|
+
|
|
66
|
+
/** Handle query execution logs provided by server.
|
|
67
|
+
* Amount of logs regulated by `send_logs_level` setting.
|
|
68
|
+
* By-default only `fatal` log events are sent to the client side.
|
|
69
|
+
*/
|
|
70
|
+
virtual void OnServerLog(const Block& block) = 0;
|
|
71
|
+
|
|
72
|
+
/// Handle query execution profile events.
|
|
73
|
+
virtual void OnProfileEvents(const Block& block) = 0;
|
|
74
|
+
|
|
75
|
+
virtual void OnFinish() = 0;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
using ExceptionCallback = std::function<void(const Exception& e)>;
|
|
80
|
+
using ProgressCallback = std::function<void(const Progress& progress)>;
|
|
81
|
+
using SelectCallback = std::function<void(const Block& block)>;
|
|
82
|
+
using SelectCancelableCallback = std::function<bool(const Block& block)>;
|
|
83
|
+
using SelectServerLogCallback = std::function<bool(const Block& block)>;
|
|
84
|
+
using ProfileEventsCallback = std::function<bool(const Block& block)>;
|
|
85
|
+
using ProfileCallback = std::function<void(const Profile& profile)>;
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
class Query : public QueryEvents {
|
|
89
|
+
public:
|
|
90
|
+
Query();
|
|
91
|
+
Query(const char* query, const char* query_id = nullptr);
|
|
92
|
+
Query(const std::string& query, const std::string& query_id = default_query_id);
|
|
93
|
+
~Query() override;
|
|
94
|
+
|
|
95
|
+
///
|
|
96
|
+
inline const std::string& GetText() const {
|
|
97
|
+
return query_;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
inline const std::string& GetQueryID() const {
|
|
101
|
+
return query_id_;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
inline const QuerySettings& GetQuerySettings() const {
|
|
105
|
+
return query_settings_;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/// Set per query settings
|
|
109
|
+
inline Query& SetQuerySettings(QuerySettings query_settings) {
|
|
110
|
+
query_settings_ = std::move(query_settings);
|
|
111
|
+
return *this;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/// Set per query setting
|
|
115
|
+
inline Query& SetSetting(const std::string& key, const QuerySettingsField& value) {
|
|
116
|
+
query_settings_[key] = value;
|
|
117
|
+
return *this;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
inline const QueryParams& GetParams() const { return query_params_; }
|
|
121
|
+
|
|
122
|
+
inline Query& SetParams(QueryParams query_params) {
|
|
123
|
+
query_params_ = std::move(query_params);
|
|
124
|
+
return *this;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
inline Query& SetParam(const std::string& name, const QueryParamValue& value) {
|
|
128
|
+
query_params_[name] = value;
|
|
129
|
+
return *this;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
inline const std::optional<open_telemetry::TracingContext>& GetTracingContext() const {
|
|
133
|
+
return tracing_context_;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/// Set tracing context for open telemetry signals
|
|
137
|
+
inline Query& SetTracingContext(open_telemetry::TracingContext tracing_context) {
|
|
138
|
+
tracing_context_ = std::move(tracing_context);
|
|
139
|
+
return *this;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/// Set handler for receiving result data.
|
|
143
|
+
inline Query& OnData(SelectCallback cb) {
|
|
144
|
+
select_cb_ = std::move(cb);
|
|
145
|
+
return *this;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
inline Query& OnDataCancelable(SelectCancelableCallback cb) {
|
|
149
|
+
select_cancelable_cb_ = std::move(cb);
|
|
150
|
+
return *this;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/// Set handler for receiving server's exception.
|
|
154
|
+
inline Query& OnException(ExceptionCallback cb) {
|
|
155
|
+
exception_cb_ = std::move(cb);
|
|
156
|
+
return *this;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/// Set handler for receiving a progress of query execution.
|
|
160
|
+
inline Query& OnProgress(ProgressCallback cb) {
|
|
161
|
+
progress_cb_ = std::move(cb);
|
|
162
|
+
return *this;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/// Set handler for receiving a server log of query exceution.
|
|
166
|
+
inline Query& OnServerLog(SelectServerLogCallback cb) {
|
|
167
|
+
select_server_log_cb_ = std::move(cb);
|
|
168
|
+
return *this;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/// Set handler for receiving profile events.
|
|
172
|
+
inline Query& OnProfileEvents(ProfileEventsCallback cb) {
|
|
173
|
+
profile_events_callback_cb_ = std::move(cb);
|
|
174
|
+
return *this;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
inline Query& OnProfile(ProfileCallback cb) {
|
|
178
|
+
profile_callback_cb_ = std::move(cb);
|
|
179
|
+
return *this;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
static const std::string default_query_id;
|
|
183
|
+
|
|
184
|
+
private:
|
|
185
|
+
void OnData(const Block& block) override {
|
|
186
|
+
if (select_cb_) {
|
|
187
|
+
select_cb_(block);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
bool OnDataCancelable(const Block& block) override {
|
|
192
|
+
if (select_cancelable_cb_) {
|
|
193
|
+
return select_cancelable_cb_(block);
|
|
194
|
+
} else {
|
|
195
|
+
return true;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
void OnServerException(const Exception& e) override {
|
|
200
|
+
if (exception_cb_) {
|
|
201
|
+
exception_cb_(e);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
void OnProfile(const Profile& profile) override {
|
|
206
|
+
if (profile_callback_cb_)
|
|
207
|
+
profile_callback_cb_(profile);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
void OnProgress(const Progress& progress) override {
|
|
211
|
+
if (progress_cb_) {
|
|
212
|
+
progress_cb_(progress);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
void OnServerLog(const Block& block) override {
|
|
217
|
+
if (select_server_log_cb_) {
|
|
218
|
+
select_server_log_cb_(block);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
void OnProfileEvents(const Block& block) override {
|
|
223
|
+
if (profile_events_callback_cb_) {
|
|
224
|
+
profile_events_callback_cb_(block);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
void OnFinish() override {
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
private:
|
|
232
|
+
const std::string query_;
|
|
233
|
+
const std::string query_id_;
|
|
234
|
+
std::optional<open_telemetry::TracingContext> tracing_context_;
|
|
235
|
+
QuerySettings query_settings_;
|
|
236
|
+
QueryParams query_params_;
|
|
237
|
+
ExceptionCallback exception_cb_;
|
|
238
|
+
ProgressCallback progress_cb_;
|
|
239
|
+
SelectCallback select_cb_;
|
|
240
|
+
SelectCancelableCallback select_cancelable_cb_;
|
|
241
|
+
SelectServerLogCallback select_server_log_cb_;
|
|
242
|
+
ProfileEventsCallback profile_events_callback_cb_;
|
|
243
|
+
ProfileCallback profile_callback_cb_;
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <string>
|
|
4
|
+
#include <memory>
|
|
5
|
+
|
|
6
|
+
namespace clickhouse {
|
|
7
|
+
struct Exception {
|
|
8
|
+
int code = 0;
|
|
9
|
+
std::string name;
|
|
10
|
+
std::string display_text;
|
|
11
|
+
std::string stack_trace;
|
|
12
|
+
/// Pointer to nested exception.
|
|
13
|
+
std::unique_ptr<Exception> nested;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
}
|
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
#include "type_parser.h"
|
|
2
|
+
|
|
3
|
+
#include "clickhouse/exceptions.h"
|
|
4
|
+
#include "clickhouse/base/platform.h" // for _win_
|
|
5
|
+
|
|
6
|
+
#include <algorithm>
|
|
7
|
+
#include <cmath>
|
|
8
|
+
#include <map>
|
|
9
|
+
#include <mutex>
|
|
10
|
+
#include <unordered_map>
|
|
11
|
+
|
|
12
|
+
#if defined _win_
|
|
13
|
+
#include <string.h>
|
|
14
|
+
#else
|
|
15
|
+
#include <strings.h>
|
|
16
|
+
#endif
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
namespace clickhouse {
|
|
20
|
+
|
|
21
|
+
bool TypeAst::operator==(const TypeAst & other) const {
|
|
22
|
+
return meta == other.meta
|
|
23
|
+
&& code == other.code
|
|
24
|
+
&& name == other.name
|
|
25
|
+
&& value == other.value
|
|
26
|
+
&& std::equal(elements.begin(), elements.end(), other.elements.begin(), other.elements.end());
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
static const std::unordered_map<std::string, Type::Code> kTypeCode = {
|
|
30
|
+
{ "Void", Type::Void },
|
|
31
|
+
{ "Int8", Type::Int8 },
|
|
32
|
+
{ "Int16", Type::Int16 },
|
|
33
|
+
{ "Int32", Type::Int32 },
|
|
34
|
+
{ "Int64", Type::Int64 },
|
|
35
|
+
{ "Bool", Type::UInt8 },
|
|
36
|
+
{ "UInt8", Type::UInt8 },
|
|
37
|
+
{ "UInt16", Type::UInt16 },
|
|
38
|
+
{ "UInt32", Type::UInt32 },
|
|
39
|
+
{ "UInt64", Type::UInt64 },
|
|
40
|
+
{ "Float32", Type::Float32 },
|
|
41
|
+
{ "Float64", Type::Float64 },
|
|
42
|
+
{ "String", Type::String },
|
|
43
|
+
{ "FixedString", Type::FixedString },
|
|
44
|
+
{ "DateTime", Type::DateTime },
|
|
45
|
+
{ "DateTime64", Type::DateTime64 },
|
|
46
|
+
{ "Date", Type::Date },
|
|
47
|
+
{ "Date32", Type::Date32 },
|
|
48
|
+
{ "Array", Type::Array },
|
|
49
|
+
{ "Nullable", Type::Nullable },
|
|
50
|
+
{ "Tuple", Type::Tuple },
|
|
51
|
+
{ "Enum8", Type::Enum8 },
|
|
52
|
+
{ "Enum16", Type::Enum16 },
|
|
53
|
+
{ "UUID", Type::UUID },
|
|
54
|
+
{ "IPv4", Type::IPv4 },
|
|
55
|
+
{ "IPv6", Type::IPv6 },
|
|
56
|
+
{ "Int128", Type::Int128 },
|
|
57
|
+
{ "UInt128", Type::UInt128 },
|
|
58
|
+
{ "Decimal", Type::Decimal },
|
|
59
|
+
{ "Decimal32", Type::Decimal32 },
|
|
60
|
+
{ "Decimal64", Type::Decimal64 },
|
|
61
|
+
{ "Decimal128", Type::Decimal128 },
|
|
62
|
+
{ "LowCardinality", Type::LowCardinality },
|
|
63
|
+
{ "Map", Type::Map },
|
|
64
|
+
{ "Point", Type::Point },
|
|
65
|
+
{ "Ring", Type::Ring },
|
|
66
|
+
{ "Polygon", Type::Polygon },
|
|
67
|
+
{ "MultiPolygon", Type::MultiPolygon },
|
|
68
|
+
{ "Time", Type::Time },
|
|
69
|
+
{ "Time64", Type::Time64 },
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
template <typename L, typename R>
|
|
73
|
+
inline int CompateStringsCaseInsensitive(const L& left, const R& right) {
|
|
74
|
+
int64_t size_diff = left.size() - right.size();
|
|
75
|
+
if (size_diff != 0)
|
|
76
|
+
return size_diff > 0 ? 1 : -1;
|
|
77
|
+
|
|
78
|
+
#if defined _win_
|
|
79
|
+
return _strnicmp(left.data(), right.data(), left.size());
|
|
80
|
+
#else
|
|
81
|
+
return strncasecmp(left.data(), right.data(), left.size());
|
|
82
|
+
#endif
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
static Type::Code GetTypeCode(const std::string& name) {
|
|
86
|
+
auto it = kTypeCode.find(name);
|
|
87
|
+
if (it != kTypeCode.end()) {
|
|
88
|
+
return it->second;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return Type::Void;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
static TypeAst::Meta GetTypeMeta(const StringView& name) {
|
|
95
|
+
if (name == "Array") {
|
|
96
|
+
return TypeAst::Array;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (name == "Null") {
|
|
100
|
+
return TypeAst::Null;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (name == "Nullable") {
|
|
104
|
+
return TypeAst::Nullable;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (name == "Tuple") {
|
|
108
|
+
return TypeAst::Tuple;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (name == "Enum8" || name == "Enum16") {
|
|
112
|
+
return TypeAst::Enum;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (name == "LowCardinality") {
|
|
116
|
+
return TypeAst::LowCardinality;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (name == "SimpleAggregateFunction") {
|
|
120
|
+
return TypeAst::SimpleAggregateFunction;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (name == "Map") {
|
|
124
|
+
return TypeAst::Map;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return TypeAst::Terminal;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
bool ValidateAST(const TypeAst& ast) {
|
|
131
|
+
// Void terminal that is not actually "void" produced when unknown type is encountered.
|
|
132
|
+
if (ast.meta == TypeAst::Terminal
|
|
133
|
+
&& ast.code == Type::Void
|
|
134
|
+
&& CompateStringsCaseInsensitive(ast.name, std::string_view("void")) != 0)
|
|
135
|
+
//throw UnimplementedError("Unsupported type: " + ast.name);
|
|
136
|
+
return false;
|
|
137
|
+
|
|
138
|
+
return true;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
TypeParser::TypeParser(const StringView& name)
|
|
143
|
+
: cur_(name.data())
|
|
144
|
+
, end_(name.data() + name.size())
|
|
145
|
+
, type_(nullptr)
|
|
146
|
+
{
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
TypeParser::~TypeParser() = default;
|
|
150
|
+
|
|
151
|
+
bool TypeParser::Parse(TypeAst* type) {
|
|
152
|
+
type_ = type;
|
|
153
|
+
open_elements_.push(type_);
|
|
154
|
+
|
|
155
|
+
size_t processed_tokens = 0;
|
|
156
|
+
do {
|
|
157
|
+
const Token & token = NextToken();
|
|
158
|
+
switch (token.type) {
|
|
159
|
+
case Token::QuotedString:
|
|
160
|
+
{
|
|
161
|
+
type_->meta = TypeAst::Terminal;
|
|
162
|
+
if (token.value.length() < 1)
|
|
163
|
+
type_->value_string = {};
|
|
164
|
+
else
|
|
165
|
+
type_->value_string = token.value.substr(1, token.value.length() - 2).to_string();
|
|
166
|
+
type_->code = Type::String;
|
|
167
|
+
break;
|
|
168
|
+
}
|
|
169
|
+
case Token::Name:
|
|
170
|
+
type_->meta = GetTypeMeta(token.value);
|
|
171
|
+
type_->name = token.value.to_string();
|
|
172
|
+
type_->code = GetTypeCode(type_->name);
|
|
173
|
+
break;
|
|
174
|
+
case Token::Number:
|
|
175
|
+
type_->meta = TypeAst::Number;
|
|
176
|
+
type_->value = std::stol(token.value.to_string());
|
|
177
|
+
break;
|
|
178
|
+
case Token::String:
|
|
179
|
+
type_->meta = TypeAst::String;
|
|
180
|
+
type_->value_string = std::string(token.value);
|
|
181
|
+
break;
|
|
182
|
+
case Token::LPar:
|
|
183
|
+
type_->elements.emplace_back(TypeAst());
|
|
184
|
+
open_elements_.push(type_);
|
|
185
|
+
type_ = &type_->elements.back();
|
|
186
|
+
break;
|
|
187
|
+
case Token::RPar:
|
|
188
|
+
type_ = open_elements_.top();
|
|
189
|
+
open_elements_.pop();
|
|
190
|
+
break;
|
|
191
|
+
case Token::Assign:
|
|
192
|
+
case Token::Comma:
|
|
193
|
+
type_ = open_elements_.top();
|
|
194
|
+
open_elements_.pop();
|
|
195
|
+
type_->elements.emplace_back(TypeAst());
|
|
196
|
+
open_elements_.push(type_);
|
|
197
|
+
type_ = &type_->elements.back();
|
|
198
|
+
break;
|
|
199
|
+
case Token::EOS:
|
|
200
|
+
{
|
|
201
|
+
// Ubalanced braces, brackets, etc is an error.
|
|
202
|
+
if (open_elements_.size() != 1)
|
|
203
|
+
return false;
|
|
204
|
+
|
|
205
|
+
// Empty input string, no tokens produced
|
|
206
|
+
if (processed_tokens == 0)
|
|
207
|
+
return false;
|
|
208
|
+
|
|
209
|
+
return ValidateAST(*type);
|
|
210
|
+
}
|
|
211
|
+
case Token::Invalid:
|
|
212
|
+
return false;
|
|
213
|
+
}
|
|
214
|
+
++processed_tokens;
|
|
215
|
+
} while (true);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
TypeParser::Token TypeParser::NextToken() {
|
|
219
|
+
for (; cur_ < end_; ++cur_) {
|
|
220
|
+
switch (*cur_) {
|
|
221
|
+
case ' ':
|
|
222
|
+
case '\n':
|
|
223
|
+
case '\t':
|
|
224
|
+
case '\0':
|
|
225
|
+
continue;
|
|
226
|
+
case '=':
|
|
227
|
+
return Token{Token::Assign, StringView(cur_++, 1)};
|
|
228
|
+
case '(':
|
|
229
|
+
return Token{Token::LPar, StringView(cur_++, 1)};
|
|
230
|
+
case ')':
|
|
231
|
+
return Token{Token::RPar, StringView(cur_++, 1)};
|
|
232
|
+
case ',':
|
|
233
|
+
return Token{Token::Comma, StringView(cur_++, 1)};
|
|
234
|
+
case '\'':
|
|
235
|
+
{
|
|
236
|
+
const auto end_quote_length = 1;
|
|
237
|
+
const StringView end_quote{cur_, end_quote_length};
|
|
238
|
+
// Fast forward to the closing quote.
|
|
239
|
+
const auto start = cur_++;
|
|
240
|
+
for (; cur_ < end_ - end_quote_length; ++cur_) {
|
|
241
|
+
// TODO (nemkov): handle escaping ?
|
|
242
|
+
if (end_quote == StringView{cur_, end_quote_length}) {
|
|
243
|
+
cur_ += end_quote_length;
|
|
244
|
+
|
|
245
|
+
return Token{Token::QuotedString, StringView{start, cur_}};
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
return Token{Token::QuotedString, StringView(cur_++, 1)};
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
default: {
|
|
252
|
+
const char* st = cur_;
|
|
253
|
+
|
|
254
|
+
if (*cur_ == '\'') {
|
|
255
|
+
for (st = ++cur_; cur_ < end_; ++cur_) {
|
|
256
|
+
if (*cur_ == '\'') {
|
|
257
|
+
return Token{Token::String, StringView(st, cur_++ - st)};
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
return Token{Token::Invalid, StringView()};
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
if (isalpha(*cur_) || *cur_ == '_') {
|
|
265
|
+
for (; cur_ < end_; ++cur_) {
|
|
266
|
+
if (!isalpha(*cur_) && !isdigit(*cur_) && *cur_ != '_') {
|
|
267
|
+
break;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
return Token{Token::Name, StringView(st, cur_)};
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
if (isdigit(*cur_) || *cur_ == '-') {
|
|
275
|
+
for (++cur_; cur_ < end_; ++cur_) {
|
|
276
|
+
if (!isdigit(*cur_)) {
|
|
277
|
+
break;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
return Token{Token::Number, StringView(st, cur_)};
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
return Token{Token::Invalid, StringView()};
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
return Token{Token::EOS, StringView()};
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
const TypeAst* ParseTypeName(const std::string& type_name) {
|
|
294
|
+
// Cache for type_name.
|
|
295
|
+
// Usually we won't have too many type names in the cache, so do not try to
|
|
296
|
+
// limit cache size.
|
|
297
|
+
static std::map<std::string, TypeAst> ast_cache;
|
|
298
|
+
static std::mutex lock;
|
|
299
|
+
|
|
300
|
+
std::lock_guard<std::mutex> guard(lock);
|
|
301
|
+
auto it = ast_cache.find(type_name);
|
|
302
|
+
if (it != ast_cache.end()) {
|
|
303
|
+
return &it->second;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
auto& ast = ast_cache[type_name];
|
|
307
|
+
if (TypeParser(type_name).Parse(&ast)) {
|
|
308
|
+
return *
|
|
309
|
+
}
|
|
310
|
+
ast_cache.erase(type_name);
|
|
311
|
+
return nullptr;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include "../base/string_view.h"
|
|
4
|
+
#include "types.h"
|
|
5
|
+
|
|
6
|
+
#include <list>
|
|
7
|
+
#include <stack>
|
|
8
|
+
#include <string>
|
|
9
|
+
|
|
10
|
+
namespace clickhouse {
|
|
11
|
+
|
|
12
|
+
struct TypeAst {
|
|
13
|
+
enum Meta {
|
|
14
|
+
Array,
|
|
15
|
+
Assign,
|
|
16
|
+
Null,
|
|
17
|
+
Nullable,
|
|
18
|
+
Number,
|
|
19
|
+
String,
|
|
20
|
+
Terminal,
|
|
21
|
+
Tuple,
|
|
22
|
+
Enum,
|
|
23
|
+
LowCardinality,
|
|
24
|
+
SimpleAggregateFunction,
|
|
25
|
+
Map
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/// Type's category.
|
|
29
|
+
Meta meta;
|
|
30
|
+
Type::Code code;
|
|
31
|
+
/// Type's name.
|
|
32
|
+
/// Need to cache TypeAst, so can't use StringView for name.
|
|
33
|
+
std::string name;
|
|
34
|
+
/// Value associated with the node,
|
|
35
|
+
/// used for fixed-width types and enum values.
|
|
36
|
+
int64_t value = 0;
|
|
37
|
+
std::string value_string;
|
|
38
|
+
/// Subelements of the type.
|
|
39
|
+
/// Used to store enum's names and values as well.
|
|
40
|
+
std::vector<TypeAst> elements;
|
|
41
|
+
|
|
42
|
+
bool operator==(const TypeAst & other) const;
|
|
43
|
+
inline bool operator!=(const TypeAst & other) const {
|
|
44
|
+
return !(*this == other);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
class TypeParser {
|
|
50
|
+
|
|
51
|
+
struct Token {
|
|
52
|
+
enum Type {
|
|
53
|
+
Invalid = 0,
|
|
54
|
+
Assign,
|
|
55
|
+
Name,
|
|
56
|
+
Number,
|
|
57
|
+
String,
|
|
58
|
+
LPar,
|
|
59
|
+
RPar,
|
|
60
|
+
Comma,
|
|
61
|
+
QuotedString, // string with quotation marks included
|
|
62
|
+
EOS,
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
Type type;
|
|
66
|
+
StringView value;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
public:
|
|
70
|
+
explicit TypeParser(const StringView& name);
|
|
71
|
+
~TypeParser();
|
|
72
|
+
|
|
73
|
+
bool Parse(TypeAst* type);
|
|
74
|
+
|
|
75
|
+
private:
|
|
76
|
+
Token NextToken();
|
|
77
|
+
|
|
78
|
+
private:
|
|
79
|
+
const char* cur_;
|
|
80
|
+
const char* end_;
|
|
81
|
+
|
|
82
|
+
TypeAst* type_;
|
|
83
|
+
std::stack<TypeAst*> open_elements_;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
const TypeAst* ParseTypeName(const std::string& type_name);
|
|
88
|
+
|
|
89
|
+
}
|