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
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Hi everyone!
The first release candidate for the Expert language server project is now available!
We’ve published a press release detai...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 18 to 9- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
g-andrade
A theoretical example
gb_treewith:[{0, %{user: :a}}, {1, %{user: b}}, {2, %{user: z}}, {3, %{user: a}}Mapof lists with:%{a: [0, 3], b: [1], c: [2]You then iterate over the
gb_treeuntil you find something you want to delete/process; then, to find out which other entries you need to delete, you consult the index rather than iterating over all the entries.Then, once you’ve finished processing that particular group of objects, you can continue iterating where you left of (
gb_treedoes provide a function for this.)All that it’s left is to write the bookkeeping code necessarily to ensure the two structures remain consistent with each other for every write.
g-andrade
You may also consider indexing your objects on every write, based on the property that binds distinct groups of them together across the ordered data structure.
This will increment memory usage and make each individual write more expensive - but not much so, if the right data structures are leveraged (e.g. a
gb_treefor the ordered bit and aMapof lists for indexing stuff.)The coordinated management of the two data structures (the main one plus the index) can be kept behind an API to keep it simple to use and reason about.
sribe
Are the keys the order of requests, and it’s desired to process in FIFO order?
Does the list of matches also need to be returned in FIFO order?
tcoopman
Am I understanding it correctly like this:
If you have structure like this
Your algorithm loops over each element, finds
1:aand searches for all a (6 in this case).Delete 1 and 6 and send a message to some process?
And then repeat this for the remaining entries? Starting with
2: c?Is this correct?
If it’s correct, then can’t you sort the objects by the items first and then do the other actions on them, so sorted like: `a: 1, 6 - c: 2, 4, 5 - x: 3 - d: 7]?
This brings the logarithmic complexity down from an O(n2) to an O(n log n) operation and should be much faster
bryanhuntesl
Need to continually perform the following operation:
1.1 for each object:
1.1.1 Iterate again through the list of objects, make a list of objects which can be matched with the current object
2.1 send a message with the object and it’s matches to another system
2.1 GOTO 1
tcoopman
Can you explain the problem a bit more? I’m not sure I understand how an map with ordered keys will help with this exactly. Maybe there are other data structures that would be suited better?
dimitarvp
The BEAM languages and Rust are a natural pair – both emphasize safety and never actually crashing (in terms of an OS process).
I know what it is to be very busy and to have an eternally huge backlog. So definitely not excuses as you said, we just have only so much focused creative time per day.
But my recommendation stands for when you have the time. Rustler works very well.
bryanhuntesl
Typical use case would be to match people looking to rent or let property by geographic area. Perform a periodic rollup across all users. Remove users who had already been matched. Have tried with ETS but was only able to process 80,000 per second. Personal challenge is to find a way to match 200,000.
Adzz
Can you share the use case for an ordered map? I super curious!
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.