Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
a2ef0f6c
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,发现更多精彩内容 >>
提交
a2ef0f6c
编写于
10月 10, 2020
作者:
A
Alexey Milovidov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Minor changes in BigInt hash
上级
4f2d4988
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
6 addition
and
43 deletion
+6
-43
src/Common/HashTable/Hash.h
src/Common/HashTable/Hash.h
+2
-27
src/Core/BigInt.h
src/Core/BigInt.h
+4
-16
未找到文件。
src/Common/HashTable/Hash.h
浏览文件 @
a2ef0f6c
...
...
@@ -73,7 +73,7 @@ inline DB::UInt64 intHashCRC32(DB::UInt64 x, DB::UInt64 updated_value)
}
template
<
typename
T
>
inline
typename
std
::
enable_if
<
(
sizeof
(
T
)
>
sizeof
(
DB
::
UInt64
))
&&
!
is_big_int_v
<
T
>
,
DB
::
UInt64
>::
type
inline
typename
std
::
enable_if
<
(
sizeof
(
T
)
>
sizeof
(
DB
::
UInt64
)),
DB
::
UInt64
>::
type
intHashCRC32
(
const
T
&
x
,
DB
::
UInt64
updated_value
)
{
auto
*
begin
=
reinterpret_cast
<
const
char
*>
(
&
x
);
...
...
@@ -86,16 +86,6 @@ intHashCRC32(const T & x, DB::UInt64 updated_value)
return
updated_value
;
}
template
<
typename
T
>
inline
typename
std
::
enable_if
<
is_big_int_v
<
T
>
,
DB
::
UInt64
>::
type
intHashCRC32
(
const
T
&
x
,
DB
::
UInt64
updated_value
)
{
std
::
vector
<
UInt64
>
parts
=
DB
::
BigInt
<
T
>::
toIntArray
(
x
);
for
(
const
auto
&
part
:
parts
)
updated_value
=
intHashCRC32
(
part
,
updated_value
);
return
updated_value
;
}
inline
UInt32
updateWeakHash32
(
const
DB
::
UInt8
*
pos
,
size_t
size
,
DB
::
UInt32
updated_value
)
{
...
...
@@ -248,22 +238,7 @@ inline size_t hashCRC32(std::enable_if_t<(sizeof(T) <= sizeof(UInt64)), T> key)
template
<
typename
T
>
inline
size_t
hashCRC32
(
std
::
enable_if_t
<
(
sizeof
(
T
)
>
sizeof
(
UInt64
)),
T
>
key
)
{
if
constexpr
(
std
::
is_same_v
<
T
,
DB
::
Int128
>
)
{
return
intHashCRC32
(
static_cast
<
UInt64
>
(
key
)
^
static_cast
<
UInt64
>
(
key
>>
64
));
}
else
if
constexpr
(
std
::
is_same_v
<
T
,
DB
::
UInt128
>
)
{
return
intHashCRC32
(
key
.
low
^
key
.
high
);
}
else
if
constexpr
(
is_big_int_v
<
T
>
&&
sizeof
(
T
)
==
32
)
{
return
intHashCRC32
(
static_cast
<
UInt64
>
(
key
)
^
static_cast
<
UInt64
>
(
key
>>
64
)
^
static_cast
<
UInt64
>
(
key
>>
128
)
^
static_cast
<
UInt64
>
(
key
>>
256
));
}
__builtin_unreachable
();
return
intHashCRC32
(
key
,
-
1
);
}
#define DEFINE_HASH(T) \
...
...
src/Core/BigInt.h
浏览文件 @
a2ef0f6c
#pragma once
#include <common/StringRef.h>
#include <common/unaligned.h>
#include <Core/Types.h>
namespace
DB
{
...
...
@@ -14,8 +16,7 @@ struct BigInt
static
StringRef
serialize
(
const
T
&
x
,
char
*
pos
)
{
//unalignedStore<T>(pos, x);
memcpy
(
pos
,
&
x
,
size
);
unalignedStore
<
T
>
(
pos
,
x
);
return
StringRef
(
pos
,
size
);
}
...
...
@@ -28,20 +29,7 @@ struct BigInt
static
T
deserialize
(
const
char
*
pos
)
{
//return unalignedLoad<T>(pos);
T
res
;
memcpy
(
&
res
,
pos
,
size
);
return
res
;
}
static
std
::
vector
<
UInt64
>
toIntArray
(
const
T
&
x
)
{
std
::
vector
<
UInt64
>
parts
(
4
,
0
);
parts
[
0
]
=
UInt64
(
x
);
parts
[
1
]
=
UInt64
(
x
>>
64
);
parts
[
2
]
=
UInt64
(
x
>>
128
);
parts
[
4
]
=
UInt64
(
x
>>
192
);
return
parts
;
return
unalignedLoad
<
T
>
(
pos
);
}
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录