bloomfilter icon indicating copy to clipboard operation
bloomfilter copied to clipboard

Bidirectional serialization of Bloom filters

Open ocharles opened this issue 11 years ago • 3 comments

I'd like to use bloomfilter in order to let clients filter a large set on the server, while making efficient use of bandwidth. As such, clients will construct a Bloom filter themselves, transmit it over the network, and the server will use this Bloom filter against a local set it maintains. The result will then be transmitted over the network back to the client.

While I can get access to the underlying representation of a filter, I do not appear to be able to recreate the filter from it.

ocharles avatar Feb 24 '13 13:02 ocharles

This is actually possible, though not too obvious from just looking at the API:

let (bits,nh) = suggestSizing 3 0.1
     hfam     = cheapHashes nh
     filt     = fromList hfam bits ["foo", "bar", "quux"]
     arr      = bitArray filt -- warnings about endianness and word size apply
     filt'    = empty hfam bits -- must use the same parameters when re-creating the filter
 in filt' { bitArray = arr } 

(note: the hackage version exposes a slightly different API)

kim avatar Apr 30 '14 08:04 kim

Can this be closed?

bgamari avatar May 27 '14 19:05 bgamari

It would be nice to get official support for this in the API.

gibiansky avatar Jul 26 '15 04:07 gibiansky