Anansi
a hybrid Ruby Set using memory and disk (SQLite) for large sized tasks
What?
An append only Set that uses constant memory by spilling to disk after crossing a size threshold.
Why?
A Set in memory isn't great for huge tasks. But a disk based Set is too slow for everything. We need the best of both worlds.
Installation
Install the gem and add to the application's Gemfile by executing:
$> bundle add anansi
If bundler is not being used to manage dependencies, install the gem by executing:
$> gem install anansi
Usage
Add items to an AppendSet
:
append_set = Anansi::AppendSet.new
append_set.add(['foo', 'bar', 'buzz'])
Check if an item exists in an AppendSet
:
append_set.include? 'foo'
Get the size of an AppendSet
:
append_set.size
(If you need other data structures, stay tuned and watch our org)
Feedback
Source code available on Github. Feedback and pull requests are greatly appreciated. Let us know if we can improve this.
From
👋 The folks at Census originally put this together. Have data? We'll sync your data warehouse with your CRM and other apps critical to your team. Interested in what we’re doing? Come work with us.