1#include "duckdb/common/checksum.hpp"
2#include "duckdb/common/types/hash.hpp"
3
4using namespace std;
5
6namespace duckdb {
7
8uint64_t Checksum(uint8_t *buffer, size_t size) {
9 uint64_t result = 5381;
10 uint64_t *ptr = (uint64_t *)buffer;
11 size_t i;
12 // for efficiency, we first hash uint64_t values
13 for (i = 0; i < size / 8; i++) {
14 result ^= Hash(ptr[i]);
15 }
16 if (size - i * 8 > 0) {
17 // the remaining 0-7 bytes we hash using a string hash
18 result ^= Hash(buffer + i * 8, size - i * 8);
19 }
20 return result;
21}
22
23} // namespace duckdb
24