Skip to content

Commit

Permalink
Added access to the keys that a bloom filter uses, if it has been sha…
Browse files Browse the repository at this point in the history
…rded among multiple keys
  • Loading branch information
Dan Lecocq committed Aug 1, 2013
1 parent 21a233f commit 19cca48
Show file tree
Hide file tree
Showing 6 changed files with 877 additions and 449 deletions.
6 changes: 3 additions & 3 deletions pyreBloom/bloom.c
Expand Up @@ -42,10 +42,10 @@ int init_pyrebloom(pyrebloomctxt * ctxt, char * key, uint32_t capacity, double e
strncpy(ctxt->password, password, strlen(password));

/* We'll need a certain number of strings here */
uint32_t num_keys = (uint32_t)(
ctxt->num_keys = (uint32_t)(
ceil((float)(ctxt->bits) / max_bits_per_key));
ctxt->keys = (char**)(malloc(num_keys * sizeof(char*)));
for (i = 0; i < num_keys; ++i) {
ctxt->keys = (char**)(malloc(ctxt->num_keys * sizeof(char*)));
for (i = 0; i < ctxt->num_keys; ++i) {
ctxt->keys[i] = (char*)(malloc(strlen(key) + 10));
sprintf(ctxt->keys[i], "%s.%i", key, i);
}
Expand Down
1 change: 1 addition & 0 deletions pyreBloom/bloom.h
Expand Up @@ -31,6 +31,7 @@
typedef struct {
uint32_t capacity;
uint32_t hashes;
uint32_t num_keys;
uint64_t bits;
double error;
uint32_t * seeds;
Expand Down
1 change: 1 addition & 0 deletions pyreBloom/bloom.pxd
Expand Up @@ -33,6 +33,7 @@ cdef extern from "bloom.h":
ctypedef struct pyrebloomctxt:
uint32_t capacity
uint32_t hashes
uint32_t num_keys
uint64_t bits
double error
uint32_t * seeds
Expand Down

0 comments on commit 19cca48

Please sign in to comment.