zeromax007 / gpdb-roaringbitmap Goto Github PK
View Code? Open in Web Editor NEWRoaringBitmap extension for greenplum-db
License: Apache License 2.0
RoaringBitmap extension for greenplum-db
License: Apache License 2.0
Greenplum/PostgreSQL has extension framework, which is easier to use and manage. Maybe it will be awesome if make this project as an extension.
请问什么时候可以支持 bigint 呢?
由于上一个issue无法reopen,所以我新开一个了。
参考:
#10 (comment)
SQL:
CREATE TABLE t1 (id integer, bitmap roaringbitmap);
INSERT INTO t1 SELECT 3,RB_BUILD(ARRAY[1,2,3]);
INSERT INTO t1 SELECT 4,RB_BUILD(ARRAY[3,4,5]);
INSERT INTO t1 SELECT 5,RB_BUILD(ARRAY[-3,4,5]);
select id, rb_maximum(bitmap) from t1 where id in (3,4,5);
id | rb_maximum
----+------------
3 | 3
4 | 5
5 | -3
I think it should be
select id, rb_maximum(bitmap) from t1 where id in (3,4,5);
id | rb_maximum
----+------------
3 | 3
4 | 5
5 | 5
I used your code with GP version 4.3.7.15, the registration of sql function for roaring bitmap operation is always failed.
I found the pgsql extern function of AggCheckCallContext is missing from C header file fmgr.h,
then I switched to the newest version of GP 5.0.0-beta.4, and all looks good.
Leave a note here to save the time for anyone who visits this looking for roaring bitmap in greenplum.
Greenplum 版本:PostgreSQL 9.4.24 (Greenplum Database 6.2.1 build commit:d90ac1a1b983b913b3950430d4d9e47ee8827fd4) on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 6.4.0, 64-bit compiled on Dec 12 2019 18:35:48
有两个一样的脚本。其中一个脚本直接计算bitmap,另外一个脚本计算表内的bitmap。两个bitmap一致。但是使用 rb_and_agg 计算时,会出现不一样的结果。
脚本1:
select rb_to_array(rb_and_agg(bitmap)) as result,
count(1) as total,
string_agg(rb_to_array(bitmap)::varchar, ',') as str
from (values (rb_build('{1,2,3}')), (rb_build('{2,3,4}'))) t(bitmap);
结果为:
field | value |
---|---|
result | {2,3} |
total | 2 |
str | {1,2,3},{2,3,4} |
正常。注释掉count(1) as total
与string_agg(rb_to_array(bitmap)::varchar, ',') as str
后,执行均正常得到and_agg计算结果。
脚本2:
select rb_to_array(rb_and_agg(bitmap)) as result,
string_agg(rb_to_array(bitmap)::varchar, ',') as str
from (select bitmap from t_tmp where id in (4, 5) order by id) a;
其中表t_tmp
内容为:
id | rb_to_array(bitmap) |
---|---|
4 | {1,2,3} |
5 | {2,3,4} |
脚本2执行结果为:
result | str |
---|---|
{2,3} | {1,2,3},{2,3,4} |
此处正常。但是当把脚本2中的string_agg(rb_to_array(bitmap)::varchar, ',') as str
注释后,将得到以下不正确的结果:
result |
---|
{} |
表创建语句:
CREATE TABLE t_tmp
(
id integer,
bitmap roaringbitmap
);
INSERT INTO t_tmp SELECT 4, rb_build('{1,2,3}');
INSERT INTO t_tmp SELECT 5, rb_build('{2,3,4}');
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.