12345678910111213141516171819202122232425262728293031(* CityHash128 implementation for ClickHouse protocol
Uses C++ bindings to the Google CityHash implementation *)typeuint128={low:int64;high:int64}(* External C++ function *)externalcityhash128_raw:bytes->int64*int64="cityhash128_stub"externalcityhash128_sub_raw:bytes->int->int->int64*int64="cityhash128_sub_stub"externalcityhash128_2sub_raw:bytes->int->int->bytes->int->int->int64*int64="cityhash128_2sub_stub_bytecode""cityhash128_2sub_stub"(* CityHash128 function that returns our uint128 type *)letcityhash128(data:bytes):uint128=letlow,high=cityhash128_rawdatain{low;high}letcityhash128_sub(data:bytes)(off:int)(len:int):uint128=letlow,high=cityhash128_sub_rawdataofflenin{low;high}letcityhash128_2sub(d1:bytes)(off1:int)(len1:int)(d2:bytes)(off2:int)(len2:int):uint128=letlow,high=cityhash128_2sub_rawd1off1len1d2off2len2in{low;high}letto_bytes(hash:uint128):bytes=letbuf=Bytes.create16inBinary.bytes_set_int64_lebuf0hash.low;Binary.bytes_set_int64_lebuf8hash.high;buf