Home

Awesome

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

Known limitations

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

Additional commands

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:

OPTIME/OP (us)ST.DEV. (us)
R.SETBIT31.8371.85
SETBIT30.5274.83
R.GETBIT30.2946.99
GETBIT29.3038.39
R.BITCOUNT30.380.04
BITCOUNT169.460.95
R.BITPOS30.620.08
BITPOS55.060.77
R.BITOP NOT103.901.71
BITOP NOT328.145.81
R.BITOP AND40.660.47
BITOP AND433.527.98
R.BITOP OR57.012.33
BITOP OR425.107.68
R.BITOP XOR60.502.77
BITOP XOR415.217.51
R.MIN27.160.08
MIN24.570.18
R.MAX24.620.04
MAX25.850.03