Multi-ApplicationOnlineProfiling  2.1
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Bloom_Filter.c
Go to the documentation of this file.
1 /* ############################ MALP License ############################## */
2 /* # Fri Jan 18 14:00:00 CET 2013 # */
3 /* # Copyright or (C) or Copr. Commissariat a l'Energie Atomique # */
4 /* # # */
5 /* # This software is governed by the CeCILL-C license under French law # */
6 /* # and abiding by the rules of distribution of free software. You can # */
7 /* # use, modify and/ or redistribute the software under the terms of # */
8 /* # the CeCILL-C license as circulated by CEA, CNRS and INRIA at the # */
9 /* # following URL http://www.cecill.info. # */
10 /* # # */
11 /* # The fact that you are presently reading this means that you have # */
12 /* # had knowledge of the CeCILL-C license and that you accept its # */
13 /* # terms. # */
14 /* # # */
15 /* # Authors: # */
16 /* # - BESNARD Jean-Baptiste jean-baptiste.besnard@cea.fr # */
17 /* # # */
18 /* ######################################################################## */
19 
20 #include "Bloom_Filter.h"
21 
22 
23 
24 void Bloom_Filter_init( struct Bloom_Filter *bf , uint64_t size, size_t sizeof_payload )
25 {
26  Bit_Array_init( &bf->array, size );
27  bf->lock = 0;
28  bf->size = size;
29  bf->sizeof_payload = sizeof_payload;
30 }
31 
33 {
34  Bit_Array_release( &bf->array );
35  bf->lock = 0;
36  bf->size = 0;
37  bf->sizeof_payload = 0;
38 }
39 
40 
41 
42 void Bloom_Filter_replicate( struct Bloom_Filter *dest , struct Bloom_Filter *src )
43 {
44  MALP_Spinlock_lock( &dest->lock );
45  MALP_Spinlock_lock( &src->lock );
46  Bit_Array_replicate( &dest->array, &src->array );
47  MALP_Spinlock_unlock( &src->lock );
48  MALP_Spinlock_unlock( &dest->lock );
49 }
struct Bit_Array array
The bit Array containing the filter data.
Definition: Bloom_Filter.h:43
void Bit_Array_release(struct Bit_Array *ba)
Bit_Array deinitializer.
Definition: Bit_Array.c:41
void Bit_Array_init(struct Bit_Array *ba, uint64_t size)
Bit_Array initializer.
Definition: Bit_Array.c:23
MALP_Spinlock lock
The lock for concurrent access on the bit array.
Definition: Bloom_Filter.h:44
int MALP_Spinlock_unlock(MALP_Spinlock *mutex)
Unlocks the given MALP_Spinlock.
Definition: Spinlock.c:41
void Bloom_Filter_release(struct Bloom_Filter *bf)
Releases a Bloom_Filter.
Definition: Bloom_Filter.c:32
This is the main structure defining the Bloom Filter.
Definition: Bloom_Filter.h:41
size_t sizeof_payload
The size of elements that can be added to the filter.
Definition: Bloom_Filter.h:46
int MALP_Spinlock_lock(MALP_Spinlock *mutex)
Locks the given MALP_Spinlock.
Definition: Spinlock.c:29
void Bloom_Filter_init(struct Bloom_Filter *bf, uint64_t size, size_t sizeof_payload)
Initializes a Bloom_Filter.
Definition: Bloom_Filter.c:24
uint64_t size
The size of the filter data.
Definition: Bloom_Filter.h:45
void Bit_Array_replicate(struct Bit_Array *dest, struct Bit_Array *src)
Copies a Bit_Array into another.
Definition: Bit_Array.c:55
void Bloom_Filter_replicate(struct Bloom_Filter *dest, struct Bloom_Filter *src)
Copies a Bloom_Filter within an other.
Definition: Bloom_Filter.c:42