preciz

preciz

Talan library - probabilistic data structures with concurrent accessibility based on atomics

Talán - probabilistic data structures

Talán is a Hungarian adverb meaning: maybe, perhaps, probably.

This library currently has 3 probablistic data structures:

  • A bloom filter (inspired by the blex library but with a few more features.
  • A counting bloom filter
  • A probabilistic linear counter for cardinality estimation

All the above are built on :atomics for concurrent accessibility and speed.

GitHub: https://github.com/preciz/talan
Hex: https://hex.pm/packages/talan

Talan.Stream.uniq/2

The library also contains a module called Talan.Stream which has a uniq/2 function.
With this you can build probabilistically uniq streams.

list = ["a", "b", "c", "a", "b", "c"]

bloom_filter = Talan.BloomFilter.new(100_000, false_positive_probability: 0.001)

Talan.Stream.uniq(list, bloom_filter) |> Enum.to_list
["a", "b", "c"]

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.

Talan.BloomFilter

  • Fixed size Bloom filter
  • Concurrent reads & writes
  • Custom & default hash functions
  • Merge multiple Bloom filters into one
  • Intersect multiple Bloom filters into one
  • Estimate number of unique elements
  • Estimate current false positive probability

Examples

iex> b = Talan.BloomFilter.new(1000)
iex> b |> Talan.BloomFilter.put("Barna")
iex> b |> Talan.BloomFilter.member?("Barna")
true
iex> b |> Talan.BloomFilter.member?("Kovacs")
false

Talan.CountingBloomFilter

This is based on the BloomFilter module and adds a custom sized counter for every bit.

Counting bloom filters support probabilistic deletion
of elements but have higher memory consumption because
they need to store a counter of N bits for every bloom filter bit.

Examples

cbf = Talan.CountingBloomFilter.new(10_000)
cbf |> Talan.CountingBloomFilter.put("hat")
cbf |> Talan.CountingBloomFilter.put("hat")
cbf |> Talan.CountingBloomFilter.put("phone")
cbf |> Talan.CountingBloomFilter.count("hat")
2
cbf |> Talan.CountingBloomFilter.count("phone")
1

Talan.Counter

Linear probabilistic counter implementation for cardinality estimation.

Examples

c = Talan.Counter.new(10_000)
c |> Talan.Counter.put(["you", :can, Hash, {"any", "elixir", "term"}])
c |> Talan.Counter.put(["you", :can, Hash, {"any", "elixir", "term"}])
c |> Talan.Counter.cardinality()
1
c |> Talan.Counter.put("more")
c |> Talan.Counter.cardinality()
2

Feedback is welcome. :wave:

(I would like to also mention that I’m looking for employment, if you are an employer or your company is hiring I would be happy to talk with you. PM me. Thank you!)

Where Next?

Popular in Libraries Top

marcuslankenau
I feel kind of stuck with the absence of a proper xml library for Elixir. Currently I use SweetXML which was ok for me more or less to pa...
New
tmbb
I’ve been working on two packages (not on hex.pm yet) to build admin interfaces for phoenix apps: bureaucrat - which contains a bunch ...
New
treble37
Just looking for a little feedback on a tiny helper library I built - Sometimes I find the need to convert maps with atom keys to maps...
New
kelvinst
Hey everyone! Well, we made this lib a while ago and now we decided to finally go out and public with it! It’s a tool for creating and m...
New
josevalim
EDIT: since Ecto 3.0 final version is out, this post was amended to use the final versions in the instructions below. Hi everyone, We a...
New
Crowdhailer
I have been updating a library that allows you to pipe between functions that use the erlang result tuple convention. Assuming you have...
New
woylie
Flop is an Elixir library that applies filtering, ordering and pagination parameters to your Ecto queries. offset-based pagination with...
New
gabrielpoca
Hello everyone! I want to share with you something that I’m really proud of: https://stillstatic.io/ Still is a static site builder for...
New
mtrudel
Bandit is an HTTP server for Plug and WebSock apps. Bandit is written entirely in Elixir and is built atop Thousand Island. It can serve...
New
anshuman23
Hello all, I have been working on my proposed project called Tensorflex as part of Google Summer of Code 2018.. Tensorflex can be used f...
New

Other popular topics Top

Tee
can someone please explain to me how Enum.reduce works with maps
New
William
I would like to know that is there any online source for learning Phoenix Framework for building E-Commerce Store? Any advantage on build...
New
yawaramin
In the Dialyzer docs ( http://erlang.org/doc/man/dialyzer.html#requesting-or-suppressing-warnings-in-source-files ), there is a way to tu...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
malloryerik
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode. The solution seems to be, in a hyphena...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list....
New
AstonJ
We’ve put together this wiki for Phoenix LiveView - please feel free to add any info you feel is worth including. What is Phoenix LiveV...
New
aesmail
Hello guys, I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New

Sub Categories:

We're in Beta

About us Mission Statement