Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
6f0c287e
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,发现更多精彩内容 >>
提交
6f0c287e
编写于
11月 15, 2019
作者:
N
Nikolai Kochetov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Small refactoring.
上级
618ecf4f
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
30 addition
and
15 deletion
+30
-15
dbms/src/Functions/array/arrayIntersect.cpp
dbms/src/Functions/array/arrayIntersect.cpp
+30
-15
未找到文件。
dbms/src/Functions/array/arrayIntersect.cpp
浏览文件 @
6f0c287e
...
@@ -66,6 +66,8 @@ private:
...
@@ -66,6 +66,8 @@ private:
const
NullMap
*
overflow_mask
=
nullptr
;
const
NullMap
*
overflow_mask
=
nullptr
;
const
ColumnArray
::
ColumnOffsets
::
Container
*
offsets
=
nullptr
;
const
ColumnArray
::
ColumnOffsets
::
Container
*
offsets
=
nullptr
;
const
IColumn
*
nested_column
=
nullptr
;
const
IColumn
*
nested_column
=
nullptr
;
Columns
column_holders
;
};
};
std
::
vector
<
UnpackedArray
>
args
;
std
::
vector
<
UnpackedArray
>
args
;
...
@@ -265,6 +267,23 @@ FunctionArrayIntersect::CastArgumentsResult FunctionArrayIntersect::castColumns(
...
@@ -265,6 +267,23 @@ FunctionArrayIntersect::CastArgumentsResult FunctionArrayIntersect::castColumns(
return
{.
initial
=
initial_columns
,
.
casted
=
columns
};
return
{.
initial
=
initial_columns
,
.
casted
=
columns
};
}
}
static
ColumnPtr
callFunctionNotEquals
(
ColumnWithTypeAndName
first
,
ColumnWithTypeAndName
second
,
const
Context
&
context
)
{
ColumnsWithTypeAndName
args
;
args
.
reserve
(
2
);
args
.
emplace_back
(
std
::
move
(
first
));
args
.
emplace_back
(
std
::
move
(
second
));
auto
eq_func
=
FunctionFactory
::
instance
().
get
(
"notEquals"
,
context
)
->
build
(
args
);
Block
block
=
args
;
block
.
insert
({
nullptr
,
eq_func
->
getReturnType
(),
""
});
eq_func
->
execute
(
block
,
{
0
,
1
},
2
,
args
.
front
().
column
->
size
());
return
block
.
getByPosition
(
2
).
column
;
}
FunctionArrayIntersect
::
UnpackedArrays
FunctionArrayIntersect
::
prepareArrays
(
FunctionArrayIntersect
::
UnpackedArrays
FunctionArrayIntersect
::
prepareArrays
(
const
ColumnsWithTypeAndName
&
columns
,
ColumnsWithTypeAndName
&
initial_columns
)
const
const
ColumnsWithTypeAndName
&
columns
,
ColumnsWithTypeAndName
&
initial_columns
)
const
{
{
...
@@ -305,6 +324,7 @@ FunctionArrayIntersect::UnpackedArrays FunctionArrayIntersect::prepareArrays(
...
@@ -305,6 +324,7 @@ FunctionArrayIntersect::UnpackedArrays FunctionArrayIntersect::prepareArrays(
initial_column
=
&
typeid_cast
<
const
ColumnNullable
*>
(
initial_column
)
->
getNestedColumn
();
initial_column
=
&
typeid_cast
<
const
ColumnNullable
*>
(
initial_column
)
->
getNestedColumn
();
}
}
/// In case column was casted need to create overflow mask for integer types.
if
(
arg
.
nested_column
!=
initial_column
)
if
(
arg
.
nested_column
!=
initial_column
)
{
{
auto
&
nested_init_type
=
typeid_cast
<
const
DataTypeArray
*>
(
removeNullable
(
initial_columns
[
i
].
type
).
get
())
->
getNestedType
();
auto
&
nested_init_type
=
typeid_cast
<
const
DataTypeArray
*>
(
removeNullable
(
initial_columns
[
i
].
type
).
get
())
->
getNestedType
();
...
@@ -312,19 +332,14 @@ FunctionArrayIntersect::UnpackedArrays FunctionArrayIntersect::prepareArrays(
...
@@ -312,19 +332,14 @@ FunctionArrayIntersect::UnpackedArrays FunctionArrayIntersect::prepareArrays(
if
(
isInteger
(
nested_init_type
)
||
isDateOrDateTime
(
nested_init_type
))
if
(
isInteger
(
nested_init_type
)
||
isDateOrDateTime
(
nested_init_type
))
{
{
ColumnsWithTypeAndName
args
=
{{
arg
.
nested_column
->
getPtr
(),
nested_init_type
,
""
},
/// Compare original and casted columns. It seem to be the easiest way.
{
initial_column
->
getPtr
(),
nested_cast_type
,
""
}};
auto
overflow_mask
=
callFunctionNotEquals
(
auto
eq_func
=
FunctionFactory
::
instance
().
get
(
"notEquals"
,
context
)
->
build
(
args
);
{
arg
.
nested_column
->
getPtr
(),
nested_init_type
,
""
},
{
initial_column
->
getPtr
(),
nested_cast_type
,
""
},
Block
block
=
args
;
context
);
block
.
insert
({
nullptr
,
eq_func
->
getReturnType
(),
""
});
arg
.
overflow_mask
=
&
typeid_cast
<
const
ColumnUInt8
*>
(
overflow_mask
.
get
())
->
getData
();
eq_func
->
execute
(
block
,
{
0
,
1
},
2
,
initial_column
->
size
());
arrays
.
column_holders
.
emplace_back
(
std
::
move
(
overflow_mask
));
/// Save result of equals.
initial_columns
[
i
].
column
=
block
.
getByPosition
(
2
).
column
;
arg
.
overflow_mask
=
&
typeid_cast
<
const
ColumnUInt8
*>
(
initial_columns
[
i
].
column
.
get
())
->
getData
();
}
}
}
}
}
}
...
@@ -412,7 +427,7 @@ void FunctionArrayIntersect::executeImpl(Block & block, const ColumnNumbers & ar
...
@@ -412,7 +427,7 @@ void FunctionArrayIntersect::executeImpl(Block & block, const ColumnNumbers & ar
result_column
=
execute
<
StringMap
,
ColumnFixedString
,
false
>
(
arrays
,
std
::
move
(
column
));
result_column
=
execute
<
StringMap
,
ColumnFixedString
,
false
>
(
arrays
,
std
::
move
(
column
));
else
else
{
{
column
=
static
_cast
<
const
DataTypeArray
&>
(
*
return_type_with_nulls
).
getNestedType
()
->
createColumn
();
column
=
assert
_cast
<
const
DataTypeArray
&>
(
*
return_type_with_nulls
).
getNestedType
()
->
createColumn
();
result_column
=
castRemoveNullable
(
execute
<
StringMap
,
IColumn
,
false
>
(
arrays
,
std
::
move
(
column
)),
return_type
);
result_column
=
castRemoveNullable
(
execute
<
StringMap
,
IColumn
,
false
>
(
arrays
,
std
::
move
(
column
)),
return_type
);
}
}
}
}
...
@@ -440,7 +455,7 @@ ColumnPtr FunctionArrayIntersect::execute(const UnpackedArrays & arrays, Mutable
...
@@ -440,7 +455,7 @@ ColumnPtr FunctionArrayIntersect::execute(const UnpackedArrays & arrays, Mutable
std
::
vector
<
const
ColumnType
*>
columns
;
std
::
vector
<
const
ColumnType
*>
columns
;
columns
.
reserve
(
args
);
columns
.
reserve
(
args
);
for
(
auto
arg
:
arrays
.
args
)
for
(
auto
&
arg
:
arrays
.
args
)
{
{
if
constexpr
(
std
::
is_same
<
ColumnType
,
IColumn
>::
value
)
if
constexpr
(
std
::
is_same
<
ColumnType
,
IColumn
>::
value
)
columns
.
push_back
(
arg
.
nested_column
);
columns
.
push_back
(
arg
.
nested_column
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录