bryanhuntesl
I’ve done a lot of GitHub searching but I can’t find an erlang/elixir data structure similar to Java’s SortedMap.
I’ve been using ETS :sortedset but the performance hasn’t been sufficient for my needs. Anyone got any suggestions ?
Need to do iterations and multiple lookups …
Trending in Questions
Hello!
Suppose you are building workflow (order / task / payment) processing system with the following requirements:
Each workflow con...
New
Hey guys,
I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly
Do you guys have any suggestions what is the best prac...
New
Hello!
Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app.
I creat...
New
I have what I’ve heard referred to as a “lookup table” in my database. This is a way of assigning codes to common values. One common lo...
New
Hello,
I’m developing a online persistent chat system (what’s app) like using elixir/dynamodb/aws for a mobile app(flutter).
The diffic...
New
What approach to take when sending live updates to “random” users Hi! I have a question, I have a little chat app, and when I create a DM...
New
Anyone here using Honeybadger?
My Honeybadger account is being overwhelmed with noise from some bots. Seeing a lot of
Bandit.HTTPError...
New
Other Trending Topics
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
There are three potential reasons for members of this forum to have a look at https://vutuv.de
You are tired or annoyed of LinkedIn.
Yo...
New
Aludel - LLM Evaluation Workbench
Aludel is an embeddable Phoenix LiveView dashboard for evaluating and comparing LLM prompts across mult...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #blog-post
- #ai
- #elixirconf-us
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
wolf4earth
Have you considered using this library?
mpope
There is an Erlang
gb_treethat is built in. For ordered iteration, there is aniterator/1, andto_list/1can be used withEnumI think.gb_setsis also available.Sadly it’s interface isn’t compatible with Elixir pipes, because the data structure is the last argument but an Elixir wrapper shouldn’t be too hard.
japplegame
If you need custom ordering, consider AVLTree
bryanhuntesl
I’m not sure from the project docs it’s doing what I need.
bryanhuntesl
Had a look. I’ll throw in a couple of examples now and maybe benchmark later.
Create new :
:gb_trees.emptyPopulate with 10 elements :
gb = 1..10 |> Enum.reduce(:gb_trees.empty, fn x,acc -> :gb_trees.insert(x,x,acc) end)Iterating elements :
{k,v,next} = :gb_trees.next(iter)I will mention I started looking at native code to solve my issue (need high performance). Here’s what I also considered.. After some investigation, I came across klib library (pure C, license X11/MIT) and it’s KBtree ordered map implementation. Considering wrapping it with a NIF.
mpope
If you need the high performance, you could still leverage
etsfor direct access and use a separate data structure just for iteration of the keys, but that does get cumbersome.Nifs are tricky
you can take a look at this (very similar) nif I write to wrap a C data structure (also a single header lib). If you need to load a huge amount of items into that tree consider using a dirty nif as not to block the whole VM while it scans the tree. That also comes with overhead of it’s own though.
dimitarvp
This probably calls for a generic Rustler-based Elixir library that bridges various Rust data structures to Elixir code. In your case that’d be Rust’s
BTreeMap.Discord have a sorted set library with bindings to Rust – not a map but still, in case you need this one as well. You can also just take a look at Discord’s libraries in general, they are quite excellent.
bryanhuntesl
Yeah everyone speaks well of Rust for native code - I haven’t taken the time to learn it so worried about the cognitive load but I do know C/C++ . Should probably watch Scroggin’s talk again but I’m spending so much time on beam/infrastructure I’ve not much chance to learn a new language. Excuses. Excuses.
bryanhuntesl
Thanks @mpope some good points there. exor_filter/c_src/xor_filter_nif.c at master · mpope9/exor_filter · GitHub yeah good example of resource allocation/deallocation - at least it’s reasonably straightforward in BEAM compared to say for example writing a Java native extension. Good point about the dirty NIF.
Adzz
Can you share the use case for an ordered map? I super curious!