From ff5783de7bf2eeb6cbc59457fb5189c7820c5568 Mon Sep 17 00:00:00 2001 From: "Shane Michael Mathews (Brandwatch Account)" <21181346+smmathews-bw-boston@users.noreply.github.com> Date: Sun, 8 Oct 2023 13:39:07 -0400 Subject: [PATCH 1/5] Add RunOptimize, to shrink binary size of bitmaps when called (#6) * allow bitmaps to be run optimized (great if you want to make bitmaps smaller, for less WAL and network usage, as well as better cache coherency for large bitmaps) * copy pasta * try try again * no need to specify in and out bytes, can just use one * undeclared * up version to 0.6 * up version to 0.6 * didn't mean to submit this * kick --- META.json | 4 ++-- roaringbitmap--0.5--0.6.sql | 6 ++++++ roaringbitmap.c | 28 ++++++++++++++++++++++++++++ roaringbitmap.control | 2 +- 4 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 roaringbitmap--0.5--0.6.sql diff --git a/META.json b/META.json index d20fff5..95d0a73 100644 --- a/META.json +++ b/META.json @@ -2,7 +2,7 @@ "name": "pg_roaringbitmap", "abstract": "A Roaring Bitmap data type", "description": "This library contains a single PostgreSQL extension, a Roaring Bitmap data type called 'roaringbitmap', along with some convenience opperators and functions for constructing and handling Roaring Bitmap.", - "version": "0.5.4", + "version": "0.6.0", "maintainer": [ "Chen Huajun " ], @@ -12,7 +12,7 @@ "abstract": "A Roaring Bitmap data type", "file": "roaringbitmap--0.5.sql", "docfile": "README.md", - "version": "0.5.4" + "version": "0.6.0" } }, "resources": { diff --git a/roaringbitmap--0.5--0.6.sql b/roaringbitmap--0.5--0.6.sql new file mode 100644 index 0000000..60344c6 --- /dev/null +++ b/roaringbitmap--0.5--0.6.sql @@ -0,0 +1,6 @@ +/* roaringbitmap--0.5--0.6 */ + +CREATE OR REPLACE FUNCTION rb_runoptimize(roaringbitmap) + RETURNS roaringbitmap + AS 'MODULE_PATHNAME', 'rb_runoptimize' + LANGUAGE C STRICT IMMUTABLE PARALLEL SAFE; \ No newline at end of file diff --git a/roaringbitmap.c b/roaringbitmap.c index 82e2101..e3308bf 100644 --- a/roaringbitmap.c +++ b/roaringbitmap.c @@ -2053,3 +2053,31 @@ rb_cardinality_final(PG_FUNCTION_ARGS) { PG_RETURN_INT64(card1); } } + +//bitmap run optimize +PG_FUNCTION_INFO_V1(rb_runoptimize); +Datum rb_runoptimize(PG_FUNCTION_ARGS); + +Datum +rb_runoptimize(PG_FUNCTION_ARGS) { + bytea *serializedbytes = PG_GETARG_BYTEA_P(0); + roaring_bitmap_t *r; + bool optimized; + size_t expectedsize; + + r = roaring_bitmap_portable_deserialize(VARDATA(serializedbytes)); + if (!r) + ereport(ERROR, + (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED), + errmsg("bitmap format is error"))); + + optimized = roaring_bitmap_run_optimize(r); + + expectedsize = roaring_bitmap_portable_size_in_bytes(r); + serializedbytes = (bytea *) palloc(VARHDRSZ + expectedsize); + roaring_bitmap_portable_serialize(r, VARDATA(serializedbytes)); + + roaring_bitmap_free(r); + SET_VARSIZE(serializedbytes, VARHDRSZ + expectedsize); + PG_RETURN_BYTEA_P(serializedbytes); +} diff --git a/roaringbitmap.control b/roaringbitmap.control index ea87ccf..c062434 100644 --- a/roaringbitmap.control +++ b/roaringbitmap.control @@ -1,5 +1,5 @@ # roaringbitmap extension comment = 'support for Roaring Bitmaps' -default_version = '0.5' +default_version = '0.6' module_pathname = '$libdir/roaringbitmap' relocatable = true From 88a5e9ead38ebe1853ce5597fe8fe7a35b3e98cb Mon Sep 17 00:00:00 2001 From: "Shane Michael Mathews (Brandwatch Account)" <21181346+smmathews-bw-boston@users.noreply.github.com> Date: Tue, 10 Oct 2023 07:41:42 -0400 Subject: [PATCH 2/5] now that we've detached our fork, add the attribution to the original author (#5) * now that we've severed the fork, add the attribution to the original author * as suggested, improve the existing attribution's english Co-authored-by: Aidan McMurray <41323054+acmcmurray@users.noreply.github.com> --------- Co-authored-by: Aidan McMurray <41323054+acmcmurray@users.noreply.github.com> --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 136662d..ee15ce8 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # pg_roaringbitmap RoaringBitmap extension for PostgreSQL. -It's initial based on https://github.com/zeromax007/gpdb-roaringbitmap. - +It's initially based on https://github.com/zeromax007/gpdb-roaringbitmap +and later forked from https://github.com/ChenHuajun/pg_roaringbitmap # Introduction Roaring bitmaps are compressed bitmaps which tend to outperform conventional compressed bitmaps such as WAH, EWAH or Concise. In some instances, roaring bitmaps can be hundreds of times faster and they often offer significantly better compression. They can even be faster than uncompressed bitmaps. More information https://github.com/RoaringBitmap/CRoaring . From 6bd0ad49d6a80439cb3a989cec5b914deb70aaf4 Mon Sep 17 00:00:00 2001 From: "Shane Michael Mathews (Brandwatch Account)" <21181346+smmathews-bw-boston@users.noreply.github.com> Date: Tue, 10 Oct 2023 07:44:30 -0400 Subject: [PATCH 3/5] remove support for greenplum and postgres before 10. (#4) --- README.md | 28 - expected/roaringbitmap_gpdb6.out | 2667 ------------------------------ 2 files changed, 2695 deletions(-) delete mode 100644 expected/roaringbitmap_gpdb6.out diff --git a/README.md b/README.md index ee15ce8..76b37dd 100644 --- a/README.md +++ b/README.md @@ -27,34 +27,6 @@ Note:You can use `make -f Makefile_native` instead of` make` to let the compiler make installcheck -# Build on PostgreSQL 9.x or Greenplum 6.0 - -Parallel execution is not supported in PostgreSQL 9.5 and earlier. -If you want to compile on these early PostgreSQL versions or Greenplum 6.0(based on PostgreSQL 9.4), you need to remove the `PARALLEL` keyword from these SQL files. - - cd pg_roaringbitmap - sed 's/PARALLEL SAFE//g' -i roaringbitmap--*.sql - sed -z 's/,[ \r\n]*PARALLEL = SAFE//g' -i roaringbitmap--*.sql - -Then refer to [Build] above for building, such as the steps to build on Greenplum 6.0: - -## Build - - su - gpadmin - make - make install - psql -c "create extension roaringbitmap" - -## Test - - sudo yum install 'perl(Data::Dumper)' - make installcheck - -Since the expected output is based on PostgreSQL 10+, this test will not pass. -Check the difference in the output file. If the execution results are the same, only the execution plan or other content that is not related to pg_roaringbitmap` is different, the test can be considered OK. - - diff results/roaringbitmap.out expected/roaringbitmap_gpdb6.out - # Usage ## about roaringbitmap data type diff --git a/expected/roaringbitmap_gpdb6.out b/expected/roaringbitmap_gpdb6.out deleted file mode 100644 index 921df50..0000000 --- a/expected/roaringbitmap_gpdb6.out +++ /dev/null @@ -1,2667 +0,0 @@ --- --- Test roaringbitmap extension --- -CREATE EXTENSION if not exists roaringbitmap; --- Test input and output -set roaringbitmap.output_format='array'; -set extra_float_digits = 0; -select '{}'::roaringbitmap; - roaringbitmap ---------------- - {} -(1 row) - -select ' { } '::roaringbitmap; - roaringbitmap ---------------- - {} -(1 row) - -select '{ 1 }'::roaringbitmap; - roaringbitmap ---------------- - {1} -(1 row) - -select '{-1,2,555555,-4}'::roaringbitmap; - roaringbitmap ------------------- - {2,555555,-4,-1} -(1 row) - -select '{ -1 , 2 , 555555 , -4 }'::roaringbitmap; - roaringbitmap ------------------- - {2,555555,-4,-1} -(1 row) - -select '{ 1 , -2 , 555555 , -4 }'::roaringbitmap; - roaringbitmap ------------------- - {1,555555,-4,-2} -(1 row) - -select '{ 1 , -2 , 555555 , -4 ,2147483647,-2147483648}'::roaringbitmap; - roaringbitmap ------------------------------------------ - {1,555555,2147483647,-2147483648,-4,-2} -(1 row) - -select roaringbitmap('{ 1 , -2 , 555555 , -4 }'); - roaringbitmap ------------------- - {1,555555,-4,-2} -(1 row) - -set roaringbitmap.output_format='bytea'; -select '{}'::roaringbitmap; - roaringbitmap --------------------- - \x3a30000000000000 -(1 row) - -select '{ -1 , 2 , 555555 , -4 }'::roaringbitmap; - roaringbitmap ------------------------------------------------------------------------------------- - \x3a300000030000000000000008000000ffff01002000000022000000240000000200237afcffffff -(1 row) - -set roaringbitmap.output_format='array'; -select '{}'::roaringbitmap; - roaringbitmap ---------------- - {} -(1 row) - -select '\x3a30000000000000'::roaringbitmap; - roaringbitmap ---------------- - {} -(1 row) - -select '\x3a300000030000000000000008000000ffff01002000000022000000240000000200237afcffffff'::roaringbitmap; - roaringbitmap ------------------- - {2,555555,-4,-1} -(1 row) - --- Exception -select ''::roaringbitmap; -ERROR: malformed bitmap literal -LINE 1: select ''::roaringbitmap; - ^ -select '{'::roaringbitmap; -ERROR: malformed bitmap literal -LINE 1: select '{'::roaringbitmap; - ^ -select '{1'::roaringbitmap; -ERROR: malformed bitmap literal -LINE 1: select '{1'::roaringbitmap; - ^ -select '{1} x'::roaringbitmap; -ERROR: malformed bitmap literal -LINE 1: select '{1} x'::roaringbitmap; - ^ -select '{1x}'::roaringbitmap; -ERROR: malformed bitmap literal -LINE 1: select '{1x}'::roaringbitmap; - ^ -select '{-x}'::roaringbitmap; -ERROR: invalid input syntax for integer: "-x}" -LINE 1: select '{-x}'::roaringbitmap; - ^ -select '{,}'::roaringbitmap; -ERROR: invalid input syntax for integer: ",}" -LINE 1: select '{,}'::roaringbitmap; - ^ -select '{1,}'::roaringbitmap; -ERROR: invalid input syntax for integer: "}" -LINE 1: select '{1,}'::roaringbitmap; - ^ -select '{1,xxx}'::roaringbitmap; -ERROR: invalid input syntax for integer: "xxx}" -LINE 1: select '{1,xxx}'::roaringbitmap; - ^ -select '{1,3'::roaringbitmap; -ERROR: malformed bitmap literal -LINE 1: select '{1,3'::roaringbitmap; - ^ -select '{1,1'::roaringbitmap; -ERROR: malformed bitmap literal -LINE 1: select '{1,1'::roaringbitmap; - ^ -select '{1,-2147483649}'::roaringbitmap; -ERROR: value "-2147483649}" is out of range for type integer -LINE 1: select '{1,-2147483649}'::roaringbitmap; - ^ -select '{2147483648}'::roaringbitmap; -ERROR: value "2147483648}" is out of range for type integer -LINE 1: select '{2147483648}'::roaringbitmap; - ^ --- Test Type cast -select '{}'::roaringbitmap::bytea; - bytea --------------------- - \x3a30000000000000 -(1 row) - -select '{1}'::roaringbitmap::bytea; - bytea ----------------------------------------- - \x3a3000000100000000000000100000000100 -(1 row) - -select '{1,9999}'::roaringbitmap::bytea; - bytea --------------------------------------------- - \x3a30000001000000000001001000000001000f27 -(1 row) - -select '{}'::roaringbitmap::bytea::roaringbitmap; - roaringbitmap ---------------- - {} -(1 row) - -select '{1}'::roaringbitmap::bytea::roaringbitmap; - roaringbitmap ---------------- - {1} -(1 row) - -select '{1,9999,-88888}'::roaringbitmap::bytea::roaringbitmap; - roaringbitmap ------------------ - {1,9999,-88888} -(1 row) - -select roaringbitmap('{1,9999,-88888}'::roaringbitmap::bytea); - roaringbitmap ------------------ - {1,9999,-88888} -(1 row) - --- Exception -select roaringbitmap('\x11'::bytea); -ERROR: bitmap format is error -select '\x11'::bytea::roaringbitmap; -ERROR: bitmap format is error --- Test Opperator -select roaringbitmap('{}') & roaringbitmap('{}'); - ?column? ----------- - {} -(1 row) - -select roaringbitmap('{}') & roaringbitmap('{3,4,5}'); - ?column? ----------- - {} -(1 row) - -select roaringbitmap('{1,2,3}') & roaringbitmap('{}'); - ?column? ----------- - {} -(1 row) - -select roaringbitmap('{1,2,3}') & roaringbitmap('{3,4,5}'); - ?column? ----------- - {3} -(1 row) - -select roaringbitmap('{1,-2,-3}') & roaringbitmap('{-3,-4,5}'); - ?column? ----------- - {-3} -(1 row) - -select roaringbitmap('{}') | roaringbitmap('{}'); - ?column? ----------- - {} -(1 row) - -select roaringbitmap('{}') | roaringbitmap('{3,4,5}'); - ?column? ----------- - {3,4,5} -(1 row) - -select roaringbitmap('{1,2,3}') | roaringbitmap('{}'); - ?column? ----------- - {1,2,3} -(1 row) - -select roaringbitmap('{1,2,3}') | roaringbitmap('{3,4,5}'); - ?column? -------------- - {1,2,3,4,5} -(1 row) - -select roaringbitmap('{1,-2,-3}') | roaringbitmap('{-3,-4,5}'); - ?column? ----------------- - {1,5,-4,-3,-2} -(1 row) - -select roaringbitmap('{}') | 6; - ?column? ----------- - {6} -(1 row) - -select roaringbitmap('{1,2,3}') | 6; - ?column? ------------ - {1,2,3,6} -(1 row) - -select roaringbitmap('{1,2,3}') | 1; - ?column? ----------- - {1,2,3} -(1 row) - -select roaringbitmap('{1,2,3}') | -1; - ?column? ------------- - {1,2,3,-1} -(1 row) - -select roaringbitmap('{-1,-2,3}') | -1; - ?column? ------------ - {3,-2,-1} -(1 row) - -select 6 | roaringbitmap('{}'); - ?column? ----------- - {6} -(1 row) - -select 6 | roaringbitmap('{1,2,3}'); - ?column? ------------ - {1,2,3,6} -(1 row) - -select 1 | roaringbitmap('{1,2,3}'); - ?column? ----------- - {1,2,3} -(1 row) - -select -1 | roaringbitmap('{1,2,3}'); - ?column? ------------- - {1,2,3,-1} -(1 row) - -select -1 | roaringbitmap('{-1,-2,3}'); - ?column? ------------ - {3,-2,-1} -(1 row) - -select roaringbitmap('{}') # roaringbitmap('{}'); - ?column? ----------- - {} -(1 row) - -select roaringbitmap('{}') # roaringbitmap('{3,4,5}'); - ?column? ----------- - {3,4,5} -(1 row) - -select roaringbitmap('{1,2,3}') # roaringbitmap('{}'); - ?column? ----------- - {1,2,3} -(1 row) - -select roaringbitmap('{1,2,3}') # roaringbitmap('{3,4,5}'); - ?column? ------------ - {1,2,4,5} -(1 row) - -select roaringbitmap('{1,-2,-3}') # roaringbitmap('{-3,-4,5}'); - ?column? -------------- - {1,5,-4,-2} -(1 row) - -select roaringbitmap('{}') - roaringbitmap('{}'); - ?column? ----------- - {} -(1 row) - -select roaringbitmap('{}') - roaringbitmap('{3,4,5}'); - ?column? ----------- - {} -(1 row) - -select roaringbitmap('{1,2,3}') - roaringbitmap('{}'); - ?column? ----------- - {1,2,3} -(1 row) - -select roaringbitmap('{1,2,3}') - roaringbitmap('{3,4,5}'); - ?column? ----------- - {1,2} -(1 row) - -select roaringbitmap('{1,-2,-3}') - roaringbitmap('{-3,-4,5}'); - ?column? ----------- - {1,-2} -(1 row) - -select roaringbitmap('{}') - 3; - ?column? ----------- - {} -(1 row) - -select roaringbitmap('{1,2,3}') - 3; - ?column? ----------- - {1,2} -(1 row) - -select roaringbitmap('{1,2,3}') - 1; - ?column? ----------- - {2,3} -(1 row) - -select roaringbitmap('{1,2,3}') - -1; - ?column? ----------- - {1,2,3} -(1 row) - -select roaringbitmap('{-1,-2,3}') - -1; - ?column? ----------- - {3,-2} -(1 row) - -select roaringbitmap('{}') << 2; - ?column? ----------- - {} -(1 row) - -select roaringbitmap('{-2,-1,0,1,2,3,2147483647,-2147483648}') << 2; - ?column? ------------------------------------ - {0,1,2147483645,2147483646,-4,-3} -(1 row) - -select roaringbitmap('{-2,-1,0,1,2,3,2147483647,-2147483648}') << 1; - ?column? -------------------------------------- - {0,1,2,2147483646,2147483647,-3,-2} -(1 row) - -select roaringbitmap('{-2,-1,0,1,2,3,2147483647,-2147483648}') << 0; - ?column? ----------------------------------------- - {0,1,2,3,2147483647,-2147483648,-2,-1} -(1 row) - -select roaringbitmap('{-2,-1,0,1,2,3,2147483647,-2147483648}') << -1; - ?column? --------------------------------------- - {1,2,3,4,-2147483648,-2147483647,-1} -(1 row) - -select roaringbitmap('{-2,-1,0,1,2,3,2147483647,-2147483648}') << -2; - ?column? ------------------------------------ - {2,3,4,5,-2147483647,-2147483646} -(1 row) - -select roaringbitmap('{-2,-1,0,1,2,3,2147483647,-2147483648}') << 4294967295; - ?column? ----------- - {0} -(1 row) - -select roaringbitmap('{-2,-1,0,1,2,3,2147483647,-2147483648}') << 4294967296; - ?column? ----------- - {} -(1 row) - -select roaringbitmap('{-2,-1,0,1,2,3,2147483647,-2147483648}') << -4294967295; - ?column? ----------- - {-1} -(1 row) - -select roaringbitmap('{-2,-1,0,1,2,3,2147483647,-2147483648}') << -4294967296; - ?column? ----------- - {} -(1 row) - -select roaringbitmap('{}') >> 2; - ?column? ----------- - {} -(1 row) - -select roaringbitmap('{-2,-1,0,1,2,3,2147483647,-2147483648}') >> 2; - ?column? ------------------------------------ - {2,3,4,5,-2147483647,-2147483646} -(1 row) - -select roaringbitmap('{-2,-1,0,1,2,3,2147483647,-2147483648}') >> 1; - ?column? --------------------------------------- - {1,2,3,4,-2147483648,-2147483647,-1} -(1 row) - -select roaringbitmap('{-2,-1,0,1,2,3,2147483647,-2147483648}') >> 0; - ?column? ----------------------------------------- - {0,1,2,3,2147483647,-2147483648,-2,-1} -(1 row) - -select roaringbitmap('{-2,-1,0,1,2,3,2147483647,-2147483648}') >> -1; - ?column? -------------------------------------- - {0,1,2,2147483646,2147483647,-3,-2} -(1 row) - -select roaringbitmap('{-2,-1,0,1,2,3,2147483647,-2147483648}') >> -2; - ?column? ------------------------------------ - {0,1,2147483645,2147483646,-4,-3} -(1 row) - -select roaringbitmap('{-2,-1,0,1,2,3,2147483647,-2147483648}') >> 4294967295; - ?column? ----------- - {-1} -(1 row) - -select roaringbitmap('{-2,-1,0,1,2,3,2147483647,-2147483648}') >> 4294967296; - ?column? ----------- - {} -(1 row) - -select roaringbitmap('{-2,-1,0,1,2,3,2147483647,-2147483648}') >> -4294967295; - ?column? ----------- - {0} -(1 row) - -select roaringbitmap('{-2,-1,0,1,2,3,2147483647,-2147483648}') >> -4294967296; - ?column? ----------- - {} -(1 row) - -select roaringbitmap('{}') @> roaringbitmap('{}'); - ?column? ----------- - t -(1 row) - -select roaringbitmap('{}') @> roaringbitmap('{3,4,5}'); - ?column? ----------- - f -(1 row) - -select roaringbitmap('{1,2,3}') @> roaringbitmap('{}'); - ?column? ----------- - t -(1 row) - -select roaringbitmap('{1,2,3}') @> roaringbitmap('{3,4,5}'); - ?column? ----------- - f -(1 row) - -select roaringbitmap('{1,2,3}') @> roaringbitmap('{3,2}'); - ?column? ----------- - t -(1 row) - -select roaringbitmap('{1,-2,-3}') @> roaringbitmap('{-3,1}'); - ?column? ----------- - t -(1 row) - -select roaringbitmap('{}') @> 2; - ?column? ----------- - f -(1 row) - -select roaringbitmap('{1,2,3}') @> 20; - ?column? ----------- - f -(1 row) - -select roaringbitmap('{1,2,3}') @> 1; - ?column? ----------- - t -(1 row) - -select roaringbitmap('{1,2,3}') @> -1; - ?column? ----------- - f -(1 row) - -select roaringbitmap('{-1,-2,3}') @> -1; - ?column? ----------- - t -(1 row) - -select roaringbitmap('{}') <@ roaringbitmap('{}'); - ?column? ----------- - t -(1 row) - -select roaringbitmap('{}') <@ roaringbitmap('{3,4,5}'); - ?column? ----------- - t -(1 row) - -select roaringbitmap('{1,2,3}') <@ roaringbitmap('{}'); - ?column? ----------- - f -(1 row) - -select roaringbitmap('{1,2,3}') <@ roaringbitmap('{3,4,5}'); - ?column? ----------- - f -(1 row) - -select roaringbitmap('{2,3}') <@ roaringbitmap('{1,3,2}'); - ?column? ----------- - t -(1 row) - -select roaringbitmap('{1,-3}') <@ roaringbitmap('{-3,1,1000}'); - ?column? ----------- - t -(1 row) - -select 6 <@ roaringbitmap('{}'); - ?column? ----------- - f -(1 row) - -select 3 <@ roaringbitmap('{1,2,3}'); - ?column? ----------- - t -(1 row) - -select 1 <@ roaringbitmap('{1,2,3}'); - ?column? ----------- - t -(1 row) - -select -1 <@ roaringbitmap('{1,2,3}'); - ?column? ----------- - f -(1 row) - -select -1 <@ roaringbitmap('{-1,-2,3}'); - ?column? ----------- - t -(1 row) - -select roaringbitmap('{}') && roaringbitmap('{}'); - ?column? ----------- - f -(1 row) - -select roaringbitmap('{}') && roaringbitmap('{3,4,5}'); - ?column? ----------- - f -(1 row) - -select roaringbitmap('{1,2,3}') && roaringbitmap('{}'); - ?column? ----------- - f -(1 row) - -select roaringbitmap('{1,2,3}') && roaringbitmap('{3,4,5}'); - ?column? ----------- - t -(1 row) - -select roaringbitmap('{1,-2,-3}') && roaringbitmap('{-3,-4,5}'); - ?column? ----------- - t -(1 row) - -select roaringbitmap('{}') = roaringbitmap('{}'); - ?column? ----------- - t -(1 row) - -select roaringbitmap('{}') = roaringbitmap('{3,4,5}'); - ?column? ----------- - f -(1 row) - -select roaringbitmap('{1,2,3}') = roaringbitmap('{}'); - ?column? ----------- - f -(1 row) - -select roaringbitmap('{1,2,3}') = roaringbitmap('{3,1,2}'); - ?column? ----------- - t -(1 row) - -select roaringbitmap('{1,-2,-3}') = roaringbitmap('{-3,-4,5}'); - ?column? ----------- - f -(1 row) - -select roaringbitmap('{}') <> roaringbitmap('{}'); - ?column? ----------- - f -(1 row) - -select roaringbitmap('{}') <> roaringbitmap('{3,4,5}'); - ?column? ----------- - t -(1 row) - -select roaringbitmap('{1,2,3}') <> roaringbitmap('{}'); - ?column? ----------- - t -(1 row) - -select roaringbitmap('{1,2,3}') <> roaringbitmap('{3,1,2}'); - ?column? ----------- - f -(1 row) - -select roaringbitmap('{1,-2,-3}') <> roaringbitmap('{-3,-4,5}'); - ?column? ----------- - t -(1 row) - --- Test the functions with one bitmap variable -select rb_build(NULL); - rb_build ----------- - -(1 row) - -select rb_build('{}'::int[]); - rb_build ----------- - {} -(1 row) - -select rb_build('{1}'::int[]); - rb_build ----------- - {1} -(1 row) - -select rb_build('{-1,2,555555,-4}'::int[]); - rb_build ------------------- - {2,555555,-4,-1} -(1 row) - -select rb_build('{1,-2,555555,-4,2147483647,-2147483648}'::int[]); - rb_build ------------------------------------------ - {1,555555,2147483647,-2147483648,-4,-2} -(1 row) - -select rb_to_array(NULL); - rb_to_array -------------- - -(1 row) - -select rb_to_array('{}'::roaringbitmap); - rb_to_array -------------- - {} -(1 row) - -select rb_to_array('{1}'::roaringbitmap); - rb_to_array -------------- - {1} -(1 row) - -select rb_to_array('{-1,2,555555,-4}'::roaringbitmap); - rb_to_array ------------------- - {2,555555,-4,-1} -(1 row) - -select rb_to_array('{1,-2,555555,-4,2147483647,-2147483648}'::roaringbitmap); - rb_to_array ------------------------------------------ - {1,555555,2147483647,-2147483648,-4,-2} -(1 row) - -select rb_is_empty(NULL); - rb_is_empty -------------- - -(1 row) - -select rb_is_empty('{}'); - rb_is_empty -------------- - t -(1 row) - -select rb_is_empty('{1}'); - rb_is_empty -------------- - f -(1 row) - -select rb_is_empty('{1,10,100}'); - rb_is_empty -------------- - f -(1 row) - -select rb_cardinality(NULL); - rb_cardinality ----------------- - -(1 row) - -select rb_cardinality('{}'); - rb_cardinality ----------------- - 0 -(1 row) - -select rb_cardinality('{1}'); - rb_cardinality ----------------- - 1 -(1 row) - -select rb_cardinality('{1,10,100}'); - rb_cardinality ----------------- - 3 -(1 row) - -select rb_max(NULL); - rb_max --------- - -(1 row) - -select rb_max('{}'); - rb_max --------- - -(1 row) - -select rb_max('{1}'); - rb_max --------- - 1 -(1 row) - -select rb_max('{1,10,100}'); - rb_max --------- - 100 -(1 row) - -select rb_max('{1,10,100,2147483647,-2147483648,-1}'); - rb_max --------- - -1 -(1 row) - -select rb_min(NULL); - rb_min --------- - -(1 row) - -select rb_min('{}'); - rb_min --------- - -(1 row) - -select rb_min('{1}'); - rb_min --------- - 1 -(1 row) - -select rb_min('{1,10,100}'); - rb_min --------- - 1 -(1 row) - -select rb_min('{1,10,100,2147483647,-2147483648,-1}'); - rb_min --------- - 1 -(1 row) - -select rb_iterate(NULL); - rb_iterate ------------- -(0 rows) - -select rb_iterate('{}'); - rb_iterate ------------- -(0 rows) - -select rb_iterate('{1}'); - rb_iterate ------------- - 1 -(1 row) - -select rb_iterate('{1,10,100}'); - rb_iterate ------------- - 1 - 10 - 100 -(3 rows) - -select rb_iterate('{1,10,100,2147483647,-2147483648,-1}'); - rb_iterate -------------- - 1 - 10 - 100 - 2147483647 - -2147483648 - -1 -(6 rows) - --- Test the functions with two bitmap variables -select rb_and(NULL,'{1,10,100}'); - rb_and --------- - -(1 row) - -select rb_and('{1,10,100}',NULL); - rb_and --------- - -(1 row) - -select rb_and('{}','{1,10,100}'); - rb_and --------- - {} -(1 row) - -select rb_and('{1,10,100}','{}'); - rb_and --------- - {} -(1 row) - -select rb_and('{2}','{1,10,100}'); - rb_and --------- - {} -(1 row) - -select rb_and('{1,2,10}','{1,10,100}'); - rb_and --------- - {1,10} -(1 row) - -select rb_and('{1,10}','{1,10,100}'); - rb_and --------- - {1,10} -(1 row) - -select rb_and_cardinality(NULL,'{1,10,100}'); - rb_and_cardinality --------------------- - -(1 row) - -select rb_and_cardinality('{1,10,100}',NULL); - rb_and_cardinality --------------------- - -(1 row) - -select rb_and_cardinality('{}','{1,10,100}'); - rb_and_cardinality --------------------- - 0 -(1 row) - -select rb_and_cardinality('{1,10,100}','{}'); - rb_and_cardinality --------------------- - 0 -(1 row) - -select rb_and_cardinality('{2}','{1,10,100}'); - rb_and_cardinality --------------------- - 0 -(1 row) - -select rb_and_cardinality('{1,2,10}','{1,10,100}'); - rb_and_cardinality --------------------- - 2 -(1 row) - -select rb_and_cardinality('{1,10}','{1,10,100}'); - rb_and_cardinality --------------------- - 2 -(1 row) - -select rb_or(NULL,'{1,10,100}'); - rb_or -------- - -(1 row) - -select rb_or('{1,10,100}',NULL); - rb_or -------- - -(1 row) - -select rb_or('{}','{1,10,100}'); - rb_or ------------- - {1,10,100} -(1 row) - -select rb_or('{1,10,100}','{}'); - rb_or ------------- - {1,10,100} -(1 row) - -select rb_or('{2}','{1,10,100}'); - rb_or --------------- - {1,2,10,100} -(1 row) - -select rb_or('{1,2,10}','{1,10,100}'); - rb_or --------------- - {1,2,10,100} -(1 row) - -select rb_or('{1,10}','{1,10,100}'); - rb_or ------------- - {1,10,100} -(1 row) - -select rb_or_cardinality(NULL,'{1,10,100}'); - rb_or_cardinality -------------------- - -(1 row) - -select rb_or_cardinality('{1,10,100}',NULL); - rb_or_cardinality -------------------- - -(1 row) - -select rb_or_cardinality('{}','{1,10,100}'); - rb_or_cardinality -------------------- - 3 -(1 row) - -select rb_or_cardinality('{1,10,100}','{}'); - rb_or_cardinality -------------------- - 3 -(1 row) - -select rb_or_cardinality('{2}','{1,10,100}'); - rb_or_cardinality -------------------- - 4 -(1 row) - -select rb_or_cardinality('{1,2,10}','{1,10,100}'); - rb_or_cardinality -------------------- - 4 -(1 row) - -select rb_or_cardinality('{1,10}','{1,10,100}'); - rb_or_cardinality -------------------- - 3 -(1 row) - -select rb_xor(NULL,'{1,10,100}'); - rb_xor --------- - -(1 row) - -select rb_xor('{1,10,100}',NULL); - rb_xor --------- - -(1 row) - -select rb_xor('{}','{1,10,100}'); - rb_xor ------------- - {1,10,100} -(1 row) - -select rb_xor('{1,10,100}','{}'); - rb_xor ------------- - {1,10,100} -(1 row) - -select rb_xor('{2}','{1,10,100}'); - rb_xor --------------- - {1,2,10,100} -(1 row) - -select rb_xor('{1,2,10}','{1,10,100}'); - rb_xor ---------- - {2,100} -(1 row) - -select rb_xor('{1,10}','{1,10,100}'); - rb_xor --------- - {100} -(1 row) - -select rb_xor_cardinality(NULL,'{1,10,100}'); - rb_xor_cardinality --------------------- - -(1 row) - -select rb_xor_cardinality('{1,10,100}',NULL); - rb_xor_cardinality --------------------- - -(1 row) - -select rb_xor_cardinality('{}','{1,10,100}'); - rb_xor_cardinality --------------------- - 3 -(1 row) - -select rb_xor_cardinality('{1,10,100}','{}'); - rb_xor_cardinality --------------------- - 3 -(1 row) - -select rb_xor_cardinality('{2}','{1,10,100}'); - rb_xor_cardinality --------------------- - 4 -(1 row) - -select rb_xor_cardinality('{1,2,10}','{1,10,100}'); - rb_xor_cardinality --------------------- - 2 -(1 row) - -select rb_xor_cardinality('{1,10}','{1,10,100}'); - rb_xor_cardinality --------------------- - 1 -(1 row) - -select rb_equals(NULL,'{1,10,100}'); - rb_equals ------------ - -(1 row) - -select rb_equals('{1,10,100}',NULL); - rb_equals ------------ - -(1 row) - -select rb_equals('{}','{1,10,100}'); - rb_equals ------------ - f -(1 row) - -select rb_equals('{1,10,100}','{}'); - rb_equals ------------ - f -(1 row) - -select rb_equals('{2}','{1,10,100}'); - rb_equals ------------ - f -(1 row) - -select rb_equals('{1,2,10}','{1,10,100}'); - rb_equals ------------ - f -(1 row) - -select rb_equals('{1,10}','{1,10,100}'); - rb_equals ------------ - f -(1 row) - -select rb_equals('{1,10,100}','{1,10,100}'); - rb_equals ------------ - t -(1 row) - -select rb_equals('{1,10,100,10}','{1,100,10}'); - rb_equals ------------ - t -(1 row) - -select rb_intersect(NULL,'{1,10,100}'); - rb_intersect --------------- - -(1 row) - -select rb_intersect('{1,10,100}',NULL); - rb_intersect --------------- - -(1 row) - -select rb_intersect('{}','{1,10,100}'); - rb_intersect --------------- - f -(1 row) - -select rb_intersect('{1,10,100}','{}'); - rb_intersect --------------- - f -(1 row) - -select rb_intersect('{2}','{1,10,100}'); - rb_intersect --------------- - f -(1 row) - -select rb_intersect('{1,2,10}','{1,10,100}'); - rb_intersect --------------- - t -(1 row) - -select rb_intersect('{1,10}','{1,10,100}'); - rb_intersect --------------- - t -(1 row) - -select rb_intersect('{1,10,100}','{1,10,100}'); - rb_intersect --------------- - t -(1 row) - -select rb_intersect('{1,10,100,10}','{1,100,10}'); - rb_intersect --------------- - t -(1 row) - -select rb_andnot(NULL,'{1,10,100}'); - rb_andnot ------------ - -(1 row) - -select rb_andnot('{1,10,100}',NULL); - rb_andnot ------------ - -(1 row) - -select rb_andnot('{}','{1,10,100}'); - rb_andnot ------------ - {} -(1 row) - -select rb_andnot('{1,10,100}','{}'); - rb_andnot ------------- - {1,10,100} -(1 row) - -select rb_andnot('{2}','{1,10,100}'); - rb_andnot ------------ - {2} -(1 row) - -select rb_andnot('{1,2,10}','{1,10,100}'); - rb_andnot ------------ - {2} -(1 row) - -select rb_andnot('{1,10}','{1,10,100}'); - rb_andnot ------------ - {} -(1 row) - -select rb_andnot('{1,10,100}','{1,10,100}'); - rb_andnot ------------ - {} -(1 row) - -select rb_andnot('{1,10,100,10}','{1,100,10}'); - rb_andnot ------------ - {} -(1 row) - -select rb_andnot_cardinality(NULL,'{1,10,100}'); - rb_andnot_cardinality ------------------------ - -(1 row) - -select rb_andnot_cardinality('{1,10,100}',NULL); - rb_andnot_cardinality ------------------------ - -(1 row) - -select rb_andnot_cardinality('{}','{1,10,100}'); - rb_andnot_cardinality ------------------------ - 0 -(1 row) - -select rb_andnot_cardinality('{1,10,100}','{}'); - rb_andnot_cardinality ------------------------ - 3 -(1 row) - -select rb_andnot_cardinality('{2}','{1,10,100}'); - rb_andnot_cardinality ------------------------ - 1 -(1 row) - -select rb_andnot_cardinality('{1,2,10}','{1,10,100}'); - rb_andnot_cardinality ------------------------ - 1 -(1 row) - -select rb_andnot_cardinality('{1,10}','{1,10,100}'); - rb_andnot_cardinality ------------------------ - 0 -(1 row) - -select rb_andnot_cardinality('{1,10,100}','{1,10,100}'); - rb_andnot_cardinality ------------------------ - 0 -(1 row) - -select rb_andnot_cardinality('{1,10,100,10}','{1,100,10}'); - rb_andnot_cardinality ------------------------ - 0 -(1 row) - -select rb_jaccard_dist(NULL,'{1,10,100}'); - rb_jaccard_dist ------------------ - -(1 row) - -select rb_jaccard_dist('{1,10,100}',NULL); - rb_jaccard_dist ------------------ - -(1 row) - -select rb_jaccard_dist('{}','{1,10,100}'); - rb_jaccard_dist ------------------ - 0 -(1 row) - -select rb_jaccard_dist('{1,10,100}','{}'); - rb_jaccard_dist ------------------ - 0 -(1 row) - -select rb_jaccard_dist('{2}','{1,10,100}'); - rb_jaccard_dist ------------------ - 0 -(1 row) - -select rb_jaccard_dist('{1,2,10}','{1,10,100}'); - rb_jaccard_dist ------------------ - 0.5 -(1 row) - -select rb_jaccard_dist('{1,10,11,12}','{1,10,100}'); - rb_jaccard_dist ------------------ - 0.4 -(1 row) - -select rb_jaccard_dist('{1,10,100}','{1,10,11,12}'); - rb_jaccard_dist ------------------ - 0.4 -(1 row) - -select rb_jaccard_dist('{1,10,100}','{1,10,100}'); - rb_jaccard_dist ------------------ - 1 -(1 row) - -select rb_jaccard_dist('{1,10,-100}','{1,10,-100}'); - rb_jaccard_dist ------------------ - 1 -(1 row) - -select rb_jaccard_dist('{1,10,100}','{1,10,-100}'); - rb_jaccard_dist ------------------ - 0.5 -(1 row) - --- Test other functions -select rb_rank(NULL,0); - rb_rank ---------- - -(1 row) - -select rb_rank('{}',0); - rb_rank ---------- - 0 -(1 row) - -select rb_rank('{1,10,100}',0); - rb_rank ---------- - 0 -(1 row) - -select rb_rank('{1,10,100}',1); - rb_rank ---------- - 1 -(1 row) - -select rb_rank('{1,10,100}',99); - rb_rank ---------- - 2 -(1 row) - -select rb_rank('{1,10,100}',100); - rb_rank ---------- - 3 -(1 row) - -select rb_rank('{1,10,100}',101); - rb_rank ---------- - 3 -(1 row) - -select rb_rank('{1,10,100,-3,-1}',-2); - rb_rank ---------- - 4 -(1 row) - -select rb_remove(NULL,0); - rb_remove ------------ - -(1 row) - -select rb_remove('{}',0); - rb_remove ------------ - {} -(1 row) - -select rb_remove('{1}',1); - rb_remove ------------ - {} -(1 row) - -select rb_remove('{1,10,100}',0); - rb_remove ------------- - {1,10,100} -(1 row) - -select rb_remove('{1,10,100}',1); - rb_remove ------------ - {10,100} -(1 row) - -select rb_remove('{1,10,100}',99); - rb_remove ------------- - {1,10,100} -(1 row) - -select rb_fill(NULL,0,0); - rb_fill ---------- - -(1 row) - -select rb_fill('{}',0,0); - rb_fill ---------- - {} -(1 row) - -select rb_fill('{}',0,1); - rb_fill ---------- - {0} -(1 row) - -select rb_fill('{}',0,2); - rb_fill ---------- - {0,1} -(1 row) - -select rb_fill('{1,10,100}',10,10); - rb_fill ------------- - {1,10,100} -(1 row) - -select rb_fill('{1,10,100}',10,11); - rb_fill ------------- - {1,10,100} -(1 row) - -select rb_fill('{1,10,100}',10,12); - rb_fill ---------------- - {1,10,11,100} -(1 row) - -select rb_fill('{1,10,100}',10,13); - rb_fill ------------------- - {1,10,11,12,100} -(1 row) - -select rb_fill('{1,10,100}',10,20); - rb_fill ---------------------------------------- - {1,10,11,12,13,14,15,16,17,18,19,100} -(1 row) - -select rb_fill('{1,10,100}',0,-1); - rb_fill ------------- - {1,10,100} -(1 row) - -select rb_cardinality(rb_fill('{1,10,100}',2,1000000000)); - rb_cardinality ----------------- - 999999999 -(1 row) - -select rb_cardinality(rb_fill('{1,10,100}',-1,5000000000)); - rb_cardinality ----------------- - 4294967296 -(1 row) - -select rb_index(NULL,3); - rb_index ----------- - -(1 row) - -select rb_index('{1,2,3}',NULL); - rb_index ----------- - -(1 row) - -select rb_index('{}',3); - rb_index ----------- - -1 -(1 row) - -select rb_index('{1}',3); - rb_index ----------- - -1 -(1 row) - -select rb_index('{1}',1); - rb_index ----------- - 0 -(1 row) - -select rb_index('{1,10,100}',10); - rb_index ----------- - 1 -(1 row) - -select rb_index('{1,10,100}',99); - rb_index ----------- - -1 -(1 row) - -select rb_index('{1,10,-100}',-100); - rb_index ----------- - 2 -(1 row) - -select rb_clear(NULL,0,10); - rb_clear ----------- - -(1 row) - -select rb_clear('{}',0,10); - rb_clear ----------- - {} -(1 row) - -select rb_clear('{1,10,100}',0,10); - rb_clear ----------- - {10,100} -(1 row) - -select rb_clear('{1,10,100}',3,3); - rb_clear ------------- - {1,10,100} -(1 row) - -select rb_clear('{1,10,100}',-3,3); - rb_clear ----------- - {10,100} -(1 row) - -select rb_clear('{1,10,100}',0,-1); - rb_clear ------------- - {1,10,100} -(1 row) - -select rb_clear('{1,10,100}',9,9); - rb_clear ------------- - {1,10,100} -(1 row) - -select rb_clear('{1,10,100}',2,1000000000); - rb_clear ----------- - {1} -(1 row) - -select rb_clear('{0,1,10,100,-2,-1}',1,4294967295); - rb_clear ----------- - {0,-1} -(1 row) - -select rb_clear('{0,1,10,100,-2,-1}',0,4294967296); - rb_clear ----------- - {} -(1 row) - -select rb_flip(NULL,0,10); - rb_flip ---------- - -(1 row) - -select rb_flip('{}',0,10); - rb_flip ------------------------ - {0,1,2,3,4,5,6,7,8,9} -(1 row) - -select rb_flip('{1,10,100}',9,100); - rb_flip --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - {1,9,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100} -(1 row) - -select rb_flip('{1,10,100}',10,101); - rb_flip --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - {1,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99} -(1 row) - -select rb_flip('{1,10,100}',-3,3); - rb_flip --------------- - {0,2,10,100} -(1 row) - -select rb_flip('{1,10,100}',0,-1); - rb_flip ------------- - {1,10,100} -(1 row) - -select rb_flip('{1,10,100}',9,9); - rb_flip ------------- - {1,10,100} -(1 row) - -select rb_cardinality(rb_flip('{1,10,100}',2,1000000000)); - rb_cardinality ----------------- - 999999997 -(1 row) - -select rb_cardinality(rb_flip('{1,10,100}',-1,5000000000)); - rb_cardinality ----------------- - 4294967293 -(1 row) - -select rb_range(NULL,0,10); - rb_range ----------- - -(1 row) - -select rb_range('{}',0,10); - rb_range ----------- - {} -(1 row) - -select rb_range('{1,10,100}',0,10); - rb_range ----------- - {1} -(1 row) - -select rb_range('{1,10,100}',3,3); - rb_range ----------- - {} -(1 row) - -select rb_range('{1,10,100}',-3,3); - rb_range ----------- - {1} -(1 row) - -select rb_range('{1,10,100}',0,-1); - rb_range ----------- - {} -(1 row) - -select rb_range('{1,10,100}',9,9); - rb_range ----------- - {} -(1 row) - -select rb_range('{1,10,100}',2,1000000000); - rb_range ----------- - {10,100} -(1 row) - -select rb_range('{0,1,10,100,-2,-1}',1,4294967295); - rb_range ---------------- - {1,10,100,-2} -(1 row) - -select rb_range('{0,1,10,100,-2,-1}',0,4294967296); - rb_range --------------------- - {0,1,10,100,-2,-1} -(1 row) - -select rb_range_cardinality(NULL,0,10); - rb_range_cardinality ----------------------- - -(1 row) - -select rb_range_cardinality('{}',0,10); - rb_range_cardinality ----------------------- - 0 -(1 row) - -select rb_range_cardinality('{1,10,100}',0,10); - rb_range_cardinality ----------------------- - 1 -(1 row) - -select rb_range_cardinality('{1,10,100}',3,3); - rb_range_cardinality ----------------------- - 0 -(1 row) - -select rb_range_cardinality('{1,10,100}',-3,3); - rb_range_cardinality ----------------------- - 1 -(1 row) - -select rb_range_cardinality('{1,10,100}',0,-1); - rb_range_cardinality ----------------------- - 0 -(1 row) - -select rb_range_cardinality('{1,10,100}',9,9); - rb_range_cardinality ----------------------- - 0 -(1 row) - -select rb_range_cardinality('{1,10,100}',2,1000000000); - rb_range_cardinality ----------------------- - 2 -(1 row) - -select rb_range_cardinality('{0,1,10,100,-2,-1}',1,4294967295); - rb_range_cardinality ----------------------- - 4 -(1 row) - -select rb_range_cardinality('{0,1,10,100,-2,-1}',0,4294967296); - rb_range_cardinality ----------------------- - 6 -(1 row) - -select rb_select(NULL,10); - rb_select ------------ - -(1 row) - -select rb_select('{}',10); - rb_select ------------ - {} -(1 row) - -select rb_select('{0,1,2,10,100,1000,2147483647,-2147483648,-2,-1}',0); - rb_select ------------ - {} -(1 row) - -select rb_select('{0,1,2,10,100,1000,2147483647,-2147483648,-2,-1}',1); - rb_select ------------ - {0} -(1 row) - -select rb_select('{0,1,2,10,100,1000,2147483647,-2147483648,-2,-1}',2); - rb_select ------------ - {0,1} -(1 row) - -select rb_select('{0,1,2,10,100,1000,2147483647,-2147483648,-2,-1}',2,0); - rb_select ------------ - {0,1} -(1 row) - -select rb_select('{0,1,2,10,100,1000,2147483647,-2147483648,-2,-1}',2,1); - rb_select ------------ - {1,2} -(1 row) - -select rb_select('{0,1,2,10,100,1000,2147483647,-2147483648,-2,-1}',2,1,true); - rb_select ------------------- - {-2147483648,-2} -(1 row) - -select rb_select('{0,1,2,10,100,1000,2147483647,-2147483648,-2,-1}',2,1,true,9); - rb_select ------------------- - {-2147483648,-2} -(1 row) - -select rb_select('{0,1,2,10,100,1000,2147483647,-2147483648,-2,-1}',2,1,true,9,4294967295); - rb_select --------------------------- - {2147483647,-2147483648} -(1 row) - -select rb_select('{0,1,2,10,100,1000,2147483647,-2147483648,-2,-1}',2,1,false); - rb_select ------------ - {1,2} -(1 row) - -select rb_select('{0,1,2,10,100,1000,2147483647,-2147483648,-2,-1}',2,1,false,9); - rb_select ------------- - {100,1000} -(1 row) - -select rb_select('{0,1,2,10,100,1000,2147483647,-2147483648,-2,-1}',2,1,false,10); - rb_select ------------- - {100,1000} -(1 row) - -select rb_select('{0,1,2,10,100,1000,2147483647,-2147483648,-2,-1}',2,1,false,10,10); - rb_select ------------ - {} -(1 row) - -select rb_select('{0,1,2,10,100,1000,2147483647,-2147483648,-2,-1}',2,1,false,-10,100); - rb_select ------------ - {1,2} -(1 row) - -select rb_select('{0,1,2,10,100,1000,2147483647,-2147483648,-2,-1}',2,1,false,-10,-10); - rb_select ------------ - {} -(1 row) - -select rb_select('{0,1,2,10,100,1000,2147483647,-2147483648,-2,-1}',2,1,false,10,10001); - rb_select ------------- - {100,1000} -(1 row) - -select rb_select('{0,1,2,10,100,1000,2147483647,-2147483648,-2,-1}',2,1,true,10,10001); - rb_select ------------ - {10,100} -(1 row) - --- Test aggregate -select rb_and_agg(id) from (values (NULL::roaringbitmap)) t(id); - rb_and_agg ------------- - -(1 row) - -select rb_and_agg(id) from (values (roaringbitmap('{}'))) t(id); - rb_and_agg ------------- - {} -(1 row) - -select rb_and_agg(id) from (values (roaringbitmap('{1}'))) t(id); - rb_and_agg ------------- - {1} -(1 row) - -select rb_and_agg(id) from (values (roaringbitmap('{1,10,100}'))) t(id); - rb_and_agg ------------- - {1,10,100} -(1 row) - -select rb_and_agg(id) from (values (roaringbitmap('{1,10,100}')),(roaringbitmap('{2,10}'))) t(id); - rb_and_agg ------------- - {10} -(1 row) - -select rb_and_agg(id) from (values (roaringbitmap('{1,10,100}')),(roaringbitmap('{1,10,100}'))) t(id); - rb_and_agg ------------- - {1,10,100} -(1 row) - -select rb_and_agg(id) from (values (NULL),(roaringbitmap('{1,10,100}')),(roaringbitmap('{}'))) t(id); - rb_and_agg ------------- - {} -(1 row) - -select rb_and_agg(id) from (values (NULL),(roaringbitmap('{1,10,100}')),(roaringbitmap('{1}'))) t(id); - rb_and_agg ------------- - {1} -(1 row) - -select rb_and_agg(id) from (values (NULL),(roaringbitmap('{1,10,100}')),(roaringbitmap('{2}'))) t(id); - rb_and_agg ------------- - {} -(1 row) - -select rb_and_agg(id) from (values (roaringbitmap('{1,10,100}')),(NULL),(roaringbitmap('{2,10}'))) t(id); - rb_and_agg ------------- - {10} -(1 row) - -select rb_and_agg(id) from (values (NULL),(roaringbitmap('{1,10,100}')),(NULL),(roaringbitmap('{1,10,100,101}')),(NULL)) t(id); - rb_and_agg ------------- - {1,10,100} -(1 row) - -select rb_and_cardinality_agg(id) from (values (NULL::roaringbitmap)) t(id); - rb_and_cardinality_agg ------------------------- - -(1 row) - -select rb_and_cardinality_agg(id) from (values (roaringbitmap('{}'))) t(id); - rb_and_cardinality_agg ------------------------- - 0 -(1 row) - -select rb_and_cardinality_agg(id) from (values (roaringbitmap('{1}'))) t(id); - rb_and_cardinality_agg ------------------------- - 1 -(1 row) - -select rb_and_cardinality_agg(id) from (values (roaringbitmap('{1,10,100}'))) t(id); - rb_and_cardinality_agg ------------------------- - 3 -(1 row) - -select rb_and_cardinality_agg(id) from (values (roaringbitmap('{1,10,100}')),(roaringbitmap('{2,10}'))) t(id); - rb_and_cardinality_agg ------------------------- - 1 -(1 row) - -select rb_and_cardinality_agg(id) from (values (roaringbitmap('{1,10,100}')),(roaringbitmap('{1,10,100}'))) t(id); - rb_and_cardinality_agg ------------------------- - 3 -(1 row) - -select rb_and_cardinality_agg(id) from (values (NULL),(roaringbitmap('{1,10,100}')),(roaringbitmap('{}'))) t(id); - rb_and_cardinality_agg ------------------------- - 0 -(1 row) - -select rb_and_cardinality_agg(id) from (values (NULL),(roaringbitmap('{1,10,100}')),(roaringbitmap('{1}'))) t(id); - rb_and_cardinality_agg ------------------------- - 1 -(1 row) - -select rb_and_cardinality_agg(id) from (values (NULL),(roaringbitmap('{1,10,100}')),(roaringbitmap('{2}'))) t(id); - rb_and_cardinality_agg ------------------------- - 0 -(1 row) - -select rb_and_cardinality_agg(id) from (values (roaringbitmap('{1,10,100}')),(NULL),(roaringbitmap('{2,10}'))) t(id); - rb_and_cardinality_agg ------------------------- - 1 -(1 row) - -select rb_and_cardinality_agg(id) from (values (NULL),(roaringbitmap('{1,10,100}')),(NULL),(roaringbitmap('{1,10,100,101}')),(NULL)) t(id); - rb_and_cardinality_agg ------------------------- - 3 -(1 row) - -select rb_or_agg(id) from (values (NULL::roaringbitmap)) t(id); - rb_or_agg ------------ - -(1 row) - -select rb_or_agg(id) from (values (roaringbitmap('{}'))) t(id); - rb_or_agg ------------ - {} -(1 row) - -select rb_or_agg(id) from (values (roaringbitmap('{1}'))) t(id); - rb_or_agg ------------ - {1} -(1 row) - -select rb_or_agg(id) from (values (roaringbitmap('{1,10,100}'))) t(id); - rb_or_agg ------------- - {1,10,100} -(1 row) - -select rb_or_agg(id) from (values (roaringbitmap('{1,10,100}')),(roaringbitmap('{2,10}'))) t(id); - rb_or_agg --------------- - {1,2,10,100} -(1 row) - -select rb_or_agg(id) from (values (roaringbitmap('{1,10,100}')),(roaringbitmap('{1,10,100}'))) t(id); - rb_or_agg ------------- - {1,10,100} -(1 row) - -select rb_or_agg(id) from (values (NULL),(roaringbitmap('{1,10,100}')),(roaringbitmap('{}'))) t(id); - rb_or_agg ------------- - {1,10,100} -(1 row) - -select rb_or_agg(id) from (values (NULL),(roaringbitmap('{1,10,100}')),(roaringbitmap('{1}'))) t(id); - rb_or_agg ------------- - {1,10,100} -(1 row) - -select rb_or_agg(id) from (values (NULL),(roaringbitmap('{1,10,100}')),(roaringbitmap('{2}'))) t(id); - rb_or_agg --------------- - {1,2,10,100} -(1 row) - -select rb_or_agg(id) from (values (roaringbitmap('{1,10,100}')),(NULL),(roaringbitmap('{2,10}'))) t(id); - rb_or_agg --------------- - {1,2,10,100} -(1 row) - -select rb_or_agg(id) from (values (NULL),(roaringbitmap('{1,10,100}')),(NULL),(roaringbitmap('{1,10,100,101}')),(NULL)) t(id); - rb_or_agg ----------------- - {1,10,100,101} -(1 row) - -select rb_or_cardinality_agg(id) from (values (NULL::roaringbitmap)) t(id); - rb_or_cardinality_agg ------------------------ - -(1 row) - -select rb_or_cardinality_agg(id) from (values (roaringbitmap('{}'))) t(id); - rb_or_cardinality_agg ------------------------ - 0 -(1 row) - -select rb_or_cardinality_agg(id) from (values (roaringbitmap('{1}'))) t(id); - rb_or_cardinality_agg ------------------------ - 1 -(1 row) - -select rb_or_cardinality_agg(id) from (values (roaringbitmap('{1,10,100}'))) t(id); - rb_or_cardinality_agg ------------------------ - 3 -(1 row) - -select rb_or_cardinality_agg(id) from (values (roaringbitmap('{1,10,100}')),(roaringbitmap('{2,10}'))) t(id); - rb_or_cardinality_agg ------------------------ - 4 -(1 row) - -select rb_or_cardinality_agg(id) from (values (roaringbitmap('{1,10,100}')),(roaringbitmap('{1,10,100}'))) t(id); - rb_or_cardinality_agg ------------------------ - 3 -(1 row) - -select rb_or_cardinality_agg(id) from (values (NULL),(roaringbitmap('{1,10,100}')),(roaringbitmap('{}'))) t(id); - rb_or_cardinality_agg ------------------------ - 3 -(1 row) - -select rb_or_cardinality_agg(id) from (values (NULL),(roaringbitmap('{1,10,100}')),(roaringbitmap('{1}'))) t(id); - rb_or_cardinality_agg ------------------------ - 3 -(1 row) - -select rb_or_cardinality_agg(id) from (values (NULL),(roaringbitmap('{1,10,100}')),(roaringbitmap('{2}'))) t(id); - rb_or_cardinality_agg ------------------------ - 4 -(1 row) - -select rb_or_cardinality_agg(id) from (values (roaringbitmap('{1,10,100}')),(NULL),(roaringbitmap('{2,10}'))) t(id); - rb_or_cardinality_agg ------------------------ - 4 -(1 row) - -select rb_or_cardinality_agg(id) from (values (NULL),(roaringbitmap('{1,10,100}')),(NULL),(roaringbitmap('{1,10,100,101}')),(NULL)) t(id); - rb_or_cardinality_agg ------------------------ - 4 -(1 row) - -select rb_xor_agg(id) from (values (NULL::roaringbitmap)) t(id); - rb_xor_agg ------------- - -(1 row) - -select rb_xor_agg(id) from (values (roaringbitmap('{}'))) t(id); - rb_xor_agg ------------- - {} -(1 row) - -select rb_xor_agg(id) from (values (roaringbitmap('{1}'))) t(id); - rb_xor_agg ------------- - {1} -(1 row) - -select rb_xor_agg(id) from (values (roaringbitmap('{1,10,100}'))) t(id); - rb_xor_agg ------------- - {1,10,100} -(1 row) - -select rb_xor_agg(id) from (values (roaringbitmap('{1,10,100}')),(roaringbitmap('{2,10}'))) t(id); - rb_xor_agg ------------- - {1,2,100} -(1 row) - -select rb_xor_agg(id) from (values (roaringbitmap('{1,10,100}')),(roaringbitmap('{1,10,100}'))) t(id); - rb_xor_agg ------------- - {} -(1 row) - -select rb_xor_agg(id) from (values (NULL),(roaringbitmap('{1,10,100}')),(roaringbitmap('{}'))) t(id); - rb_xor_agg ------------- - {1,10,100} -(1 row) - -select rb_xor_agg(id) from (values (NULL),(roaringbitmap('{1,10,100}')),(roaringbitmap('{1}'))) t(id); - rb_xor_agg ------------- - {10,100} -(1 row) - -select rb_xor_agg(id) from (values (NULL),(roaringbitmap('{1,10,100}')),(roaringbitmap('{2}'))) t(id); - rb_xor_agg --------------- - {1,2,10,100} -(1 row) - -select rb_xor_agg(id) from (values (NULL),(roaringbitmap('{1,10,100}')),(roaringbitmap('{2,10}'))) t(id); - rb_xor_agg ------------- - {1,2,100} -(1 row) - -select rb_xor_agg(id) from (values (roaringbitmap('{1,10,100}')),(NULL),(roaringbitmap('{1,10,100,101}'))) t(id); - rb_xor_agg ------------- - {101} -(1 row) - -select rb_xor_agg(id) from (values (NULL),(roaringbitmap('{1,10,100}')),(NULL),(roaringbitmap('{1,10,101}')),(roaringbitmap('{1,100,102}')),(NULL)) t(id); - rb_xor_agg -------------- - {1,101,102} -(1 row) - -select rb_xor_cardinality_agg(id) from (values (NULL::roaringbitmap)) t(id); - rb_xor_cardinality_agg ------------------------- - -(1 row) - -select rb_xor_cardinality_agg(id) from (values (roaringbitmap('{}'))) t(id); - rb_xor_cardinality_agg ------------------------- - 0 -(1 row) - -select rb_xor_cardinality_agg(id) from (values (roaringbitmap('{1}'))) t(id); - rb_xor_cardinality_agg ------------------------- - 1 -(1 row) - -select rb_xor_cardinality_agg(id) from (values (roaringbitmap('{1,10,100}'))) t(id); - rb_xor_cardinality_agg ------------------------- - 3 -(1 row) - -select rb_xor_cardinality_agg(id) from (values (roaringbitmap('{1,10,100}')),(roaringbitmap('{2,10}'))) t(id); - rb_xor_cardinality_agg ------------------------- - 3 -(1 row) - -select rb_xor_cardinality_agg(id) from (values (roaringbitmap('{1,10,100}')),(roaringbitmap('{1,10,100}'))) t(id); - rb_xor_cardinality_agg ------------------------- - 0 -(1 row) - -select rb_xor_cardinality_agg(id) from (values (NULL),(roaringbitmap('{1,10,100}')),(roaringbitmap('{}'))) t(id); - rb_xor_cardinality_agg ------------------------- - 3 -(1 row) - -select rb_xor_cardinality_agg(id) from (values (NULL),(roaringbitmap('{1,10,100}')),(roaringbitmap('{1}'))) t(id); - rb_xor_cardinality_agg ------------------------- - 2 -(1 row) - -select rb_xor_cardinality_agg(id) from (values (NULL),(roaringbitmap('{1,10,100}')),(roaringbitmap('{2}'))) t(id); - rb_xor_cardinality_agg ------------------------- - 4 -(1 row) - -select rb_xor_cardinality_agg(id) from (values (NULL),(roaringbitmap('{1,10,100}')),(roaringbitmap('{2,10}'))) t(id); - rb_xor_cardinality_agg ------------------------- - 3 -(1 row) - -select rb_xor_cardinality_agg(id) from (values (roaringbitmap('{1,10,100}')),(NULL),(roaringbitmap('{1,10,100,101}'))) t(id); - rb_xor_cardinality_agg ------------------------- - 1 -(1 row) - -select rb_xor_cardinality_agg(id) from (values (NULL),(roaringbitmap('{1,10,100}')),(NULL),(roaringbitmap('{1,10,101}')),(roaringbitmap('{1,100,102}')),(NULL)) t(id); - rb_xor_cardinality_agg ------------------------- - 3 -(1 row) - -select rb_build_agg(id) from (values (NULL::int)) t(id); - rb_build_agg --------------- - -(1 row) - -select rb_build_agg(id) from (values (1)) t(id); - rb_build_agg --------------- - {1} -(1 row) - -select rb_build_agg(id) from (values (1),(10)) t(id); - rb_build_agg --------------- - {1,10} -(1 row) - -select rb_build_agg(id) from (values (1),(10),(10),(100),(1)) t(id); - rb_build_agg --------------- - {1,10,100} -(1 row) - --- Test Windows aggregate -with t(id,bitmap) as( - values(0,NULL),(1,roaringbitmap('{1,10}')),(2,NULL),(3,roaringbitmap('{2,10}')),(4,roaringbitmap('{10,100}')) -) -select id,bitmap,rb_and_agg(bitmap) over(order by id),rb_and_cardinality_agg(bitmap) over(order by id) from t; - id | bitmap | rb_and_agg | rb_and_cardinality_agg -----+----------+------------+------------------------ - 0 | | | - 1 | {1,10} | {1,10} | 2 - 2 | | {1,10} | 2 - 3 | {2,10} | {10} | 1 - 4 | {10,100} | {10} | 1 -(5 rows) - -with t(id,bitmap) as( - values(0,NULL),(1,roaringbitmap('{1,10}')),(2,NULL),(3,roaringbitmap('{2,10}')),(4,roaringbitmap('{10,100}')) -) -select id,bitmap,rb_or_agg(bitmap) over(order by id),rb_or_cardinality_agg(bitmap) over(order by id) from t; - id | bitmap | rb_or_agg | rb_or_cardinality_agg -----+----------+--------------+----------------------- - 0 | | | - 1 | {1,10} | {1,10} | 2 - 2 | | {1,10} | 2 - 3 | {2,10} | {1,2,10} | 3 - 4 | {10,100} | {1,2,10,100} | 4 -(5 rows) - -with t(id,bitmap) as( - values(0,NULL),(1,roaringbitmap('{1,10}')),(2,NULL),(3,roaringbitmap('{2,10}')),(4,roaringbitmap('{10,100}')) -) -select id,bitmap,rb_xor_agg(bitmap) over(order by id),rb_xor_cardinality_agg(bitmap) over(order by id) from t; - id | bitmap | rb_xor_agg | rb_xor_cardinality_agg -----+----------+--------------+------------------------ - 0 | | | - 1 | {1,10} | {1,10} | 2 - 2 | | {1,10} | 2 - 3 | {2,10} | {1,2} | 2 - 4 | {10,100} | {1,2,10,100} | 4 -(5 rows) - -with t(id) as( - values(0),(1),(2),(NULL),(4),(NULL) -) -select id,rb_build_agg(id) over(order by id) from t; - id | rb_build_agg -----+-------------- - 0 | {0} - 1 | {0,1} - 2 | {0,1,2} - 4 | {0,1,2,4} - | {0,1,2,4} - | {0,1,2,4} -(6 rows) - --- Test parallel aggregate -set max_parallel_workers=8; -ERROR: unrecognized configuration parameter "max_parallel_workers" -set max_parallel_workers_per_gather=2; -ERROR: unrecognized configuration parameter "max_parallel_workers_per_gather" -set parallel_setup_cost=0; -ERROR: unrecognized configuration parameter "parallel_setup_cost" -set parallel_tuple_cost=0; -ERROR: unrecognized configuration parameter "parallel_tuple_cost" -set min_parallel_table_scan_size=0; -ERROR: unrecognized configuration parameter "min_parallel_table_scan_size" -CREATE OR REPLACE FUNCTION get_json_plan(sql text) RETURNS SETOF json AS -$BODY$ -BEGIN - RETURN QUERY EXECUTE 'EXPLAIN (COSTS OFF,FORMAT JSON) ' || sql; - - RETURN; - END -$BODY$ -LANGUAGE plpgsql; -drop table if exists bitmap_test_tb1; -NOTICE: table "bitmap_test_tb1" does not exist, skipping -create table bitmap_test_tb1(id int, bitmap roaringbitmap); -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'id' as the Greenplum Database data distribution key for this table. -HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. -insert into bitmap_test_tb1 values (NULL,NULL); -insert into bitmap_test_tb1 select id,rb_build(ARRAY[id]) from generate_series(1,10000)id; -insert into bitmap_test_tb1 values (NULL,NULL); -insert into bitmap_test_tb1 values (10001,rb_build(ARRAY[10,100,1000,10000,10001])); -select position('"Parallel Aware": true' in get_json_plan(' -select rb_cardinality(bitmap),rb_min(bitmap),rb_max(bitmap) - from (select rb_build_agg(id) bitmap from bitmap_test_tb1)a -')::text) > 0 is_parallel_plan; - is_parallel_plan ------------------- - f -(1 row) - -select rb_cardinality(bitmap),rb_min(bitmap),rb_max(bitmap) - from (select rb_build_agg(id) bitmap from bitmap_test_tb1)a; - rb_cardinality | rb_min | rb_max -----------------+--------+-------- - 10001 | 1 | 10001 -(1 row) - -select position('"Parallel Aware": true' in get_json_plan(' -select rb_cardinality(bitmap),rb_min(bitmap),rb_max(bitmap) - from (select rb_and_agg(bitmap) bitmap from bitmap_test_tb1)a -')::text) > 0 is_parallel_plan; - is_parallel_plan ------------------- - f -(1 row) - -select rb_cardinality(bitmap),rb_min(bitmap),rb_max(bitmap) - from (select rb_and_agg(bitmap) bitmap from bitmap_test_tb1)a; - rb_cardinality | rb_min | rb_max -----------------+--------+-------- - 0 | | -(1 row) - -select position('"Parallel Aware": true' in get_json_plan(' -select rb_cardinality(bitmap),rb_min(bitmap),rb_max(bitmap) - from (select rb_or_agg(bitmap) bitmap from bitmap_test_tb1)a -')::text) > 0 is_parallel_plan; - is_parallel_plan ------------------- - f -(1 row) - -select rb_cardinality(bitmap),rb_min(bitmap),rb_max(bitmap) - from (select rb_or_agg(bitmap) bitmap from bitmap_test_tb1)a; - rb_cardinality | rb_min | rb_max -----------------+--------+-------- - 10001 | 1 | 10001 -(1 row) - -select position('"Parallel Aware": true' in get_json_plan(' -select rb_cardinality(bitmap),rb_min(bitmap),rb_max(bitmap) - from (select rb_xor_agg(bitmap) bitmap from bitmap_test_tb1)a -')::text) > 0 is_parallel_plan; - is_parallel_plan ------------------- - f -(1 row) - -select rb_cardinality(bitmap),rb_min(bitmap),rb_max(bitmap) - from (select rb_xor_agg(bitmap) bitmap from bitmap_test_tb1)a; - rb_cardinality | rb_min | rb_max -----------------+--------+-------- - 9997 | 1 | 10001 -(1 row) - -select position('"Parallel Aware": true' in get_json_plan(' -select rb_and_cardinality_agg(bitmap),rb_or_cardinality_agg(bitmap),rb_xor_cardinality_agg(bitmap) from bitmap_test_tb1 -')::text) > 0 is_parallel_plan; - is_parallel_plan ------------------- - f -(1 row) - -select rb_and_cardinality_agg(bitmap),rb_or_cardinality_agg(bitmap),rb_xor_cardinality_agg(bitmap) from bitmap_test_tb1; - rb_and_cardinality_agg | rb_or_cardinality_agg | rb_xor_cardinality_agg -------------------------+-----------------------+------------------------ - 0 | 10001 | 9997 -(1 row) - ---rb_iterate() not support parallel on PG10 while run on parallel in PG11+ ---explain(costs off) ---select count(*) from (select rb_iterate(bitmap) from bitmap_test_tb1)a; -select count(*) from (select rb_iterate(bitmap) from bitmap_test_tb1)a; - count -------- - 10005 -(1 row) - -select position('"Parallel Aware": true' in get_json_plan(' -select id,bitmap, - rb_build_agg(id) over(w), - rb_or_agg(bitmap) over(w), - rb_and_agg(bitmap) over(w), - rb_xor_agg(bitmap) over(w) -from bitmap_test_tb1 -window w as (order by id) -order by id limit 10 -')::text) > 0 is_parallel_plan; - is_parallel_plan ------------------- - f -(1 row) - -select id,bitmap, - rb_build_agg(id) over(w), - rb_or_agg(bitmap) over(w), - rb_and_agg(bitmap) over(w), - rb_xor_agg(bitmap) over(w) -from bitmap_test_tb1 -window w as (order by id) -order by id limit 10; - id | bitmap | rb_build_agg | rb_or_agg | rb_and_agg | rb_xor_agg -----+--------+------------------------+------------------------+------------+------------------------ - 1 | {1} | {1} | {1} | {1} | {1} - 2 | {2} | {1,2} | {1,2} | {} | {1,2} - 3 | {3} | {1,2,3} | {1,2,3} | {} | {1,2,3} - 4 | {4} | {1,2,3,4} | {1,2,3,4} | {} | {1,2,3,4} - 5 | {5} | {1,2,3,4,5} | {1,2,3,4,5} | {} | {1,2,3,4,5} - 6 | {6} | {1,2,3,4,5,6} | {1,2,3,4,5,6} | {} | {1,2,3,4,5,6} - 7 | {7} | {1,2,3,4,5,6,7} | {1,2,3,4,5,6,7} | {} | {1,2,3,4,5,6,7} - 8 | {8} | {1,2,3,4,5,6,7,8} | {1,2,3,4,5,6,7,8} | {} | {1,2,3,4,5,6,7,8} - 9 | {9} | {1,2,3,4,5,6,7,8,9} | {1,2,3,4,5,6,7,8,9} | {} | {1,2,3,4,5,6,7,8,9} - 10 | {10} | {1,2,3,4,5,6,7,8,9,10} | {1,2,3,4,5,6,7,8,9,10} | {} | {1,2,3,4,5,6,7,8,9,10} -(10 rows) - From 615d3d25874f18f1491eb5d508156d2b6d4f6451 Mon Sep 17 00:00:00 2001 From: Aidan McMurray <41323054+acmcmurray@users.noreply.github.com> Date: Tue, 10 Oct 2023 12:53:11 +0100 Subject: [PATCH 4/5] NT add Github Actions CI.yaml (#7) * NT add CI * NT remove .travis.yml --- .github/workflows/CI.yaml | 23 ++++++++++++++++++++++ .travis.yml | 40 --------------------------------------- 2 files changed, 23 insertions(+), 40 deletions(-) create mode 100644 .github/workflows/CI.yaml delete mode 100644 .travis.yml diff --git a/.github/workflows/CI.yaml b/.github/workflows/CI.yaml new file mode 100644 index 0000000..ce3f502 --- /dev/null +++ b/.github/workflows/CI.yaml @@ -0,0 +1,23 @@ +# This workflow will build & run tests +name: CI + +on: + push: + branches: [main] + pull_request: + +jobs: + test: + strategy: + matrix: + pg: [ 16, 15, 14, 13, 12, 11 ] + name: 🐘 PostgreSQL ${{ matrix.pg }} + runs-on: ubuntu-latest + container: pgxn/pgxn-tools + steps: + - name: Start PostgreSQL ${{ matrix.pg }} + run: pg-start ${{ matrix.pg }} + - name: Check out the repo + uses: actions/checkout@v3 + - name: Test on PostgreSQL ${{ matrix.pg }} + run: pg-build-test diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 0efa31d..0000000 --- a/.travis.yml +++ /dev/null @@ -1,40 +0,0 @@ -sudo: required -dist: bionic -language: c -cache: - apt: true - directories: - - /home/travis/postgresql -env: - global: - - enable_coverage=yes -# - PG_PRELOAD=cstore_fdw - matrix: - - PGVERSION=10 - - PGVERSION=11 - - PGVERSION=12 - - PGVERSION=13 - - PGVERSION=14 - -before_install: - - git clone -b v0.7.13 --depth 1 https://github.com/ChenHuajun/tools.git - - sudo make -C tools install - - setup_apt - - nuke_pg -install: -# - sudo apt-get install protobuf-c-compiler -# - sudo apt-get install libprotobuf-c0-dev - - sudo locale-gen da_DK - - sudo locale-gen da_DK.utf8 - - sudo pip install cpp-coveralls - - install_pg - - install_custom_pg -before_script: -# - chmod 777 . -# - chmod 777 data -# - chmod 666 data/* - - config_and_start_cluster -script: pg_travis_test -after_success: - - sudo chmod 666 *.gcda - - coveralls --exclude roaring.c --exclude roaring.h From 9aa507d8ae994be420a0cbeedaf812050ff503d2 Mon Sep 17 00:00:00 2001 From: "Shane Michael Mathews (Brandwatch Account)" <21181346+smmathews-bw-boston@users.noreply.github.com> Date: Tue, 10 Oct 2023 08:02:16 -0400 Subject: [PATCH 5/5] remove warning from unused variable (#8) --- roaringbitmap.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/roaringbitmap.c b/roaringbitmap.c index e3308bf..7022ed7 100644 --- a/roaringbitmap.c +++ b/roaringbitmap.c @@ -2062,7 +2062,6 @@ Datum rb_runoptimize(PG_FUNCTION_ARGS) { bytea *serializedbytes = PG_GETARG_BYTEA_P(0); roaring_bitmap_t *r; - bool optimized; size_t expectedsize; r = roaring_bitmap_portable_deserialize(VARDATA(serializedbytes)); @@ -2071,7 +2070,7 @@ rb_runoptimize(PG_FUNCTION_ARGS) { (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED), errmsg("bitmap format is error"))); - optimized = roaring_bitmap_run_optimize(r); + roaring_bitmap_run_optimize(r); expectedsize = roaring_bitmap_portable_size_in_bytes(r); serializedbytes = (bytea *) palloc(VARHDRSZ + expectedsize);