This commit is contained in:
Luca
2023-09-07 11:12:37 +02:00
parent 2bd986a00a
commit 47fb5e9f3d
2 changed files with 47 additions and 27 deletions
+10
View File
@@ -2002,6 +2002,10 @@ extern "C" {
/* /*
Bitmap based on compressed bitmaps Bitmap based on compressed bitmaps
implemented by https://roaringbitmap.org implemented by https://roaringbitmap.org
This is
- NOT a probabilistic datastructure (i.e. no false positives)
- mutable (i.e. you can add values at any time)
*/ */
ndpi_bitmap* ndpi_bitmap_alloc(void); ndpi_bitmap* ndpi_bitmap_alloc(void);
@@ -2035,6 +2039,11 @@ extern "C" {
/* /*
Bitmap with 64 bit values based Bitmap with 64 bit values based
on https://github.com/FastFilter/xor_singleheader/tree/master on https://github.com/FastFilter/xor_singleheader/tree/master
This is
- a probabilistic datastructure !!! (i.e. be prepared to false positives)
- immutable (i.e. adding keys after a search (i.e. ndpi_bitmap64_isset)
is not allowed
*/ */
ndpi_bitmap64* ndpi_bitmap64_alloc(); ndpi_bitmap64* ndpi_bitmap64_alloc();
@@ -2045,6 +2054,7 @@ extern "C" {
u_int32_t ndpi_bitmap64_size(ndpi_bitmap64 *b); u_int32_t ndpi_bitmap64_size(ndpi_bitmap64 *b);
/* ******************************* */ /* ******************************* */
/* /*
Bloom-filter on steroids based on ndpi_bitmap Bloom-filter on steroids based on ndpi_bitmap
+10
View File
@@ -122,6 +122,16 @@ bool ndpi_bitmap64_compress(ndpi_bitmap64 *_b) {
bool ndpi_bitmap64_set(ndpi_bitmap64 *_b, u_int64_t value) { bool ndpi_bitmap64_set(ndpi_bitmap64 *_b, u_int64_t value) {
ndpi_bitmap64_t *b = (ndpi_bitmap64_t*)_b; ndpi_bitmap64_t *b = (ndpi_bitmap64_t*)_b;
if(b->is_compressed) {
/*
We need to discard the filter and start over as this
datastructure is immutable
*/
binary_fuse16_free(&b->bitmap);
/* No need to call b->is_compressed = false; as it will be set below */
}
if(b->num_used_entries >= b->num_allocated_entries) { if(b->num_used_entries >= b->num_allocated_entries) {
u_int64_t *rc; u_int64_t *rc;
u_int32_t new_len = b->num_allocated_entries + NDPI_BITMAP64_REALLOC_SIZE; u_int32_t new_len = b->num_allocated_entries + NDPI_BITMAP64_REALLOC_SIZE;