Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
d3e63219
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,发现更多精彩内容 >>
提交
d3e63219
编写于
5月 05, 2017
作者:
A
Alexey Milovidov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
AggregateFunctionTopK: minor modifications [#CLICKHOUSE-2].
上级
32a75147
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
8 addition
and
11 deletion
+8
-11
dbms/src/AggregateFunctions/AggregateFunctionTopK.h
dbms/src/AggregateFunctions/AggregateFunctionTopK.h
+1
-2
dbms/src/Common/SpaceSaving.h
dbms/src/Common/SpaceSaving.h
+7
-9
未找到文件。
dbms/src/AggregateFunctions/AggregateFunctionTopK.h
浏览文件 @
d3e63219
...
...
@@ -72,9 +72,8 @@ public:
void
addImpl
(
AggregateDataPtr
place
,
const
IColumn
&
column
,
size_t
row_num
,
Arena
*
)
const
{
auto
&
set
=
this
->
data
(
place
).
value
;
if
(
set
.
capacity
()
!=
reserved
)
{
if
(
set
.
capacity
()
!=
reserved
)
set
.
resize
(
reserved
);
}
set
.
insert
(
static_cast
<
const
ColumnVector
<
T
>
&>
(
column
).
getData
()[
row_num
]);
}
...
...
dbms/src/Common/SpaceSaving.h
浏览文件 @
d3e63219
...
...
@@ -85,7 +85,7 @@ public:
m_capacity
=
new_capacity
;
}
Counter
*
insert
(
const
TKey
&
key
,
UInt64
increment
=
1
,
UInt64
error
=
0
)
void
insert
(
const
TKey
&
key
,
UInt64
increment
=
1
,
UInt64
error
=
0
)
{
// Increase weight of a key that already exists
// It uses hashtable for both value mapping as a presence test (c_i != 0)
...
...
@@ -97,7 +97,7 @@ public:
c
->
count
+=
increment
;
c
->
error
+=
error
;
percolate
(
c
);
return
c
;
return
;
}
// Key doesn't exist, but can fit in the top K
...
...
@@ -105,7 +105,7 @@ public:
{
auto
c
=
new
Counter
(
key
,
increment
,
error
);
push
(
c
);
return
c
;
return
;
}
auto
min
=
counter_list
.
back
();
...
...
@@ -113,12 +113,12 @@ public:
if
(
alpha
+
increment
<
min
->
count
)
{
alpha
+=
increment
;
return
nullptr
;
return
;
}
// Erase the current minimum element
auto
min
H
ash
=
counter_map
.
hash
(
min
->
key
);
it
=
counter_map
.
find
(
min
->
key
,
min
H
ash
);
auto
min
_h
ash
=
counter_map
.
hash
(
min
->
key
);
it
=
counter_map
.
find
(
min
->
key
,
min
_h
ash
);
if
(
it
!=
counter_map
.
end
())
{
auto
cell
=
it
.
getPtr
();
...
...
@@ -130,15 +130,13 @@ public:
counter_map
.
emplace
(
key
,
it
,
inserted
,
hash
);
if
(
inserted
)
{
alpha_map
[
min
H
ash
%
alpha_map
.
size
()]
=
min
->
count
;
alpha_map
[
min
_h
ash
%
alpha_map
.
size
()]
=
min
->
count
;
min
->
key
=
key
;
min
->
count
=
alpha
+
increment
;
min
->
error
=
alpha
+
error
;
it
->
second
=
min
;
percolate
(
min
);
}
return
min
;
}
/*
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录