File tree Expand file tree Collapse file tree 3 files changed +17
-12
lines changed Expand file tree Collapse file tree 3 files changed +17
-12
lines changed Original file line number Diff line number Diff line change @@ -107,7 +107,7 @@ int load_bloom_filter_from_graph(struct commit_graph *g,
107
107
* Not considered to be cryptographically secure.
108
108
* Implemented as described in https://en.wikipedia.org/wiki/MurmurHash#Algorithm
109
109
*/
110
- uint32_t murmur3_seeded_v2 (uint32_t seed , const char * data , size_t len )
110
+ static uint32_t murmur3_seeded_v2 (uint32_t seed , const char * data , size_t len )
111
111
{
112
112
const uint32_t c1 = 0xcc9e2d51 ;
113
113
const uint32_t c2 = 0x1b873593 ;
@@ -540,3 +540,14 @@ int bloom_filter_contains(const struct bloom_filter *filter,
540
540
541
541
return 1 ;
542
542
}
543
+
544
+ uint32_t test_bloom_murmur3_seeded (uint32_t seed , const char * data , size_t len ,
545
+ int version )
546
+ {
547
+ assert (version == 1 || version == 2 );
548
+
549
+ if (version == 2 )
550
+ return murmur3_seeded_v2 (seed , data , len );
551
+ else
552
+ return murmur3_seeded_v1 (seed , data , len );
553
+ }
Original file line number Diff line number Diff line change @@ -78,15 +78,6 @@ int load_bloom_filter_from_graph(struct commit_graph *g,
78
78
struct bloom_filter * filter ,
79
79
uint32_t graph_pos );
80
80
81
- /*
82
- * Calculate the murmur3 32-bit hash value for the given data
83
- * using the given seed.
84
- * Produces a uniformly distributed hash value.
85
- * Not considered to be cryptographically secure.
86
- * Implemented as described in https://en.wikipedia.org/wiki/MurmurHash#Algorithm
87
- */
88
- uint32_t murmur3_seeded_v2 (uint32_t seed , const char * data , size_t len );
89
-
90
81
void fill_bloom_key (const char * data ,
91
82
size_t len ,
92
83
struct bloom_key * key ,
@@ -137,4 +128,7 @@ int bloom_filter_contains(const struct bloom_filter *filter,
137
128
const struct bloom_key * key ,
138
129
const struct bloom_filter_settings * settings );
139
130
131
+ uint32_t test_bloom_murmur3_seeded (uint32_t seed , const char * data , size_t len ,
132
+ int version );
133
+
140
134
#endif
Original file line number Diff line number Diff line change @@ -61,13 +61,13 @@ int cmd__bloom(int argc, const char **argv)
61
61
uint32_t hashed ;
62
62
if (argc < 3 )
63
63
usage (bloom_usage );
64
- hashed = murmur3_seeded_v2 (0 , argv [2 ], strlen (argv [2 ]));
64
+ hashed = test_bloom_murmur3_seeded (0 , argv [2 ], strlen (argv [2 ]), 2 );
65
65
printf ("Murmur3 Hash with seed=0:0x%08x\n" , hashed );
66
66
}
67
67
68
68
if (!strcmp (argv [1 ], "get_murmur3_seven_highbit" )) {
69
69
uint32_t hashed ;
70
- hashed = murmur3_seeded_v2 (0 , "\x99\xaa\xbb\xcc\xdd\xee\xff" , 7 );
70
+ hashed = test_bloom_murmur3_seeded (0 , "\x99\xaa\xbb\xcc\xdd\xee\xff" , 7 , 2 );
71
71
printf ("Murmur3 Hash with seed=0:0x%08x\n" , hashed );
72
72
}
73
73
You can’t perform that action at this time.
0 commit comments