pollymc/libraries/murmur2/src/MurmurHash2.h
flow f95bcf45ad
feat(libs): add incremental version of murmurhash2 calculation
This does two passes for a given file, which is kinda slow, but I don't
know how else to get the size excluding the filtered ones :<

Signed-off-by: flow <flowlnlnln@gmail.com>
2022-07-24 17:46:53 -03:00

31 lines
1007 B
C++

//-----------------------------------------------------------------------------
// The original MurmurHash2 was written by Austin Appleby, and is placed in the
// public domain. The author hereby disclaims copyright to this source code.
//
// This was modified as to possibilitate it's usage incrementally.
// Those modifications are also placed in the public domain, and the author of
// such modifications hereby disclaims copyright to this source code.
#pragma once
#include <cstdint>
#include <fstream>
#include <functional>
//-----------------------------------------------------------------------------
uint32_t MurmurHash2(
std::ifstream&& file_stream,
std::size_t buffer_size = 4096,
std::function<bool(char)> filter_out = [](char) { return true; });
struct IncrementalHashInfo {
uint32_t h;
uint32_t len;
};
void FourBytes_MurmurHash2(const unsigned char* data, IncrementalHashInfo& prev);
//-----------------------------------------------------------------------------