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.
Files changed (260) hide show
  1. checksums.yaml +7 -0
  2. data/ext/clickhouse_native/client.cpp +847 -0
  3. data/ext/clickhouse_native/extconf.rb +101 -0
  4. data/ext/clickhouse_native/vendor/clickhouse-cpp/.clang-format +11 -0
  5. data/ext/clickhouse_native/vendor/clickhouse-cpp/.git +1 -0
  6. data/ext/clickhouse_native/vendor/clickhouse-cpp/.gitattributes +63 -0
  7. data/ext/clickhouse_native/vendor/clickhouse-cpp/.github/CODEOWNERS +1 -0
  8. data/ext/clickhouse_native/vendor/clickhouse-cpp/.github/workflows/linux.yml +139 -0
  9. data/ext/clickhouse_native/vendor/clickhouse-cpp/.github/workflows/macos.yml +87 -0
  10. data/ext/clickhouse_native/vendor/clickhouse-cpp/.github/workflows/windows_mingw.yml +102 -0
  11. data/ext/clickhouse_native/vendor/clickhouse-cpp/.github/workflows/windows_msvc.yml +74 -0
  12. data/ext/clickhouse_native/vendor/clickhouse-cpp/.gitignore +280 -0
  13. data/ext/clickhouse_native/vendor/clickhouse-cpp/.travis.yml +62 -0
  14. data/ext/clickhouse_native/vendor/clickhouse-cpp/CMakeLists.txt +157 -0
  15. data/ext/clickhouse_native/vendor/clickhouse-cpp/LICENSE +206 -0
  16. data/ext/clickhouse_native/vendor/clickhouse-cpp/README.md +260 -0
  17. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/CMakeLists.txt +246 -0
  18. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/buffer.h +10 -0
  19. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/compressed.cpp +258 -0
  20. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/compressed.h +48 -0
  21. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/endpoints_iterator.cpp +20 -0
  22. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/endpoints_iterator.h +34 -0
  23. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/input.cpp +96 -0
  24. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/input.h +103 -0
  25. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/open_telemetry.h +23 -0
  26. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/output.cpp +119 -0
  27. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/output.h +142 -0
  28. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/platform.cpp +1 -0
  29. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/platform.h +33 -0
  30. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/projected_iterator.h +55 -0
  31. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/singleton.h +11 -0
  32. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/socket.cpp +489 -0
  33. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/socket.h +177 -0
  34. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/sslsocket.cpp +307 -0
  35. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/sslsocket.h +111 -0
  36. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/string_utils.h +28 -0
  37. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/string_view.h +142 -0
  38. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/uuid.h +10 -0
  39. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/wire_format.cpp +177 -0
  40. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/wire_format.h +79 -0
  41. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/block.cpp +134 -0
  42. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/block.h +114 -0
  43. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/client.cpp +1269 -0
  44. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/client.h +320 -0
  45. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/array.cpp +175 -0
  46. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/array.h +321 -0
  47. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/column.cpp +24 -0
  48. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/column.h +107 -0
  49. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/date.cpp +365 -0
  50. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/date.h +245 -0
  51. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/decimal.cpp +255 -0
  52. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/decimal.h +50 -0
  53. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/enum.cpp +123 -0
  54. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/enum.h +65 -0
  55. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/factory.cpp +285 -0
  56. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/factory.h +14 -0
  57. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/geo.cpp +108 -0
  58. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/geo.h +79 -0
  59. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/ip4.cpp +117 -0
  60. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/ip4.h +71 -0
  61. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/ip6.cpp +108 -0
  62. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/ip6.h +66 -0
  63. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/itemview.cpp +101 -0
  64. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/itemview.h +86 -0
  65. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/lowcardinality.cpp +527 -0
  66. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/lowcardinality.h +221 -0
  67. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/lowcardinalityadaptor.h +63 -0
  68. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/map.cpp +87 -0
  69. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/map.h +257 -0
  70. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/nothing.h +87 -0
  71. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/nullable.cpp +109 -0
  72. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/nullable.h +153 -0
  73. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/numeric.cpp +126 -0
  74. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/numeric.h +88 -0
  75. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/string.cpp +333 -0
  76. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/string.h +145 -0
  77. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/time.cpp +155 -0
  78. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/time.h +118 -0
  79. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/tuple.cpp +106 -0
  80. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/tuple.h +178 -0
  81. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/utils.h +41 -0
  82. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/uuid.cpp +80 -0
  83. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/uuid.h +58 -0
  84. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/error_codes.h +595 -0
  85. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/exceptions.h +66 -0
  86. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/protocol.h +54 -0
  87. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/query.cpp +25 -0
  88. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/query.h +246 -0
  89. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/server_exception.h +16 -0
  90. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/types/type_parser.cpp +314 -0
  91. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/types/type_parser.h +89 -0
  92. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/types/types.cpp +484 -0
  93. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/types/types.h +397 -0
  94. data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/version.h +14 -0
  95. data/ext/clickhouse_native/vendor/clickhouse-cpp/cmake/Findcityhash.cmake +26 -0
  96. data/ext/clickhouse_native/vendor/clickhouse-cpp/cmake/Findlz4.cmake +39 -0
  97. data/ext/clickhouse_native/vendor/clickhouse-cpp/cmake/Findzstd.cmake +39 -0
  98. data/ext/clickhouse_native/vendor/clickhouse-cpp/cmake/cpp17.cmake +8 -0
  99. data/ext/clickhouse_native/vendor/clickhouse-cpp/cmake/openssl.cmake +8 -0
  100. data/ext/clickhouse_native/vendor/clickhouse-cpp/cmake/subdirs.cmake +5 -0
  101. data/ext/clickhouse_native/vendor/clickhouse-cpp/cmake/version.cmake +87 -0
  102. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/absl/absl/CMakeLists.txt +9 -0
  103. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/absl/absl/base/attributes.h +682 -0
  104. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/absl/absl/base/config.h +714 -0
  105. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/absl/absl/base/internal/bits.h +219 -0
  106. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/absl/absl/base/macros.h +147 -0
  107. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/absl/absl/base/optimization.h +241 -0
  108. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/absl/absl/base/options.h +238 -0
  109. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/absl/absl/base/policy_checks.h +111 -0
  110. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/absl/absl/base/port.h +26 -0
  111. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/absl/absl/numeric/int128.cc +390 -0
  112. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/absl/absl/numeric/int128.h +1092 -0
  113. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/absl/absl/numeric/int128_have_intrinsic.inc +302 -0
  114. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/absl/absl/numeric/int128_no_intrinsic.inc +308 -0
  115. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/cityhash/cityhash/BUCK +13 -0
  116. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/cityhash/cityhash/CMakeLists.txt +7 -0
  117. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/cityhash/cityhash/COPYING +19 -0
  118. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/cityhash/cityhash/city.cc +469 -0
  119. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/cityhash/cityhash/city.h +90 -0
  120. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/cityhash/cityhash/citycrc.h +43 -0
  121. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/cityhash/cityhash/config.h +118 -0
  122. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/BUCK +14 -0
  123. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/CMakeLists.txt +4 -0
  124. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/LICENSE +28 -0
  125. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/README.md +1 -0
  126. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/gtest-death-test.h +346 -0
  127. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/gtest-matchers.h +930 -0
  128. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/gtest-message.h +219 -0
  129. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/gtest-param-test.h +507 -0
  130. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/gtest-printers.h +1029 -0
  131. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/gtest-spi.h +238 -0
  132. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/gtest-test-part.h +184 -0
  133. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/gtest-typed-test.h +329 -0
  134. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/gtest.h +2495 -0
  135. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/gtest_pred_impl.h +359 -0
  136. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/gtest_prod.h +61 -0
  137. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/internal/custom/README.md +56 -0
  138. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/internal/custom/gtest-port.h +37 -0
  139. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/internal/custom/gtest-printers.h +42 -0
  140. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/internal/custom/gtest.h +37 -0
  141. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/internal/gtest-death-test-internal.h +304 -0
  142. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/internal/gtest-filepath.h +211 -0
  143. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/internal/gtest-internal.h +1560 -0
  144. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/internal/gtest-param-util.h +947 -0
  145. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/internal/gtest-port-arch.h +114 -0
  146. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/internal/gtest-port.h +2389 -0
  147. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/internal/gtest-string.h +175 -0
  148. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/internal/gtest-type-util.h +183 -0
  149. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/src/gtest-all.cc +48 -0
  150. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/src/gtest-death-test.cc +1644 -0
  151. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/src/gtest-filepath.cc +369 -0
  152. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/src/gtest-internal-inl.h +1221 -0
  153. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/src/gtest-matchers.cc +97 -0
  154. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/src/gtest-port.cc +1433 -0
  155. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/src/gtest-printers.cc +533 -0
  156. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/src/gtest-test-part.cc +108 -0
  157. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/src/gtest-typed-test.cc +107 -0
  158. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/src/gtest.cc +6746 -0
  159. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/src/gtest_main.cc +54 -0
  160. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/lz4/lz4/BUCK +13 -0
  161. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/lz4/lz4/CMakeLists.txt +8 -0
  162. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/lz4/lz4/LICENSE +24 -0
  163. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/lz4/lz4/lz4.c +2402 -0
  164. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/lz4/lz4/lz4.h +764 -0
  165. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/lz4/lz4/lz4hc.c +1554 -0
  166. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/lz4/lz4/lz4hc.h +438 -0
  167. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/BUCK +232 -0
  168. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/CMakeLists.txt +115 -0
  169. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/LICENSE +30 -0
  170. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/allocations.h +55 -0
  171. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/bits.h +200 -0
  172. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/bitstream.h +437 -0
  173. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/compiler.h +358 -0
  174. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/cpu.h +213 -0
  175. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/debug.c +24 -0
  176. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/debug.h +107 -0
  177. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/entropy_common.c +340 -0
  178. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/error_private.c +63 -0
  179. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/error_private.h +159 -0
  180. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/fse.h +639 -0
  181. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/fse_decompress.c +311 -0
  182. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/huf.h +273 -0
  183. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/mem.h +435 -0
  184. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/pool.c +371 -0
  185. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/pool.h +90 -0
  186. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/portability_macros.h +156 -0
  187. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/threading.c +176 -0
  188. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/threading.h +150 -0
  189. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/xxhash.c +24 -0
  190. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/xxhash.h +5686 -0
  191. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/zstd_common.c +48 -0
  192. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/zstd_deps.h +111 -0
  193. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/zstd_internal.h +392 -0
  194. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/zstd_trace.h +163 -0
  195. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/clevels.h +134 -0
  196. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/fse_compress.c +624 -0
  197. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/hist.c +181 -0
  198. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/hist.h +75 -0
  199. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/huf_compress.c +1435 -0
  200. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_compress.c +7032 -0
  201. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_compress_internal.h +1532 -0
  202. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_compress_literals.c +235 -0
  203. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_compress_literals.h +39 -0
  204. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_compress_sequences.c +442 -0
  205. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_compress_sequences.h +54 -0
  206. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_compress_superblock.c +577 -0
  207. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_compress_superblock.h +32 -0
  208. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_cwksp.h +742 -0
  209. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_double_fast.c +758 -0
  210. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_double_fast.h +39 -0
  211. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_fast.c +960 -0
  212. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_fast.h +38 -0
  213. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_lazy.c +2157 -0
  214. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_lazy.h +127 -0
  215. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_ldm.c +724 -0
  216. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_ldm.h +117 -0
  217. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_ldm_geartab.h +106 -0
  218. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_opt.c +1472 -0
  219. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_opt.h +56 -0
  220. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstdmt_compress.c +1867 -0
  221. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstdmt_compress.h +113 -0
  222. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/decompress/huf_decompress.c +1882 -0
  223. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/decompress/huf_decompress_amd64.S +576 -0
  224. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/decompress/zstd_ddict.c +244 -0
  225. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/decompress/zstd_ddict.h +44 -0
  226. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/decompress/zstd_decompress.c +2355 -0
  227. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/decompress/zstd_decompress_block.c +2192 -0
  228. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/decompress/zstd_decompress_block.h +73 -0
  229. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/decompress/zstd_decompress_internal.h +238 -0
  230. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/dictBuilder/cover.c +1257 -0
  231. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/dictBuilder/cover.h +158 -0
  232. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/dictBuilder/divsufsort.c +1913 -0
  233. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/dictBuilder/divsufsort.h +67 -0
  234. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/dictBuilder/fastcover.c +766 -0
  235. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/dictBuilder/zdict.c +1127 -0
  236. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/legacy/zstd_legacy.h +422 -0
  237. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/legacy/zstd_v01.c +2125 -0
  238. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/legacy/zstd_v01.h +94 -0
  239. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/legacy/zstd_v02.c +3477 -0
  240. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/legacy/zstd_v02.h +93 -0
  241. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/legacy/zstd_v03.c +3117 -0
  242. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/legacy/zstd_v03.h +93 -0
  243. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/legacy/zstd_v04.c +3605 -0
  244. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/legacy/zstd_v04.h +142 -0
  245. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/legacy/zstd_v05.c +4004 -0
  246. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/legacy/zstd_v05.h +162 -0
  247. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/legacy/zstd_v06.c +4113 -0
  248. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/legacy/zstd_v06.h +172 -0
  249. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/legacy/zstd_v07.c +4498 -0
  250. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/legacy/zstd_v07.h +187 -0
  251. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/zdict.h +474 -0
  252. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/zstd.h +3020 -0
  253. data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/zstd_errors.h +114 -0
  254. data/lib/clickhouse_native/clickhouse_native.bundle +0 -0
  255. data/lib/clickhouse_native/client.rb +50 -0
  256. data/lib/clickhouse_native/errors.rb +23 -0
  257. data/lib/clickhouse_native/pool.rb +49 -0
  258. data/lib/clickhouse_native/version.rb +3 -0
  259. data/lib/clickhouse_native.rb +8 -0
  260. metadata +369 -0
@@ -0,0 +1,469 @@
1
+ // Copyright (c) 2011 Google, Inc.
2
+ //
3
+ // Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ // of this software and associated documentation files (the "Software"), to deal
5
+ // in the Software without restriction, including without limitation the rights
6
+ // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ // copies of the Software, and to permit persons to whom the Software is
8
+ // furnished to do so, subject to the following conditions:
9
+ //
10
+ // The above copyright notice and this permission notice shall be included in
11
+ // all copies or substantial portions of the Software.
12
+ //
13
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ // THE SOFTWARE.
20
+ //
21
+ // CityHash, by Geoff Pike and Jyrki Alakuijala
22
+ //
23
+ // This file provides CityHash64() and related functions.
24
+ //
25
+ // It's probably possible to create even faster hash functions by
26
+ // writing a program that systematically explores some of the space of
27
+ // possible hash functions, by using SIMD instructions, or by
28
+ // compromising on hash quality.
29
+
30
+ #include "config.h"
31
+ #include "city.h"
32
+
33
+ #include <algorithm>
34
+ #include <string.h> // for memcpy and memset
35
+
36
+ using namespace std;
37
+
38
+ static uint64 UNALIGNED_LOAD64(const char *p) {
39
+ uint64 result;
40
+ memcpy(&result, p, sizeof(result));
41
+ return result;
42
+ }
43
+
44
+ static uint32 UNALIGNED_LOAD32(const char *p) {
45
+ uint32 result;
46
+ memcpy(&result, p, sizeof(result));
47
+ return result;
48
+ }
49
+
50
+ #if !defined(WORDS_BIGENDIAN)
51
+
52
+ #define uint32_in_expected_order(x) (x)
53
+ #define uint64_in_expected_order(x) (x)
54
+
55
+ #else
56
+
57
+ #ifdef _MSC_VER
58
+ #include <stdlib.h>
59
+ #define bswap_32(x) _byteswap_ulong(x)
60
+ #define bswap_64(x) _byteswap_uint64(x)
61
+
62
+ #elif defined(__APPLE__)
63
+ // Mac OS X / Darwin features
64
+ #include <libkern/OSByteOrder.h>
65
+ #define bswap_32(x) OSSwapInt32(x)
66
+ #define bswap_64(x) OSSwapInt64(x)
67
+
68
+ #else
69
+ #include <byteswap.h>
70
+ #endif
71
+
72
+ #define uint32_in_expected_order(x) (bswap_32(x))
73
+ #define uint64_in_expected_order(x) (bswap_64(x))
74
+
75
+ #endif // WORDS_BIGENDIAN
76
+
77
+ #if !defined(LIKELY)
78
+ #if HAVE_BUILTIN_EXPECT
79
+ #define LIKELY(x) (__builtin_expect(!!(x), 1))
80
+ #else
81
+ #define LIKELY(x) (x)
82
+ #endif
83
+ #endif
84
+
85
+ static uint64 Fetch64(const char *p) {
86
+ return uint64_in_expected_order(UNALIGNED_LOAD64(p));
87
+ }
88
+
89
+ static uint32 Fetch32(const char *p) {
90
+ return uint32_in_expected_order(UNALIGNED_LOAD32(p));
91
+ }
92
+
93
+ // Some primes between 2^63 and 2^64 for various uses.
94
+ static const uint64 k0 = 0xc3a5c85c97cb3127ULL;
95
+ static const uint64 k1 = 0xb492b66fbe98f273ULL;
96
+ static const uint64 k2 = 0x9ae16a3b2f90404fULL;
97
+ static const uint64 k3 = 0xc949d7c7509e6557ULL;
98
+
99
+ // Bitwise right rotate. Normally this will compile to a single
100
+ // instruction, especially if the shift is a manifest constant.
101
+ static uint64 Rotate(uint64 val, int shift) {
102
+ // Avoid shifting by 64: doing so yields an undefined result.
103
+ return shift == 0 ? val : ((val >> shift) | (val << (64 - shift)));
104
+ }
105
+
106
+ // Equivalent to Rotate(), but requires the second arg to be non-zero.
107
+ // On x86-64, and probably others, it's possible for this to compile
108
+ // to a single instruction if both args are already in registers.
109
+ static uint64 RotateByAtLeast1(uint64 val, int shift) {
110
+ return (val >> shift) | (val << (64 - shift));
111
+ }
112
+
113
+ static uint64 ShiftMix(uint64 val) {
114
+ return val ^ (val >> 47);
115
+ }
116
+
117
+ static uint64 HashLen16(uint64 u, uint64 v) {
118
+ return Hash128to64(uint128(u, v));
119
+ }
120
+
121
+ static uint64 HashLen0to16(const char *s, size_t len) {
122
+ if (len > 8) {
123
+ uint64 a = Fetch64(s);
124
+ uint64 b = Fetch64(s + len - 8);
125
+ return HashLen16(a, RotateByAtLeast1(b + len, len)) ^ b;
126
+ }
127
+ if (len >= 4) {
128
+ uint64 a = Fetch32(s);
129
+ return HashLen16(len + (a << 3), Fetch32(s + len - 4));
130
+ }
131
+ if (len > 0) {
132
+ uint8 a = s[0];
133
+ uint8 b = s[len >> 1];
134
+ uint8 c = s[len - 1];
135
+ uint32 y = static_cast<uint32>(a) + (static_cast<uint32>(b) << 8);
136
+ uint32 z = len + (static_cast<uint32>(c) << 2);
137
+ return ShiftMix(y * k2 ^ z * k3) * k2;
138
+ }
139
+ return k2;
140
+ }
141
+
142
+ // This probably works well for 16-byte strings as well, but it may be overkill
143
+ // in that case.
144
+ static uint64 HashLen17to32(const char *s, size_t len) {
145
+ uint64 a = Fetch64(s) * k1;
146
+ uint64 b = Fetch64(s + 8);
147
+ uint64 c = Fetch64(s + len - 8) * k2;
148
+ uint64 d = Fetch64(s + len - 16) * k0;
149
+ return HashLen16(Rotate(a - b, 43) + Rotate(c, 30) + d,
150
+ a + Rotate(b ^ k3, 20) - c + len);
151
+ }
152
+
153
+ // Return a 16-byte hash for 48 bytes. Quick and dirty.
154
+ // Callers do best to use "random-looking" values for a and b.
155
+ static pair<uint64, uint64> WeakHashLen32WithSeeds(
156
+ uint64 w, uint64 x, uint64 y, uint64 z, uint64 a, uint64 b) {
157
+ a += w;
158
+ b = Rotate(b + a + z, 21);
159
+ uint64 c = a;
160
+ a += x;
161
+ a += y;
162
+ b += Rotate(a, 44);
163
+ return make_pair(a + z, b + c);
164
+ }
165
+
166
+ // Return a 16-byte hash for s[0] ... s[31], a, and b. Quick and dirty.
167
+ static pair<uint64, uint64> WeakHashLen32WithSeeds(
168
+ const char* s, uint64 a, uint64 b) {
169
+ return WeakHashLen32WithSeeds(Fetch64(s),
170
+ Fetch64(s + 8),
171
+ Fetch64(s + 16),
172
+ Fetch64(s + 24),
173
+ a,
174
+ b);
175
+ }
176
+
177
+ // Return an 8-byte hash for 33 to 64 bytes.
178
+ static uint64 HashLen33to64(const char *s, size_t len) {
179
+ uint64 z = Fetch64(s + 24);
180
+ uint64 a = Fetch64(s) + (len + Fetch64(s + len - 16)) * k0;
181
+ uint64 b = Rotate(a + z, 52);
182
+ uint64 c = Rotate(a, 37);
183
+ a += Fetch64(s + 8);
184
+ c += Rotate(a, 7);
185
+ a += Fetch64(s + 16);
186
+ uint64 vf = a + z;
187
+ uint64 vs = b + Rotate(a, 31) + c;
188
+ a = Fetch64(s + 16) + Fetch64(s + len - 32);
189
+ z = Fetch64(s + len - 8);
190
+ b = Rotate(a + z, 52);
191
+ c = Rotate(a, 37);
192
+ a += Fetch64(s + len - 24);
193
+ c += Rotate(a, 7);
194
+ a += Fetch64(s + len - 16);
195
+ uint64 wf = a + z;
196
+ uint64 ws = b + Rotate(a, 31) + c;
197
+ uint64 r = ShiftMix((vf + ws) * k2 + (wf + vs) * k0);
198
+ return ShiftMix(r * k0 + vs) * k2;
199
+ }
200
+
201
+ uint64 CityHash64(const char *s, size_t len) {
202
+ if (len <= 32) {
203
+ if (len <= 16) {
204
+ return HashLen0to16(s, len);
205
+ } else {
206
+ return HashLen17to32(s, len);
207
+ }
208
+ } else if (len <= 64) {
209
+ return HashLen33to64(s, len);
210
+ }
211
+
212
+ // For strings over 64 bytes we hash the end first, and then as we
213
+ // loop we keep 56 bytes of state: v, w, x, y, and z.
214
+ uint64 x = Fetch64(s);
215
+ uint64 y = Fetch64(s + len - 16) ^ k1;
216
+ uint64 z = Fetch64(s + len - 56) ^ k0;
217
+ pair<uint64, uint64> v = WeakHashLen32WithSeeds(s + len - 64, len, y);
218
+ pair<uint64, uint64> w = WeakHashLen32WithSeeds(s + len - 32, len * k1, k0);
219
+ z += ShiftMix(v.second) * k1;
220
+ x = Rotate(z + x, 39) * k1;
221
+ y = Rotate(y, 33) * k1;
222
+
223
+ // Decrease len to the nearest multiple of 64, and operate on 64-byte chunks.
224
+ len = (len - 1) & ~static_cast<size_t>(63);
225
+ do {
226
+ x = Rotate(x + y + v.first + Fetch64(s + 16), 37) * k1;
227
+ y = Rotate(y + v.second + Fetch64(s + 48), 42) * k1;
228
+ x ^= w.second;
229
+ y ^= v.first;
230
+ z = Rotate(z ^ w.first, 33);
231
+ v = WeakHashLen32WithSeeds(s, v.second * k1, x + w.first);
232
+ w = WeakHashLen32WithSeeds(s + 32, z + w.second, y);
233
+ std::swap(z, x);
234
+ s += 64;
235
+ len -= 64;
236
+ } while (len != 0);
237
+ return HashLen16(HashLen16(v.first, w.first) + ShiftMix(y) * k1 + z,
238
+ HashLen16(v.second, w.second) + x);
239
+ }
240
+
241
+ uint64 CityHash64WithSeed(const char *s, size_t len, uint64 seed) {
242
+ return CityHash64WithSeeds(s, len, k2, seed);
243
+ }
244
+
245
+ uint64 CityHash64WithSeeds(const char *s, size_t len,
246
+ uint64 seed0, uint64 seed1) {
247
+ return HashLen16(CityHash64(s, len) - seed0, seed1);
248
+ }
249
+
250
+ // A subroutine for CityHash128(). Returns a decent 128-bit hash for strings
251
+ // of any length representable in ssize_t. Based on City and Murmur.
252
+ static uint128 CityMurmur(const char *s, size_t len, uint128 seed) {
253
+ uint64 a = Uint128Low64(seed);
254
+ uint64 b = Uint128High64(seed);
255
+ uint64 c = 0;
256
+ uint64 d = 0;
257
+ if (len <= 16) { // len <= 16
258
+ a = ShiftMix(a * k1) * k1;
259
+ c = b * k1 + HashLen0to16(s, len);
260
+ d = ShiftMix(a + (len >= 8 ? Fetch64(s) : c));
261
+ } else { // len > 16
262
+ c = HashLen16(Fetch64(s + len - 8) + k1, a);
263
+ d = HashLen16(b + len, c + Fetch64(s + len - 16));
264
+ a += d;
265
+ do {
266
+ a ^= ShiftMix(Fetch64(s) * k1) * k1;
267
+ a *= k1;
268
+ b ^= a;
269
+ c ^= ShiftMix(Fetch64(s + 8) * k1) * k1;
270
+ c *= k1;
271
+ d ^= c;
272
+ s += 16;
273
+ len -= 16;
274
+ } while (len > 16);
275
+ }
276
+ a = HashLen16(a, c);
277
+ b = HashLen16(d, b);
278
+ return uint128(a ^ b, HashLen16(b, a));
279
+ }
280
+
281
+ uint128 CityHash128WithSeed(const char *s, size_t len, uint128 seed) {
282
+ if (len < 128) {
283
+ return CityMurmur(s, len, seed);
284
+ }
285
+
286
+ // We expect len >= 128 to be the common case. Keep 56 bytes of state:
287
+ // v, w, x, y, and z.
288
+ pair<uint64, uint64> v, w;
289
+ uint64 x = Uint128Low64(seed);
290
+ uint64 y = Uint128High64(seed);
291
+ uint64 z = len * k1;
292
+ v.first = Rotate(y ^ k1, 49) * k1 + Fetch64(s);
293
+ v.second = Rotate(v.first, 42) * k1 + Fetch64(s + 8);
294
+ w.first = Rotate(y + z, 35) * k1 + x;
295
+ w.second = Rotate(x + Fetch64(s + 88), 53) * k1;
296
+
297
+ // This is the same inner loop as CityHash64(), manually unrolled.
298
+ do {
299
+ x = Rotate(x + y + v.first + Fetch64(s + 16), 37) * k1;
300
+ y = Rotate(y + v.second + Fetch64(s + 48), 42) * k1;
301
+ x ^= w.second;
302
+ y ^= v.first;
303
+ z = Rotate(z ^ w.first, 33);
304
+ v = WeakHashLen32WithSeeds(s, v.second * k1, x + w.first);
305
+ w = WeakHashLen32WithSeeds(s + 32, z + w.second, y);
306
+ std::swap(z, x);
307
+ s += 64;
308
+ x = Rotate(x + y + v.first + Fetch64(s + 16), 37) * k1;
309
+ y = Rotate(y + v.second + Fetch64(s + 48), 42) * k1;
310
+ x ^= w.second;
311
+ y ^= v.first;
312
+ z = Rotate(z ^ w.first, 33);
313
+ v = WeakHashLen32WithSeeds(s, v.second * k1, x + w.first);
314
+ w = WeakHashLen32WithSeeds(s + 32, z + w.second, y);
315
+ std::swap(z, x);
316
+ s += 64;
317
+ len -= 128;
318
+ } while (LIKELY(len >= 128));
319
+ y += Rotate(w.first, 37) * k0 + z;
320
+ x += Rotate(v.first + z, 49) * k0;
321
+ // If 0 < len < 128, hash up to 4 chunks of 32 bytes each from the end of s.
322
+ for (size_t tail_done = 0; tail_done < len; ) {
323
+ tail_done += 32;
324
+ y = Rotate(y - x, 42) * k0 + v.second;
325
+ w.first += Fetch64(s + len - tail_done + 16);
326
+ x = Rotate(x, 49) * k0 + w.first;
327
+ w.first += v.first;
328
+ v = WeakHashLen32WithSeeds(s + len - tail_done, v.first, v.second);
329
+ }
330
+ // At this point our 48 bytes of state should contain more than
331
+ // enough information for a strong 128-bit hash. We use two
332
+ // different 48-byte-to-8-byte hashes to get a 16-byte final result.
333
+ x = HashLen16(x, v.first);
334
+ y = HashLen16(y, w.first);
335
+ return uint128(HashLen16(x + v.second, w.second) + y,
336
+ HashLen16(x + w.second, y + v.second));
337
+ }
338
+
339
+ uint128 CityHash128(const char *s, size_t len) {
340
+ if (len >= 16) {
341
+ return CityHash128WithSeed(s + 16,
342
+ len - 16,
343
+ uint128(Fetch64(s) ^ k3,
344
+ Fetch64(s + 8)));
345
+ } else if (len >= 8) {
346
+ return CityHash128WithSeed(NULL,
347
+ 0,
348
+ uint128(Fetch64(s) ^ (len * k0),
349
+ Fetch64(s + len - 8) ^ k1));
350
+ } else {
351
+ return CityHash128WithSeed(s, len, uint128(k0, k1));
352
+ }
353
+ }
354
+
355
+ #ifdef __SSE4_2__
356
+ #include "citycrc.h"
357
+ #include <nmmintrin.h>
358
+
359
+ // Requires len >= 240.
360
+ static void CityHashCrc256Long(const char *s, size_t len,
361
+ uint32 seed, uint64 *result) {
362
+ uint64 a = Fetch64(s + 56) + k0;
363
+ uint64 b = Fetch64(s + 96) + k0;
364
+ uint64 c = result[1] = HashLen16(b, len);
365
+ uint64 d = result[2] = Fetch64(s + 120) * k0 + len;
366
+ uint64 e = Fetch64(s + 184) + seed;
367
+ uint64 f = seed;
368
+ uint64 g = 0;
369
+ uint64 h = 0;
370
+ uint64 i = 0;
371
+ uint64 j = 0;
372
+ uint64 t = c + d;
373
+
374
+ // 240 bytes of input per iter.
375
+ size_t iters = len / 240;
376
+ len -= iters * 240;
377
+ do {
378
+ #define CHUNK(multiplier, z) \
379
+ { \
380
+ uint64 old_a = a; \
381
+ a = Rotate(b, 41 ^ z) * multiplier + Fetch64(s); \
382
+ b = Rotate(c, 27 ^ z) * multiplier + Fetch64(s + 8); \
383
+ c = Rotate(d, 41 ^ z) * multiplier + Fetch64(s + 16); \
384
+ d = Rotate(e, 33 ^ z) * multiplier + Fetch64(s + 24); \
385
+ e = Rotate(t, 25 ^ z) * multiplier + Fetch64(s + 32); \
386
+ t = old_a; \
387
+ } \
388
+ f = _mm_crc32_u64(f, a); \
389
+ g = _mm_crc32_u64(g, b); \
390
+ h = _mm_crc32_u64(h, c); \
391
+ i = _mm_crc32_u64(i, d); \
392
+ j = _mm_crc32_u64(j, e); \
393
+ s += 40
394
+
395
+ CHUNK(1, 1); CHUNK(k0, 0);
396
+ CHUNK(1, 1); CHUNK(k0, 0);
397
+ CHUNK(1, 1); CHUNK(k0, 0);
398
+ } while (--iters > 0);
399
+ j += i << 32;
400
+ a = HashLen16(a, j);
401
+ h += g << 32;
402
+ b = b * k0 + h;
403
+ c = HashLen16(c, f) + i;
404
+ d = HashLen16(d, e);
405
+ pair<uint64, uint64> v(j + e, HashLen16(h, t));
406
+ h = v.second + f;
407
+ // If 0 < len < 240, hash chunks of 32 bytes each from the end of s.
408
+ for (size_t tail_done = 0; tail_done < len; ) {
409
+ tail_done += 32;
410
+ c = Rotate(c - a, 42) * k0 + v.second;
411
+ d += Fetch64(s + len - tail_done + 16);
412
+ a = Rotate(a, 49) * k0 + d;
413
+ d += v.first;
414
+ v = WeakHashLen32WithSeeds(s + len - tail_done, v.first, v.second);
415
+ }
416
+
417
+ // Final mix.
418
+ e = HashLen16(a, d) + v.first;
419
+ f = HashLen16(b, c) + a;
420
+ g = HashLen16(v.first, v.second) + c;
421
+ result[0] = e + f + g + h;
422
+ a = ShiftMix((a + g) * k0) * k0 + b;
423
+ result[1] += a + result[0];
424
+ a = ShiftMix(a * k0) * k0 + c;
425
+ result[2] += a + result[1];
426
+ a = ShiftMix((a + e) * k0) * k0;
427
+ result[3] = a + result[2];
428
+ }
429
+
430
+ // Requires len < 240.
431
+ static void CityHashCrc256Short(const char *s, size_t len, uint64 *result) {
432
+ char buf[240];
433
+ memcpy(buf, s, len);
434
+ memset(buf + len, 0, 240 - len);
435
+ CityHashCrc256Long(buf, 240, ~static_cast<uint32>(len), result);
436
+ }
437
+
438
+ void CityHashCrc256(const char *s, size_t len, uint64 *result) {
439
+ if (LIKELY(len >= 240)) {
440
+ CityHashCrc256Long(s, len, 0, result);
441
+ } else {
442
+ CityHashCrc256Short(s, len, result);
443
+ }
444
+ }
445
+
446
+ uint128 CityHashCrc128WithSeed(const char *s, size_t len, uint128 seed) {
447
+ if (len <= 900) {
448
+ return CityHash128WithSeed(s, len, seed);
449
+ } else {
450
+ uint64 result[4];
451
+ CityHashCrc256(s, len, result);
452
+ uint64 u = Uint128High64(seed) + result[0];
453
+ uint64 v = Uint128Low64(seed) + result[1];
454
+ return uint128(HashLen16(u, v + result[2]),
455
+ HashLen16(Rotate(v, 32), u * k0 + result[3]));
456
+ }
457
+ }
458
+
459
+ uint128 CityHashCrc128(const char *s, size_t len) {
460
+ if (len <= 900) {
461
+ return CityHash128(s, len);
462
+ } else {
463
+ uint64 result[4];
464
+ CityHashCrc256(s, len, result);
465
+ return uint128(result[2], result[3]);
466
+ }
467
+ }
468
+
469
+ #endif
@@ -0,0 +1,90 @@
1
+ // Copyright (c) 2011 Google, Inc.
2
+ //
3
+ // Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ // of this software and associated documentation files (the "Software"), to deal
5
+ // in the Software without restriction, including without limitation the rights
6
+ // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ // copies of the Software, and to permit persons to whom the Software is
8
+ // furnished to do so, subject to the following conditions:
9
+ //
10
+ // The above copyright notice and this permission notice shall be included in
11
+ // all copies or substantial portions of the Software.
12
+ //
13
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ // THE SOFTWARE.
20
+ //
21
+ // CityHash, by Geoff Pike and Jyrki Alakuijala
22
+ //
23
+ // This file provides a few functions for hashing strings. On x86-64
24
+ // hardware in 2011, CityHash64() is faster than other high-quality
25
+ // hash functions, such as Murmur. This is largely due to higher
26
+ // instruction-level parallelism. CityHash64() and CityHash128() also perform
27
+ // well on hash-quality tests.
28
+ //
29
+ // CityHash128() is optimized for relatively long strings and returns
30
+ // a 128-bit hash. For strings more than about 2000 bytes it can be
31
+ // faster than CityHash64().
32
+ //
33
+ // Functions in the CityHash family are not suitable for cryptography.
34
+ //
35
+ // WARNING: This code has not been tested on big-endian platforms!
36
+ // It is known to work well on little-endian platforms that have a small penalty
37
+ // for unaligned reads, such as current Intel and AMD moderate-to-high-end CPUs.
38
+ //
39
+ // By the way, for some hash functions, given strings a and b, the hash
40
+ // of a+b is easily derived from the hashes of a and b. This property
41
+ // doesn't hold for any hash functions in this file.
42
+
43
+ #ifndef CITY_HASH_H_
44
+ #define CITY_HASH_H_
45
+
46
+ #include <stdlib.h> // for size_t.
47
+ #include <stdint.h>
48
+ #include <utility>
49
+
50
+ typedef uint8_t uint8;
51
+ typedef uint32_t uint32;
52
+ typedef uint64_t uint64;
53
+ typedef std::pair<uint64, uint64> uint128;
54
+
55
+ inline uint64 Uint128Low64(const uint128& x) { return x.first; }
56
+ inline uint64 Uint128High64(const uint128& x) { return x.second; }
57
+
58
+ // Hash function for a byte array.
59
+ uint64 CityHash64(const char *buf, size_t len);
60
+
61
+ // Hash function for a byte array. For convenience, a 64-bit seed is also
62
+ // hashed into the result.
63
+ uint64 CityHash64WithSeed(const char *buf, size_t len, uint64 seed);
64
+
65
+ // Hash function for a byte array. For convenience, two seeds are also
66
+ // hashed into the result.
67
+ uint64 CityHash64WithSeeds(const char *buf, size_t len,
68
+ uint64 seed0, uint64 seed1);
69
+
70
+ // Hash function for a byte array.
71
+ uint128 CityHash128(const char *s, size_t len);
72
+
73
+ // Hash function for a byte array. For convenience, a 128-bit seed is also
74
+ // hashed into the result.
75
+ uint128 CityHash128WithSeed(const char *s, size_t len, uint128 seed);
76
+
77
+ // Hash 128 input bits down to 64 bits of output.
78
+ // This is intended to be a reasonably good hash function.
79
+ inline uint64 Hash128to64(const uint128& x) {
80
+ // Murmur-inspired hashing.
81
+ const uint64 kMul = 0x9ddfea08eb382d69ULL;
82
+ uint64 a = (Uint128Low64(x) ^ Uint128High64(x)) * kMul;
83
+ a ^= (a >> 47);
84
+ uint64 b = (Uint128High64(x) ^ a) * kMul;
85
+ b ^= (b >> 47);
86
+ b *= kMul;
87
+ return b;
88
+ }
89
+
90
+ #endif // CITY_HASH_H_
@@ -0,0 +1,43 @@
1
+ // Copyright (c) 2011 Google, Inc.
2
+ //
3
+ // Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ // of this software and associated documentation files (the "Software"), to deal
5
+ // in the Software without restriction, including without limitation the rights
6
+ // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ // copies of the Software, and to permit persons to whom the Software is
8
+ // furnished to do so, subject to the following conditions:
9
+ //
10
+ // The above copyright notice and this permission notice shall be included in
11
+ // all copies or substantial portions of the Software.
12
+ //
13
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ // THE SOFTWARE.
20
+ //
21
+ // CityHash, by Geoff Pike and Jyrki Alakuijala
22
+ //
23
+ // This file declares the subset of the CityHash functions that require
24
+ // _mm_crc32_u64(). See the CityHash README for details.
25
+ //
26
+ // Functions in the CityHash family are not suitable for cryptography.
27
+
28
+ #ifndef CITY_HASH_CRC_H_
29
+ #define CITY_HASH_CRC_H_
30
+
31
+ #include "city.h"
32
+
33
+ // Hash function for a byte array.
34
+ uint128 CityHashCrc128(const char *s, size_t len);
35
+
36
+ // Hash function for a byte array. For convenience, a 128-bit seed is also
37
+ // hashed into the result.
38
+ uint128 CityHashCrc128WithSeed(const char *s, size_t len, uint128 seed);
39
+
40
+ // Hash function for a byte array. Sets result[0] ... result[3].
41
+ void CityHashCrc256(const char *s, size_t len, uint64 *result);
42
+
43
+ #endif // CITY_HASH_CRC_H_