roaringbitmap
roaringbitmap
pg_roaringbitmap : support for Roaring Bitmaps
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 3570 | roaringbitmap | pg_roaringbitmap | 1.1.0 | TYPE | Apache-2.0 | C |
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
--s-d-r | No | Yes | No | Yes | yes | no |
| Relationships | |
|---|---|
| Need By | pgfaceting |
| See Also | rum prefix semver unit pgpdf pglite_fusion md5hash asn1oid |
Packages
| Type | Repo | Version | PG Major Compatibility | Package Pattern | Dependencies |
|---|---|---|---|---|---|
| EXT | PGDG | 1.1.0 | 18 17 16 15 14 | pg_roaringbitmap | - |
| RPM | PGDG | 1.1.0 | 18 17 16 15 14 | pg_roaringbitmap_$v | - |
| DEB | PGDG | 1.1.0 | 18 17 16 15 14 | postgresql-$v-roaringbitmap | - |
| Linux / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
el8.x86_64 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 |
el8.aarch64 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 |
el9.x86_64 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 |
el9.aarch64 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 |
el10.x86_64 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 |
el10.aarch64 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 |
d12.x86_64 | PGDG 1.1.0 | PGDG 1.1.0 | PGDG 1.1.0 | PGDG 1.1.0 | PGDG 1.1.0 |
d12.aarch64 | PGDG 1.1.0 | PGDG 1.1.0 | PGDG 1.1.0 | PGDG 1.1.0 | PGDG 1.1.0 |
d13.x86_64 | PGDG 1.1.0 | PGDG 1.1.0 | PGDG 1.1.0 | PGDG 1.1.0 | PGDG 1.1.0 |
d13.aarch64 | PGDG 1.1.0 | PGDG 1.1.0 | PGDG 1.1.0 | PGDG 1.1.0 | PGDG 1.1.0 |
u22.x86_64 | PGDG 1.1.0 | PGDG 1.1.0 | PGDG 1.1.0 | PGDG 1.1.0 | PGDG 1.1.0 |
u22.aarch64 | PGDG 1.1.0 | PGDG 1.1.0 | PGDG 1.1.0 | PGDG 1.1.0 | PGDG 1.1.0 |
u24.x86_64 | PGDG 1.1.0 | PGDG 1.1.0 | PGDG 1.1.0 | PGDG 1.1.0 | PGDG 1.1.0 |
u24.aarch64 | PGDG 1.1.0 | PGDG 1.1.0 | PGDG 1.1.0 | PGDG 1.1.0 | PGDG 1.1.0 |
Source
pig build pkg pg_roaringbitmap; # build rpmInstall
Make sure PGDG repo available:
pig repo add pgdg -u # add pgdg repo and update cacheInstall this extension with pig:
pig install pg_roaringbitmap; # install via package name, for the active PG version
pig install roaringbitmap; # install by extension name, for the current active PG version
pig install roaringbitmap -v 18; # install for PG 18
pig install roaringbitmap -v 17; # install for PG 17
pig install roaringbitmap -v 16; # install for PG 16
pig install roaringbitmap -v 15; # install for PG 15
pig install roaringbitmap -v 14; # install for PG 14Create this extension with:
CREATE EXTENSION roaringbitmap;Usage
The roaringbitmap extension provides compressed bitmap data types for efficient set operations on integer collections.
CREATE EXTENSION roaringbitmap;
SET roaringbitmap.output_format = 'array';
SELECT rb_build('{1,2,3,4,5}'::int[]); -- {1,2,3,4,5}Data Types
roaringbitmap: 32-bit bitmap, range [0, 4294967296)roaringbitmap64: 64-bit bitmap, range [0, 18446744073709551615)
Output format controlled by: SET roaringbitmap.output_format = 'array' or 'bytea'
Operators
| Operator | Description |
|---|---|
| | Bitwise OR (union) |
& | Bitwise AND (intersection) |
# | Bitwise XOR |
- | Difference (ANDNOT) |
| (with int) | Add element |
- (with int) | Remove element |
@> | Contains |
<@ | Is contained by |
&& | Overlap |
=, <> | Equality/inequality |
Core Functions
-- Construction
SELECT rb_build(ARRAY[1,2,3,4,5]);
-- Analysis
SELECT rb_cardinality(rb_build('{1,2,3}'::int[])); -- 3
SELECT rb_to_array(rb_build('{1,2,3}'::int[])); -- {1,2,3}
SELECT rb_iterate(rb_build('{1,2,3}'::int[])); -- returns set
-- Set operation cardinalities
SELECT rb_and_cardinality(a, b);
SELECT rb_or_cardinality(a, b);
SELECT rb_xor_cardinality(a, b);
SELECT rb_andnot_cardinality(a, b);
-- Range operations
SELECT rb_range(bitmap, 2, 5); -- extract range [2, 5)
SELECT rb_fill(bitmap, 0, 10); -- add range [0, 10)
SELECT rb_clear(bitmap, 3, 7); -- remove range [3, 7)
SELECT rb_flip(bitmap, 0, 10); -- toggle range [0, 10)
-- Element access
SELECT rb_min(bitmap); -- minimum element
SELECT rb_max(bitmap); -- maximum element
SELECT rb_rank(bitmap, 5); -- count elements <= 5
SELECT rb_index(bitmap, 3); -- 0-based position of element
-- Utilities
SELECT rb_is_empty(bitmap);
SELECT rb_jaccard_dist(a, b); -- Jaccard similarityAggregate Functions
SELECT rb_build_agg(id) FROM table; -- build from rows
SELECT rb_or_agg(bitmap) FROM table; -- union all bitmaps
SELECT rb_and_agg(bitmap) FROM table; -- intersect all bitmaps
SELECT rb_xor_agg(bitmap) FROM table; -- XOR all bitmaps64-bit equivalents use the rb64_ prefix.
Last updated on