difference transmission of source databases done

This commit is contained in:
2021-09-23 12:40:21 -04:00
parent 6fbe700107
commit 6490db43fc
8 changed files with 320 additions and 44 deletions

View File

@@ -105,11 +105,25 @@ IdVector sort_union_id_vectors(const IdVector &v1, const IdVector &v2) {
return result;
}
HashValue hash_string(const std::string &s) {
uint64_t hash1 = 0;
uint64_t hash2 = 0;
SpookyHash::Hash128(s.c_str(), s.size(), &hash1, &hash2);
return util::HashValue(hash1, hash2);
}
HashValue hash_id_vector(const IdVector &idv) {
uint64_t hash1 = 0;
uint64_t hash2 = 0;
SpookyHash::Hash128(&idv[0], idv.size() * sizeof(int64_t), &hash1, &hash2);
return std::make_pair(hash1, hash2);
return util::HashValue(hash1, hash2);
}
std::string hash_to_hex(const HashValue &hv) {
std::ostringstream oss;
oss << std::hex << std::setw(16) << std::setfill('0') << hv.first;
oss << std::hex << std::setw(16) << std::setfill('0') << hv.second;
return oss.str();
}
StringVec split(const std::string &s, char sep) {
@@ -318,6 +332,10 @@ LuaDefine(unittests_util, "c") {
LuaAssert(L, xyza != xyzc);
LuaAssert(L, xyza.debug_string() == "(3,4,5)");
// Test hash_to_string
LuaAssertStrEq(L, util::hash_to_hex(util::HashValue(0x1234,0x789a)),
"0000000000001234000000000000789a");
return 0;
}