View Source Talan.Stream (talan v0.1.2)

Link to this section Summary

Functions

Returns a probabilistically uniq stream.

Link to this section Functions

Link to this function

uniq(enum, bloom_filter)

View Source

Returns a probabilistically uniq stream.

Its main advantage is that it doesn't store elements emitted by the stream. Instead it uses a bloom filter for membership check.

The stream never returns duplicate elements but it sometimes detects false positive duplicates depending on the bloom filter it uses. False positives are faulty duplicate detections that get rejected.

examples

Examples

iex> list = ["a", "b", "c", "a", "b"]
iex> bloom_filter = Talan.BloomFilter.new(100_000, false_positive_probability: 0.001)
iex> Talan.Stream.uniq(list, bloom_filter) |> Enum.to_list
["a", "b", "c"]