forked from git/git
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bloom.h
58 lines (47 loc) · 1.31 KB
/
bloom.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#ifndef BLOOM_H
#define BLOOM_H
struct commit;
struct repository;
struct commit_graph;
struct bloom_filter_settings {
uint32_t hash_version;
uint32_t num_hashes;
uint32_t bits_per_entry;
};
#define DEFAULT_BLOOM_FILTER_SETTINGS { 1, 7, 10 }
#define BITS_PER_WORD 64
#define BLOOMDATA_CHUNK_HEADER_SIZE 3*sizeof(uint32_t)
/*
* A bloom_filter struct represents a data segment to
* use when testing hash values. The 'len' member
* dictates how many uint64_t entries are stored in
* 'data'.
*/
struct bloom_filter {
uint64_t *data;
int len;
};
/*
* A bloom_key represents the k hash values for a
* given hash input. These can be precomputed and
* stored in a bloom_key for re-use when testing
* against a bloom_filter.
*/
struct bloom_key {
uint32_t *hashes;
};
void load_bloom_filters(void);
void fill_bloom_key(const char *data,
int len,
struct bloom_key *key,
struct bloom_filter_settings *settings);
void add_key_to_filter(struct bloom_key *key,
struct bloom_filter *filter,
struct bloom_filter_settings *settings);
struct bloom_filter *get_bloom_filter(struct repository *r,
struct commit *c,
int compute_if_not_present);
int bloom_filter_contains(struct bloom_filter *filter,
struct bloom_key *key,
struct bloom_filter_settings *settings);
#endif