aviggiano/redis-roaring
Über uns
Roaring Bitmaps for Redis
Daten und AnalyseGemessener Sternzuwachs
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- +1
- in 1 month
- Verlauf wird gesammelt
Nettoänderungen in überlappenden Zeiträumen, keine Tagessummen. Fehlende Messwerte bleiben leer. Sterne zeigen Interesse, nicht Qualität.
README.md
Originalredis-roaring

Redis 8.12 adds native Roaring bitmaps to Redis Open Source. For new deployments, use native Redis bitmaps on Redis 8.12 or later. If you already use the module, migrate from redis-roaring.
redis-roaring is in maintenance mode. Maintenance focuses on critical fixes and migration support.
Intro
redis-roaring is a standalone Redis module that implements Roaring bitmap commands using CRoaring.
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)
Redis Version Compatibility
This module is intended to support Redis 6.2 and 7.0 (the versions we test in CI).
- Redis 7.4+: Full feature support including custom ACL categories, command ACL categories, and command introspection
- Redis 7.2 - 7.3: Command introspection and command ACL categories supported
- Redis 7.0 - 7.1: Command introspection (COMMAND INFO, COMMAND DOCS) supported
- Redis 6.2: Core roaring bitmap functionality supported
The module automatically detects the Redis version at runtime and adjusts its behavior accordingly:
- Command metadata (via
RedisModule_SetCommandInfo) is only registered on Redis 7.0+ - Command ACL categories (via
RedisModule_SetCommandACLCategories) are only set on Redis 7.2+ - Custom ACL categories (via
RedisModule_AddACLCategory) are only registered on Redis 7.4+
All core roaring bitmap commands work on Redis 6.0+.
Getting started
Use these instructions to build the standalone module for an existing deployment.
$ 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
Run the standalone module in a container with Docker.
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.
Migrating to Redis native bitmaps
The migration guide covers application command changes, dry runs, and copying R.* and R64.* bitmap keys with tools/redis-bitmap-migrate.py.
Run the migrator contract tests with:
python3 -m py_compile tools/redis-bitmap-migrate.py tests/integration/redis-bitmap-migrate.py
python3 tests/integration/redis-bitmap-migrate.py
The default test run uses fake RESP servers to verify the public-command
contract. Real Redis-to-native integration tests are enabled when
REDIS_NATIVE_SERVER, REDIS_ROARING_SERVER, and REDIS_ROARING_MODULE point
to built binaries.
Fuzzing
redis-roaring includes fuzz testing using libFuzzer with AddressSanitizer and UndefinedBehaviorSanitizer. Five fuzz targets cover 32-bit operations, 64-bit operations, complex bitwise operations, data parsing, and BITOP key-discovery metadata. Fuzzing runs automatically on every push to master.
Build and run fuzzers locally with ./scripts/build_fuzzers.sh (requires Clang). Run individual fuzzers with ./scripts/run_fuzzer.sh <fuzzer_name> <duration> or all fuzzers with ./scripts/run_all_fuzzers.sh.
See docs/fuzzing.md for complete documentation.
API
See the module command reference for syntax, parameters, and examples.
The following operations are supported
R.SETBIT(same as SETBIT)R.GETBIT(same as GETBIT)R.BITOP(performs bitwise operations and returns the number of set bits in the result)R.BITCOUNT(same as BITCOUNT withoutstartandendparameters)R.BITPOS(same as BITPOS withoutstartandendparameters)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 withstartandend, 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)
64-bit bitmap commands (for handling values beyond 32-bit range)
R64.SETBIT(64-bit version of SETBIT)R64.GETBIT(64-bit version of GETBIT)R64.SETINTARRAY(create a 64-bit roaring bitmap from an integer array)R64.GETINTARRAY(get an integer array from a 64-bit roaring bitmap)R64.RANGEINTARRAY(get an integer array from a 64-bit roaring bitmap withstartandend)R64.APPENDINTARRAY(append integers to a 64-bit roaring bitmap)R64.DIFF(get difference between two 64-bit bitmaps)R64.SETFULL(fill up a 64-bit roaring bitmap)
Missing commands:
R.BITFIELD(same as BITFIELD)
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
These benchmarks compare the standalone module with uncompressed, string-backed Redis bitmaps on CRoaring's census1881 dataset. Performance tests run automatically on pushes to the master branch.
| OP | TIME/OP (us) | ST.DEV. (us) |
|---|---|---|
| R.SETBIT | 26.31 | 7.02 |
| R64.SETBIT | 26.12 | 8.03 |
| SETBIT | 25.82 | 7.69 |
| R.GETBIT | 25.74 | 4.51 |
| R64.GETBIT | 26.09 | 3.74 |
| GETBIT | 25.75 | 3.69 |
| R.BITCOUNT | 28.48 | 0.05 |
| R64.BITCOUNT | 28.64 | 0.04 |
| BITCOUNT | 42.36 | 0.11 |
| R.BITPOS | 28.55 | 0.05 |
| R64.BITPOS | 28.70 | 0.04 |
| BITPOS | 31.72 | 0.11 |
| R.BITOP NOT | 73.44 | 1.35 |
| R64.BITOP NOT | 76.69 | 1.32 |
| BITOP NOT | 175.84 | 1.06 |
| R.BITOP AND | 34.16 | 0.23 |
| R64.BITOP AND | 34.21 | 0.18 |
| BITOP AND | 214.86 | 3.28 |
| R.BITOP OR | 44.88 | 1.05 |
| R64.BITOP OR | 43.98 | 0.64 |
| BITOP OR | 319.23 | 5.25 |
| R.BITOP XOR | 44.32 | 0.93 |
| R64.BITOP XOR | 44.18 | 0.65 |
| BITOP XOR | 189.82 | 2.64 |
| R.BITOP ANDOR | 33.38 | 0.15 |
| R64.BITOP ANDOR | 34.42 | 0.18 |
| BITOP ANDOR | 373.17 | 6.35 |
| R.BITOP ONE | 42.06 | 0.59 |
| R64.BITOP ONE | 47.09 | 0.72 |
| BITOP ONE | 310.34 | 5.07 |
| R.MIN | 30.08 | 0.18 |
| R64.MIN | 29.30 | 0.04 |
| MIN | 28.97 | 0.03 |
| R.MAX | 28.71 | 0.03 |
| R64.MAX | 28.99 | 0.03 |
| MAX | 28.95 | 0.03 |
Ähnliche Projekte entdecken
Wird geladen…