mirror of
https://github.com/versity/scoutfs.git
synced 2025-12-23 13:35:18 +00:00
Add bloom filter index calc for userspace utils
Signed-off-by: Zach Brown <zab@versity.com>
This commit is contained in:
20
utils/src/bloom.c
Normal file
20
utils/src/bloom.c
Normal file
@@ -0,0 +1,20 @@
|
||||
#include <errno.h>
|
||||
|
||||
#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;
|
||||
}
|
||||
}
|
||||
6
utils/src/bloom.h
Normal file
6
utils/src/bloom.h
Normal file
@@ -0,0 +1,6 @@
|
||||
#ifndef _BLOOM_H_
|
||||
#define _BLOOM_H_
|
||||
|
||||
void calc_bloom_nrs(struct scoutfs_key *key, unsigned int *nrs);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user