Probabilistic set tests. More...
Typedefs | |
typedef int(* | GNUNET_CONTAINER_HashCodeIterator) (void *cls, struct GNUNET_HashCode *next) |
Iterator over struct GNUNET_HashCode . More... | |
Functions | |
struct GNUNET_CONTAINER_BloomFilter * | GNUNET_CONTAINER_bloomfilter_load (const char *filename, size_t size, unsigned int k) |
Load a Bloom filter from a file. More... | |
struct GNUNET_CONTAINER_BloomFilter * | GNUNET_CONTAINER_bloomfilter_init (const char *data, size_t size, unsigned int k) |
Create a Bloom filter from raw bits. More... | |
enum GNUNET_GenericReturnValue | GNUNET_CONTAINER_bloomfilter_get_raw_data (const struct GNUNET_CONTAINER_BloomFilter *bf, char *data, size_t size) |
Copy the raw data of this Bloom filter into the given data array. More... | |
bool | GNUNET_CONTAINER_bloomfilter_test (const struct GNUNET_CONTAINER_BloomFilter *bf, const struct GNUNET_HashCode *e) |
Test if an element is in the filter. More... | |
void | GNUNET_CONTAINER_bloomfilter_add (struct GNUNET_CONTAINER_BloomFilter *bf, const struct GNUNET_HashCode *e) |
Add an element to the filter. More... | |
void | GNUNET_CONTAINER_bloomfilter_remove (struct GNUNET_CONTAINER_BloomFilter *bf, const struct GNUNET_HashCode *e) |
Remove an element from the filter. More... | |
struct GNUNET_CONTAINER_BloomFilter * | GNUNET_CONTAINER_bloomfilter_copy (const struct GNUNET_CONTAINER_BloomFilter *bf) |
Create a copy of a bloomfilter. More... | |
void | GNUNET_CONTAINER_bloomfilter_free (struct GNUNET_CONTAINER_BloomFilter *bf) |
Free the space associated with a filter in memory, flush to drive if needed (do not free the space on the drive). More... | |
size_t | GNUNET_CONTAINER_bloomfilter_get_size (const struct GNUNET_CONTAINER_BloomFilter *bf) |
Get size of the bloom filter. More... | |
void | GNUNET_CONTAINER_bloomfilter_clear (struct GNUNET_CONTAINER_BloomFilter *bf) |
Reset a Bloom filter to empty. More... | |
enum GNUNET_GenericReturnValue | GNUNET_CONTAINER_bloomfilter_or (struct GNUNET_CONTAINER_BloomFilter *bf, const char *data, size_t size) |
"or" the entries of the given raw data array with the data of the given Bloom filter. More... | |
enum GNUNET_GenericReturnValue | GNUNET_CONTAINER_bloomfilter_or2 (struct GNUNET_CONTAINER_BloomFilter *bf, const struct GNUNET_CONTAINER_BloomFilter *to_or) |
"or" the entries of the given raw data array with the data of the given Bloom filter. More... | |
void | GNUNET_CONTAINER_bloomfilter_resize (struct GNUNET_CONTAINER_BloomFilter *bf, GNUNET_CONTAINER_HashCodeIterator iterator, void *iterator_cls, size_t size, unsigned int k) |
Resize a bloom filter. More... | |
Probabilistic set tests.
typedef int(* GNUNET_CONTAINER_HashCodeIterator) (void *cls, struct GNUNET_HashCode *next) |
Iterator over struct GNUNET_HashCode
.
cls | closure |
next | set to the next hash code |
Definition at line 130 of file gnunet_container_lib.h.
struct GNUNET_CONTAINER_BloomFilter * GNUNET_CONTAINER_bloomfilter_load | ( | const char * | filename, |
size_t | size, | ||
unsigned int | k | ||
) |
Load a Bloom filter from a file.
filename | the name of the file (or the prefix) |
size | the size of the bloom-filter (number of bytes of storage space to use); will be rounded up to next power of 2 |
k | the number of GNUNET_CRYPTO_hash-functions to apply per element (number of bits set per element in the set) |
Definition at line 472 of file container_bloomfilter.c.
References _, GNUNET_CONTAINER_BloomFilter::addressesPerElement, GNUNET_CONTAINER_BloomFilter::bitArray, GNUNET_CONTAINER_BloomFilter::bitArraySize, BUFFSIZE, GNUNET_CONTAINER_BloomFilter::fh, filename, GNUNET_CONTAINER_BloomFilter::filename, GNUNET_assert, GNUNET_DISK_file_close(), GNUNET_DISK_file_handle_size(), GNUNET_DISK_file_open(), GNUNET_DISK_file_read(), GNUNET_DISK_file_test(), GNUNET_DISK_OPEN_CREATE, GNUNET_DISK_OPEN_READWRITE, GNUNET_DISK_PERM_USER_READ, GNUNET_DISK_PERM_USER_WRITE, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log, GNUNET_log_strerror, GNUNET_malloc, GNUNET_malloc_large, GNUNET_new, GNUNET_NO, GNUNET_OK, GNUNET_strdup, GNUNET_YES, LOG_STRERROR_FILE, make_empty_file(), res, setBit(), and size.
Referenced by GNUNET_DATACACHE_create(), and run().
struct GNUNET_CONTAINER_BloomFilter * GNUNET_CONTAINER_bloomfilter_init | ( | const char * | data, |
size_t | size, | ||
unsigned int | k | ||
) |
Create a Bloom filter from raw bits.
data | the raw bits in memory (maybe NULL, in which case all bits should be considered to be zero). |
size | the size of the bloom-filter (number of bytes of storage space to use); also size of data – unless data is NULL. Must be a power of 2. |
k | the number of GNUNET_CRYPTO_hash-functions to apply per element (number of bits set per element in the set) |
Definition at line 613 of file container_bloomfilter.c.
References GNUNET_CONTAINER_BloomFilter::addressesPerElement, GNUNET_CONTAINER_BloomFilter::bitArray, GNUNET_CONTAINER_BloomFilter::bitArraySize, data, GNUNET_CONTAINER_BloomFilter::fh, GNUNET_CONTAINER_BloomFilter::filename, GNUNET_free, GNUNET_malloc_large, GNUNET_memcpy, GNUNET_new, and size.
Referenced by GNUNET_BLOCK_GROUP_bf_create(), GNUNET_CONTAINER_bloomfilter_copy(), GNUNET_DATACACHE_create(), handle_dht_local_put(), handle_dht_p2p_get(), handle_dht_p2p_put(), handle_intersection_p2p_bf(), run(), send_bloomfilter(), send_find_peer_message(), setup_filter(), and transmit_request().
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_bloomfilter_get_raw_data | ( | const struct GNUNET_CONTAINER_BloomFilter * | bf, |
char * | data, | ||
size_t | size | ||
) |
Copy the raw data of this Bloom filter into the given data array.
data | where to write the data |
size | the size of the given data array |
Definition at line 639 of file container_bloomfilter.c.
References GNUNET_CONTAINER_BloomFilter::bitArray, GNUNET_CONTAINER_BloomFilter::bitArraySize, data, GNUNET_memcpy, GNUNET_OK, GNUNET_SYSERR, and size.
Referenced by bf_group_serialize_cb(), GDS_helper_make_put_message(), GDS_NEIGHBOURS_handle_get(), and send_bloomfilter().
bool GNUNET_CONTAINER_bloomfilter_test | ( | const struct GNUNET_CONTAINER_BloomFilter * | bf, |
const struct GNUNET_HashCode * | e | ||
) |
Test if an element is in the filter.
e | the element |
bf | the filter |
Definition at line 679 of file container_bloomfilter.c.
References iterateBits(), res, and testBitCallback().
Referenced by filtered_map_initialization(), find_advertisable_hello(), GDS_am_closest_peer(), GDS_helper_make_put_message(), GNUNET_BLOCK_GROUP_bf_test_and_set(), GNUNET_DATACACHE_get(), handle_dht_p2p_get(), handle_dht_p2p_put(), handle_get_key(), handle_put(), iterator_bf_reduce(), and select_peer().
void GNUNET_CONTAINER_bloomfilter_add | ( | struct GNUNET_CONTAINER_BloomFilter * | bf, |
const struct GNUNET_HashCode * | e | ||
) |
Add an element to the filter.
bf | the filter |
e | the element |
Definition at line 697 of file container_bloomfilter.c.
References incrementBitCallback(), and iterateBits().
Referenced by add_key_to_bloomfilter(), bf_group_mark_seen_cb(), GDS_NEIGHBOURS_handle_get(), GDS_NEIGHBOURS_handle_put(), GNUNET_BLOCK_GROUP_bf_test_and_set(), GNUNET_CONTAINER_bloomfilter_resize(), GNUNET_DATACACHE_put(), iterator_bf_create(), put_continuation(), run(), schedule_next_hello(), and setup_filter().
void GNUNET_CONTAINER_bloomfilter_remove | ( | struct GNUNET_CONTAINER_BloomFilter * | bf, |
const struct GNUNET_HashCode * | e | ||
) |
Remove an element from the filter.
bf | the filter |
e | the element to remove |
Definition at line 767 of file container_bloomfilter.c.
References decrementBitCallback(), GNUNET_CONTAINER_BloomFilter::filename, and iterateBits().
Referenced by env_delete_notify(), expired_processor(), quota_processor(), and remove_continuation().
struct GNUNET_CONTAINER_BloomFilter * GNUNET_CONTAINER_bloomfilter_copy | ( | const struct GNUNET_CONTAINER_BloomFilter * | bf | ) |
Create a copy of a bloomfilter.
bf | the filter |
Definition at line 108 of file container_bloomfilter.c.
References GNUNET_CONTAINER_BloomFilter::addressesPerElement, GNUNET_CONTAINER_BloomFilter::bitArray, GNUNET_CONTAINER_BloomFilter::bitArraySize, and GNUNET_CONTAINER_bloomfilter_init().
void GNUNET_CONTAINER_bloomfilter_free | ( | struct GNUNET_CONTAINER_BloomFilter * | bf | ) |
Free the space associated with a filter in memory, flush to drive if needed (do not free the space on the drive).
bf | the filter |
Definition at line 654 of file container_bloomfilter.c.
References GNUNET_CONTAINER_BloomFilter::bitArray, GNUNET_CONTAINER_BloomFilter::fh, GNUNET_CONTAINER_BloomFilter::filename, GNUNET_DISK_file_close(), and GNUNET_free.
Referenced by _GSS_operation_destroy(), bf_group_destroy_cb(), cleaning_task(), consider_for_advertising(), find_advertisable_hello(), free_peer(), GNUNET_DATACACHE_destroy(), handle_dht_local_put(), handle_dht_p2p_get(), handle_dht_p2p_put(), intersection_op_cancel(), process_bf(), process_peer(), process_stat_done(), send_bloomfilter(), send_find_peer_message(), and transmit_request().
size_t GNUNET_CONTAINER_bloomfilter_get_size | ( | const struct GNUNET_CONTAINER_BloomFilter * | bf | ) |
Get size of the bloom filter.
bf | the filter |
Definition at line 98 of file container_bloomfilter.c.
References GNUNET_CONTAINER_BloomFilter::bitArraySize.
void GNUNET_CONTAINER_bloomfilter_clear | ( | struct GNUNET_CONTAINER_BloomFilter * | bf | ) |
Reset a Bloom filter to empty.
bf | the filter |
Definition at line 667 of file container_bloomfilter.c.
References GNUNET_CONTAINER_BloomFilter::bitArray, GNUNET_CONTAINER_BloomFilter::bitArraySize, GNUNET_CONTAINER_BloomFilter::fh, GNUNET_CONTAINER_BloomFilter::filename, and make_empty_file().
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_bloomfilter_or | ( | struct GNUNET_CONTAINER_BloomFilter * | bf, |
const char * | data, | ||
size_t | size | ||
) |
"or" the entries of the given raw data array with the data of the given Bloom filter.
Assumes that the size of the data array and the current filter match.
bf | the filter |
data | data to OR-in |
size | size of data |
Definition at line 710 of file container_bloomfilter.c.
References GNUNET_CONTAINER_BloomFilter::bitArray, GNUNET_CONTAINER_BloomFilter::bitArraySize, data, dc, GNUNET_OK, GNUNET_SYSERR, GNUNET_YES, and size.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_bloomfilter_or2 | ( | struct GNUNET_CONTAINER_BloomFilter * | bf, |
const struct GNUNET_CONTAINER_BloomFilter * | to_or | ||
) |
"or" the entries of the given raw data array with the data of the given Bloom filter.
Assumes that the size of the two filters matches.
bf | the filter |
to_or | the bloomfilter to or-in |
Definition at line 736 of file container_bloomfilter.c.
References GNUNET_CONTAINER_BloomFilter::bitArray, GNUNET_CONTAINER_BloomFilter::bitArraySize, dc, GNUNET_break, GNUNET_OK, GNUNET_SYSERR, and size.
Referenced by bf_group_merge_cb().
void GNUNET_CONTAINER_bloomfilter_resize | ( | struct GNUNET_CONTAINER_BloomFilter * | bf, |
GNUNET_CONTAINER_HashCodeIterator | iterator, | ||
void * | iterator_cls, | ||
size_t | size, | ||
unsigned int | k | ||
) |
Resize a bloom filter.
Note that this operation is pretty costly. Essentially, the Bloom filter needs to be completely re-build.
bf | the filter |
iterator | an iterator over all elements stored in the BF |
iterator_cls | closure for iterator |
size | the new size for the filter |
k | the new number of GNUNET_CRYPTO_hash-function to apply per element |
Definition at line 782 of file container_bloomfilter.c.
References GNUNET_CONTAINER_BloomFilter::addressesPerElement, GNUNET_CONTAINER_BloomFilter::bitArray, GNUNET_CONTAINER_BloomFilter::bitArraySize, GNUNET_CONTAINER_BloomFilter::fh, GNUNET_CONTAINER_BloomFilter::filename, GNUNET_CONTAINER_bloomfilter_add(), GNUNET_free, GNUNET_malloc, GNUNET_YES, make_empty_file(), and size.