aboutsummaryrefslogtreecommitdiffstats
path: root/util/digest/city_streaming.h
diff options
context:
space:
mode:
authora11ax <a11ax@yandex-team.com>2024-11-20 02:29:59 +0300
committera11ax <a11ax@yandex-team.com>2024-11-20 02:40:36 +0300
commit1f50694cfb5c440be984de5cae781b8d5948fea6 (patch)
treee333a908be139d081bf2478409567248fbfc58de /util/digest/city_streaming.h
parent7963b1e3e8537150d193c39a9d7a008fc82c6fc8 (diff)
downloadydb-1f50694cfb5c440be984de5cae781b8d5948fea6.tar.gz
/util: streaming CityHash
commit_hash:bd4032fbf4c4ece089ad071747194b38df6c5edd
Diffstat (limited to 'util/digest/city_streaming.h')
-rw-r--r--util/digest/city_streaming.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/util/digest/city_streaming.h b/util/digest/city_streaming.h
new file mode 100644
index 0000000000..f9c5209e0a
--- /dev/null
+++ b/util/digest/city_streaming.h
@@ -0,0 +1,21 @@
+#pragma once
+#include <util/digest/city.h>
+
+/**
+ * (partially) streaming version of CityHash64 for large data.
+ * You need to know length and first/last 64 bytes.
+ * Those bytes should be passed twice: in constructor and thru process().
+ * Length must be STRICTLY larger than 64 bytes.
+ * XXX: Dont use CityHash64 if you can use something else and need streaming
+ */
+class TStreamingCityHash64 {
+ ui64 x, y, z;
+ std::pair<ui64, ui64> v, w;
+ char UnalignBuf_[64];
+ size_t UnalignBufSz_, Rest64_;
+
+public:
+ TStreamingCityHash64(size_t len, const char* head64, const char* tail64);
+ void Process(const char* s, size_t avail);
+ ui64 operator()();
+};