https://github.com/azuchi/minisketchrb
This is a Ruby wrapper for the libminisketch C library.
https://github.com/azuchi/minisketchrb
minisketch ruby
Last synced: 9 days ago
JSON representation
This is a Ruby wrapper for the libminisketch C library.
- Host: GitHub
- URL: https://github.com/azuchi/minisketchrb
- Owner: azuchi
- License: mit
- Created: 2022-10-31T09:05:38.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2025-05-28T08:00:41.000Z (about 1 year ago)
- Last Synced: 2025-10-13T18:05:33.285Z (9 months ago)
- Topics: minisketch, ruby
- Language: Ruby
- Homepage:
- Size: 27.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Minisketch binding for ruby [](https://github.com/azuchi/minisketchrb/actions/workflows/main.yml) [](https://badge.fury.io/rb/minisketch)
This is a wrapper around [libminisketch](https://github.com/sipa/minisketch) for efficient set reconciliation.
## Installation
### Install libminisketch
Since this library is an FFI wrapper, `libminisketch` must be installed beforehand.
If the library is installed in an unusual location,
the environment variable [`LIBMINISKETCH`] can be used to specify the path to the library.
### Install gem
Add this line to your application's Gemfile:
```ruby
gem 'minisketch'
```
And then execute:
$ bundle install
Or install it yourself as:
$ gem install minisketch
## Usage
Functions exposed in `libminisketch.h` can be accessed using the `Minisketch` class.
```ruby
require 'minisketch'
# Create new sketch
sketch = Minisketch.create(12, 0, 4)
# Add element to sketch
sketch.add(3000)
# or
sketch << 3001
# Serialize
sketch.serialize
# Decode
decoded = sketch.decode
another_sketch = Minisketch.create(12, 0, 4)
another_sketch << 3000
another_sketch << 3002
# Merge another sketch
sketch.merge(another_sketch)
```
This library has been tested based on commit [a571ba2](https://github.com/sipa/minisketch/commit/a571ba20f9dd1accab6a2309d066369878042ca6) of libminisketch.