diff --git a/utils/src/bloom.c b/utils/src/bloom.c new file mode 100644 index 00000000..45939424 --- /dev/null +++ b/utils/src/bloom.c @@ -0,0 +1,20 @@ +#include + +#include "sparse.h" +#include "util.h" +#include "format.h" +#include "hash.h" +#include "bloom.h" + +void calc_bloom_nrs(struct scoutfs_key *key, unsigned int *nrs) +{ + u64 hash; + int i; + + hash = scoutfs_hash64(key, sizeof(struct scoutfs_key)); + + for (i = 0; i < SCOUTFS_FOREST_BLOOM_NRS; i++) { + nrs[i] = (u32)hash % SCOUTFS_FOREST_BLOOM_BITS; + hash >>= SCOUTFS_FOREST_BLOOM_FUNC_BITS; + } +} diff --git a/utils/src/bloom.h b/utils/src/bloom.h new file mode 100644 index 00000000..9a2d3b3b --- /dev/null +++ b/utils/src/bloom.h @@ -0,0 +1,6 @@ +#ifndef _BLOOM_H_ +#define _BLOOM_H_ + +void calc_bloom_nrs(struct scoutfs_key *key, unsigned int *nrs); + +#endif