• Stars
    star
    345
  • Rank 122,750 (Top 3 %)
  • Language
    C
  • License
    MIT License
  • Created over 7 years ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Roaring Bitmaps for Redis

redis-roaring CI/CD

Roaring Bitmaps for Redis

Intro

This project uses the CRoaring library to implement roaring bitmap commands for Redis. These commands can have the same performance as redis' native bitmaps for O(1) operations and be up to 8x faster for O(N) calls, according to microbenchmarks, while consuming less memory than their uncompressed counterparts (benchmark pending).

Pull requests are welcome.

Dependencies

  • CRoaring (bitmap compression library used by this redis module)
  • cmake (build tools needed for compiling the source code)
  • redis (server needed for integration tests)
  • hiredis (redis client library needed for performance tests)
Known limitations
  • This library only works with 32-bit integeres (e.g. counting numbers up to 4294967296)

Getting started

$ git clone https://github.com/aviggiano/redis-roaring.git
$ cd redis-roaring/
$ configure.sh
$ cd dist 
$ ./redis-server ./redis.conf  

then you can open another terminal and use ./redis-cli to connect to the redis server

Docker

It is also possible to run this project as a docker container.

docker run -p 6379:6379 aviggiano/redis-roaring:latest

Tests

Run the test.sh script for unit tests, integration tests and performance tests. The performance tests can take a while, since they run on a real dataset of integer values.

API

The following operations are supported

  • R.SETBIT (same as SETBIT)
  • R.GETBIT (same as GETBIT)
  • R.BITOP (same as BITOP)
  • R.BITCOUNT (same as BITCOUNT without start and end parameters)
  • R.BITPOS (same as BITPOS without start and end parameters)
  • R.SETINTARRAY (create a roaring bitmap from an integer array)
  • R.GETINTARRAY (get an integer array from a roaring bitmap)
  • R.SETBITARRAY (create a roaring bitmap from a bit array string)
  • R.GETBITARRAY (get a bit array string from a roaring bitmap)

Additional commands

  • R.APPENDINTARRAY (append integers to a roaring bitmap)
  • R.RANGEINTARRAY (get an integer array from a roaring bitmap with start and end, so can implements paging)
  • R.SETRANGE (set or append integer range to a roaring bitmap)
  • R.SETFULL (fill up a roaring bitmap in integer)
  • R.STAT (get statistical information of a roaring bitmap)
  • R.OPTIMIZE (optimize a roaring bitmap)
  • R.MIN (get minimal integer from a roaring bitmap, if key is not exists or bitmap is empty, return -1)
  • R.MAX (get maximal integer from a roaring bitmap, if key is not exists or bitmap is empty, return -1)
  • R.DIFF (get difference between two bitmaps)

Missing commands:

API Example

$ redis-cli
# create a roaring bitmap with numbers from 1 to 99
127.0.0.1:6379> R.SETRANGE test 1 100

# get all the numbers as an integer array
127.0.0.1:6379> R.GETINTARRAY test

# fill up the roaring bitmap 
# because you need 2^32*4 bytes memory and a very long time
127.0.0.1:6379> R.SETFULL full

# use `R.RANGEINTARRAY` to get numbers from 100 to 1000 
127.0.0.1:6379> R.RANGEINTARRAY full 100 1000

# append numbers to an existing roaring bitmap
127.0.0.1:6379> R.APPENDINTARRAY test 111 222 3333 456 999999999 9999990

Performance

Tested using CRoaring's census1881 dataset on the travis build 552223545:

OP TIME/OP (us) ST.DEV. (us)
R.SETBIT 31.83 71.85
SETBIT 30.52 74.83
R.GETBIT 30.29 46.99
GETBIT 29.30 38.39
R.BITCOUNT 30.38 0.04
BITCOUNT 169.46 0.95
R.BITPOS 30.62 0.08
BITPOS 55.06 0.77
R.BITOP NOT 103.90 1.71
BITOP NOT 328.14 5.81
R.BITOP AND 40.66 0.47
BITOP AND 433.52 7.98
R.BITOP OR 57.01 2.33
BITOP OR 425.10 7.68
R.BITOP XOR 60.50 2.77
BITOP XOR 415.21 7.51
R.MIN 27.16 0.08
MIN 24.57 0.18
R.MAX 24.62 0.04
MAX 25.85 0.03

More Repositories

1

theauditorbook

The Auditor Book
HTML
231
star
2

security

Security Reviews and Audit Checklists
90
star
3

solidity-audit-report-generator

Solidity Audit Report Generator
TypeScript
82
star
4

qcl

Quantum Computation Language port from http://tph.tuwien.ac.at/~oemer/qcl.html
C++
39
star
5

fuzzer-evaluation

Evaluating fuzzer effectiveness
Solidity
20
star
6

guitar-pro-6

Unofficial Guitar Pro 6 docker image for linux
Shell
18
star
7

circom-mutator

Mutation testing tool for circom
Circom
15
star
8

judgementalist

Judgementalist — judge Sherlock contests faster
TypeScript
13
star
9

fiat-paymaster

Paymaster that funds your transactions on any supported chain through a credit card top up using Paypal
TypeScript
11
star
10

property-based-testing-benchmark

Property-based testing benchmark
Solidity
9
star
11

fuzzy-fyi

We help protocols improve their invariant tests
TypeScript
8
star
12

weth-paymaster

WETH Paymaster for ERC-4337 Account Abstraction Using Alt Mempool
Solidity
7
star
13

account-abstraction-workshop

Account Abstraction Workshop
4
star
14

CoinMarketApp

CoinMarketApp - cryptocurrency price tracker
JavaScript
4
star
15

tcc

Sistema de Recomendação de Produtos para e-Commerces
TeX
3
star
16

the-state-of-invariant-testing

The State of Invariant Testing
2
star
17

rm-logger

Redis module logger
C
2
star
18

fluffy-waddle

Zero-config smart contract vulnerability detection system. This is a project inspired by library.dedaub.com/decompile and it should ONLY be used for research purposes.
TypeScript
2
star
19

talks

Talks
1
star
20

flexbox-for-dummies

JavaScript
1
star
21

votobrasil

Previsão de voto das eleições presidenciais de 2014 no Brasil
Python
1
star
22

selfgpt

Talk to yourself with ChatGPT on WhatsApp
TypeScript
1
star
23

serverless-boilerplate

Serverless Boilerplate based on AWS Lambda/API Gateway and Node.js
JavaScript
1
star
24

openzeppelin-contracts-upgradeable-v5-footguns

OpenZeppelin Contracts 5.0 Footguns
Solidity
1
star