Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
914663e2
C
ClickHouse
项目概览
2dot5
/
ClickHouse
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
ClickHouse
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
914663e2
编写于
6月 05, 2019
作者:
A
alexey-milovidov
提交者:
GitHub
6月 05, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #5528 from infinivision/fix_bitmapHasAny
Fix bitmapHasAny segment fault
上级
1c5ab08e
59a59c34
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
32 addition
and
5 deletion
+32
-5
dbms/src/Functions/FunctionsBitmap.h
dbms/src/Functions/FunctionsBitmap.h
+23
-5
dbms/tests/queries/0_stateless/00829_bitmap_function.reference
...tests/queries/0_stateless/00829_bitmap_function.reference
+3
-0
dbms/tests/queries/0_stateless/00829_bitmap_function.sql
dbms/tests/queries/0_stateless/00829_bitmap_function.sql
+6
-0
未找到文件。
dbms/src/Functions/FunctionsBitmap.h
浏览文件 @
914663e2
...
...
@@ -55,6 +55,12 @@ namespace ErrorCodes
*
* Two bitmap andnot calculation, return cardinality:
* bitmapAndnotCardinality: bitmap,bitmap -> integer
*
* Judge if a bitmap is superset of the another one:
* bitmapHasAll: bitmap,bitmap -> bool
*
* Judge if the intersection of two bitmap is nonempty:
* bitmapHasAny: bitmap,bitmap -> bool
*/
template
<
typename
Name
>
...
...
@@ -430,20 +436,32 @@ private:
Block
&
block
,
const
ColumnNumbers
&
arguments
,
size_t
input_rows_count
,
typename
ColumnVector
<
ToType
>::
Container
&
vec_to
)
{
const
ColumnAggregateFunction
*
columns
[
2
];
bool
isColumnConst
[
2
];
for
(
size_t
i
=
0
;
i
<
2
;
++
i
)
{
if
(
auto
argument_column_const
=
typeid_cast
<
const
ColumnConst
*>
(
block
.
getByPosition
(
arguments
[
i
]).
column
.
get
()))
columns
[
i
]
=
typeid_cast
<
const
ColumnAggregateFunction
*>
(
argument_column_const
->
getDataColumnPtr
().
get
());
if
(
auto
argument_column_const
=
typeid_cast
<
const
ColumnConst
*>
(
block
.
getByPosition
(
arguments
[
i
]).
column
.
get
()))
{
columns
[
i
]
=
typeid_cast
<
const
ColumnAggregateFunction
*>
(
argument_column_const
->
getDataColumnPtr
().
get
());
isColumnConst
[
i
]
=
true
;
}
else
columns
[
i
]
=
typeid_cast
<
const
ColumnAggregateFunction
*>
(
block
.
getByPosition
(
arguments
[
i
]).
column
.
get
());
{
columns
[
i
]
=
typeid_cast
<
const
ColumnAggregateFunction
*>
(
block
.
getByPosition
(
arguments
[
i
]).
column
.
get
());
isColumnConst
[
i
]
=
false
;
}
}
const
PaddedPODArray
<
AggregateDataPtr
>
&
container0
=
columns
[
0
]
->
getData
();
const
PaddedPODArray
<
AggregateDataPtr
>
&
container1
=
columns
[
1
]
->
getData
();
for
(
size_t
i
=
0
;
i
<
input_rows_count
;
++
i
)
{
const
AggregateDataPtr
dataPtr0
=
isColumnConst
[
0
]
?
container0
[
0
]
:
container0
[
i
];
const
AggregateDataPtr
dataPtr1
=
isColumnConst
[
1
]
?
container1
[
0
]
:
container1
[
i
];
const
AggregateFunctionGroupBitmapData
<
T
>
&
bd1
=
*
reinterpret_cast
<
const
AggregateFunctionGroupBitmapData
<
T
>
*>
(
columns
[
0
]
->
getData
()[
i
]
);
=
*
reinterpret_cast
<
const
AggregateFunctionGroupBitmapData
<
T
>
*>
(
dataPtr0
);
const
AggregateFunctionGroupBitmapData
<
T
>
&
bd2
=
*
reinterpret_cast
<
const
AggregateFunctionGroupBitmapData
<
T
>
*>
(
columns
[
1
]
->
getData
()[
i
]
);
=
*
reinterpret_cast
<
const
AggregateFunctionGroupBitmapData
<
T
>
*>
(
dataPtr1
);
vec_to
[
i
]
=
Impl
<
T
>::
apply
(
bd1
,
bd2
);
}
}
...
...
dbms/tests/queries/0_stateless/00829_bitmap_function.reference
浏览文件 @
914663e2
...
...
@@ -15,6 +15,9 @@
2019-01-02 60 [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]
60 50 70 40 20 30
60 50 70 40 20 30
90
90
20
2019-01-01 50
2019-01-02 60
1
...
...
dbms/tests/queries/0_stateless/00829_bitmap_function.sql
浏览文件 @
914663e2
...
...
@@ -56,6 +56,12 @@ ALL LEFT JOIN
)
USING
city_id
;
SELECT
count
(
*
)
FROM
bitmap_test
WHERE
bitmapHasAny
((
SELECT
groupBitmapState
(
uid
)
FROM
bitmap_test
WHERE
pickup_date
=
'2019-01-01'
),
bitmapBuild
([
uid
]));
SELECT
count
(
*
)
FROM
bitmap_test
WHERE
bitmapHasAny
(
bitmapBuild
([
uid
]),
(
SELECT
groupBitmapState
(
uid
)
FROM
bitmap_test
WHERE
pickup_date
=
'2019-01-01'
));
SELECT
count
(
*
)
FROM
bitmap_test
WHERE
0
=
bitmapHasAny
((
SELECT
groupBitmapState
(
uid
)
FROM
bitmap_test
WHERE
pickup_date
=
'2019-01-01'
),
bitmapBuild
([
uid
]));
-- bitmap state test
DROP
TABLE
IF
EXISTS
bitmap_state_test
;
CREATE
TABLE
bitmap_state_test
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录