Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
c6a50834
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,发现更多精彩内容 >>
提交
c6a50834
编写于
7月 05, 2017
作者:
G
Guillaume Tassery
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix comparison of UInt128 to Float64
上级
b9073492
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
37 addition
and
25 deletion
+37
-25
dbms/src/Columns/ColumnVector.cpp
dbms/src/Columns/ColumnVector.cpp
+1
-1
dbms/src/Common/UInt128.h
dbms/src/Common/UInt128.h
+20
-6
dbms/src/Core/AccurateComparison.h
dbms/src/Core/AccurateComparison.h
+8
-8
dbms/src/Core/UUID.h
dbms/src/Core/UUID.h
+0
-3
dbms/src/DataTypes/DataTypeNumberBase.cpp
dbms/src/DataTypes/DataTypeNumberBase.cpp
+2
-2
dbms/src/DataTypes/DataTypeUUID.h
dbms/src/DataTypes/DataTypeUUID.h
+2
-1
dbms/src/DataTypes/DataTypesNumber.h
dbms/src/DataTypes/DataTypesNumber.h
+1
-0
dbms/src/DataTypes/FieldToDataType.cpp
dbms/src/DataTypes/FieldToDataType.cpp
+1
-1
dbms/src/Dictionaries/MongoDBBlockInputStream.cpp
dbms/src/Dictionaries/MongoDBBlockInputStream.cpp
+0
-1
dbms/src/IO/ReadHelpers.h
dbms/src/IO/ReadHelpers.h
+1
-1
dbms/src/IO/WriteHelpers.h
dbms/src/IO/WriteHelpers.h
+1
-1
dbms/tests/queries/0_stateless/00472_compare_uuid_with_constant_string.reference
...ateless/00472_compare_uuid_with_constant_string.reference
+0
-0
dbms/tests/queries/0_stateless/00472_compare_uuid_with_constant_string.sql
...s/0_stateless/00472_compare_uuid_with_constant_string.sql
+0
-0
未找到文件。
dbms/src/Columns/ColumnVector.cpp
浏览文件 @
c6a50834
...
...
@@ -307,11 +307,11 @@ template class ColumnVector<UInt8>;
template
class
ColumnVector
<
UInt16
>;
template
class
ColumnVector
<
UInt32
>;
template
class
ColumnVector
<
UInt64
>;
template
class
ColumnVector
<
UInt128
>;
template
class
ColumnVector
<
Int8
>;
template
class
ColumnVector
<
Int16
>;
template
class
ColumnVector
<
Int32
>;
template
class
ColumnVector
<
Int64
>;
template
class
ColumnVector
<
Float32
>;
template
class
ColumnVector
<
Float64
>;
template
class
ColumnVector
<
UUID
>;
}
dbms/src/Common/UInt128.h
浏览文件 @
c6a50834
...
...
@@ -29,15 +29,15 @@ struct UInt128
explicit
UInt128
(
const
UInt64
low
,
const
UInt64
high
)
:
low
(
low
),
high
(
high
)
{
}
bool
inline
operator
==
(
const
UInt128
rhs
)
const
{
return
std
::
tie
(
low
,
high
)
==
std
::
tie
(
rhs
.
low
,
rhs
.
high
);
}
bool
inline
operator
!=
(
const
UInt128
rhs
)
const
{
return
!
(
*
this
==
rhs
);
}
bool
inline
operator
!=
(
const
UInt128
rhs
)
const
{
return
!
operator
==
(
rhs
);
}
bool
inline
operator
<
(
const
UInt128
rhs
)
const
{
return
std
::
tie
(
low
,
high
)
<
std
::
tie
(
rhs
.
low
,
rhs
.
high
);
}
bool
inline
operator
<=
(
const
UInt128
rhs
)
const
{
return
!
(
rhs
<
*
this
);
}
bool
inline
operator
>
(
const
UInt128
rhs
)
const
{
return
rhs
<
*
this
;
}
bool
inline
operator
>=
(
const
UInt128
rhs
)
const
{
return
!
(
*
this
<
rhs
);
}
bool
inline
operator
<=
(
const
UInt128
rhs
)
const
{
return
!
rhs
.
operator
<
(
*
this
);
}
bool
inline
operator
>
(
const
UInt128
rhs
)
const
{
return
rhs
.
operator
<
(
*
this
)
;
}
bool
inline
operator
>=
(
const
UInt128
rhs
)
const
{
return
!
operator
<
(
rhs
);
}
/** Type
stored in the database will contain no more than 64 bits at the moment, don't need
*
to check the `high` element
/** Type
s who are stored at the moment in the database have no more than 64bits and can be handle
*
inside an unique UInt64.
*/
template
<
typename
T
>
bool
inline
operator
==
(
const
T
rhs
)
const
{
return
*
this
==
UInt128
(
0
,
rhs
);
}
template
<
typename
T
>
bool
inline
operator
!=
(
const
T
rhs
)
const
{
return
*
this
!=
UInt128
(
0
,
rhs
);
}
...
...
@@ -62,6 +62,9 @@ template<typename T> bool inline operator> (T a, const UInt128 b) { return b.lo
template
<
typename
T
>
bool
inline
operator
<=
(
T
a
,
const
UInt128
b
)
{
return
b
.
low
!=
0
||
a
<=
static_cast
<
T
>
(
b
.
high
);
}
template
<
typename
T
>
bool
inline
operator
<
(
T
a
,
const
UInt128
b
)
{
return
b
.
low
!=
0
||
a
<
static_cast
<
T
>
(
b
.
high
);
}
template
<
>
struct
IsNumber
<
UInt128
>
{
static
constexpr
bool
value
=
true
;
};
template
<
>
struct
TypeName
<
UInt128
>
{
static
std
::
string
get
()
{
return
"UInt128"
;
}
};
struct
UInt128Hash
{
size_t
operator
()(
UInt128
x
)
const
...
...
@@ -199,4 +202,15 @@ template <> struct is_unsigned<DB::UInt128>
{
static
constexpr
bool
value
=
true
;
};
template
<
>
struct
is_integral
<
DB
::
UInt128
>
{
static
constexpr
bool
value
=
true
;
};
// Operator +, -, /, *, % aren't implemented so it's not an arithmetic type
template
<
>
struct
is_arithmetic
<
DB
::
UInt128
>
{
static
constexpr
bool
value
=
false
;
};
}
dbms/src/Core/AccurateComparison.h
浏览文件 @
c6a50834
...
...
@@ -31,7 +31,7 @@ using DB::UInt64;
// Case 1. Is pair of floats or pair of ints or pair of uints
template
<
typename
A
,
typename
B
>
using
is_safe_conversion
=
std
::
integral_constant
<
bool
,
(
std
::
is_floating_point
<
A
>::
value
&&
std
::
is_floating_point
<
B
>::
value
)
||
(
(
std
::
is_integral
<
A
>::
value
||
std
::
is_same
<
A
,
DB
::
UInt128
>::
value
)
&&
(
std
::
is_integral
<
B
>::
value
||
std
::
is_same
<
B
,
DB
::
UInt128
>::
value
)
&&
!
(
std
::
is_signed
<
A
>::
value
^
std
::
is_signed
<
B
>::
value
))
>
;
||
(
std
::
is_integral
<
A
>::
value
&&
std
::
is_integral
<
B
>::
value
&&
!
(
std
::
is_signed
<
A
>::
value
^
std
::
is_signed
<
B
>::
value
))
>
;
template
<
typename
A
,
typename
B
>
using
bool_if_safe_conversion
=
std
::
enable_if_t
<
is_safe_conversion
<
A
,
B
>::
value
,
bool
>
;
template
<
typename
A
,
typename
B
>
...
...
@@ -41,8 +41,8 @@ using bool_if_not_safe_conversion = std::enable_if_t<!is_safe_conversion<A, B>::
/// Case 2. Are params IntXX and UIntYY ?
template
<
typename
TInt
,
typename
TUInt
>
using
is_any_int_vs_uint
=
std
::
integral_constant
<
bool
,
std
::
is_integral
<
TInt
>::
value
&&
(
std
::
is_integral
<
TUInt
>::
value
||
std
::
is_same
<
TUInt
,
DB
::
UInt128
>::
value
)
&&
std
::
is_signed
<
TInt
>::
value
&&
(
std
::
is_unsigned
<
TUInt
>::
value
||
std
::
is_same
<
TUInt
,
DB
::
UInt128
>::
value
)
>
;
std
::
is_integral
<
TInt
>::
value
&&
std
::
is_integral
<
TUInt
>::
value
&&
std
::
is_signed
<
TInt
>::
value
&&
std
::
is_unsigned
<
TUInt
>::
value
>
;
// Case 2a. Are params IntXX and UIntYY and sizeof(IntXX) >= sizeof(UIntYY) (in such case will use accurate compare)
...
...
@@ -112,7 +112,7 @@ inline bool_if_gt_int_vs_uint<TInt, TUInt> equalsOpTmpl(TUInt a, TInt b)
// Case 3a. Comparison via conversion to double.
template
<
typename
TAInt
,
typename
TAFloat
>
using
bool_if_double_can_be_used
=
std
::
enable_if_t
<
std
::
is_integral
<
TAInt
>::
value
&&
(
sizeof
(
TAInt
)
<=
4
||
sizeof
(
DB
::
UInt128
)
==
sizeof
(
TAInt
)
)
&&
std
::
is_floating_point
<
TAFloat
>::
value
,
std
::
is_integral
<
TAInt
>::
value
&&
(
sizeof
(
TAInt
)
<=
4
)
&&
std
::
is_floating_point
<
TAFloat
>::
value
,
bool
>
;
template
<
typename
TAInt
,
typename
TAFloat
>
...
...
@@ -228,13 +228,13 @@ inline bool greaterOp<DB::UInt64, DB::Float32>(DB::UInt64 u, DB::Float32 f)
template
<
>
inline
bool
greaterOp
<
DB
::
Float64
,
DB
::
UInt128
>
(
DB
::
Float64
f
,
DB
::
UInt128
u
)
{
return
f
>
u
&&
greaterOp
(
f
,
static_cast
<
UInt64
>
(
u
)
);
return
u
.
low
==
0
&&
greaterOp
(
f
,
u
.
high
);
}
template
<
>
inline
bool
greaterOp
<
DB
::
UInt128
,
DB
::
Float64
>
(
DB
::
UInt128
u
,
DB
::
Float64
f
)
{
return
u
>
f
&&
greaterOp
(
static_cast
<
UInt64
>
(
u
)
,
f
);
return
u
.
low
!=
0
||
greaterOp
(
u
.
high
,
f
);
}
template
<
>
...
...
@@ -312,7 +312,7 @@ inline bool equalsOp<DB::Int64, DB::Float32>(DB::Int64 u, DB::Float32 f)
template
<
>
inline
bool
equalsOp
<
DB
::
UInt128
,
DB
::
Float64
>
(
DB
::
UInt128
u
,
DB
::
Float64
f
)
{
return
u
==
f
&&
equalsOp
(
static_cast
<
UInt64
>
(
u
),
f
);
return
u
.
low
==
0
&&
equalsOp
(
static_cast
<
UInt64
>
(
u
.
high
),
f
);
}
template
<
>
...
...
@@ -324,7 +324,7 @@ inline bool equalsOp<DB::UInt128, DB::Float32>(DB::UInt128 u, DB::Float32 f)
template
<
>
inline
bool
equalsOp
<
DB
::
Float64
,
DB
::
UInt128
>
(
DB
::
Float64
f
,
DB
::
UInt128
u
)
{
return
f
==
u
&&
equalsOp
(
f
,
static_cast
<
UInt64
>
(
u
)
);
return
equalsOp
(
u
,
f
);
}
template
<
>
...
...
dbms/src/Core/UUID.h
浏览文件 @
c6a50834
...
...
@@ -7,7 +7,4 @@ namespace DB
using
UUID
=
DB
::
UInt128
;
template
<
>
struct
IsNumber
<
UUID
>
{
static
constexpr
bool
value
=
true
;
};
template
<
>
struct
TypeName
<
UUID
>
{
static
std
::
string
get
()
{
return
"UUID"
;
}
};
}
dbms/src/DataTypes/DataTypeNumberBase.cpp
浏览文件 @
c6a50834
...
...
@@ -23,13 +23,13 @@ void DataTypeNumberBase<T>::serializeTextEscaped(const IColumn & column, size_t
template
<
typename
T
>
static
void
readTextUnsafeIfIntegral
(
typename
std
::
enable_if
<
std
::
is_integral
<
T
>::
value
,
T
>::
type
&
x
,
ReadBuffer
&
istr
)
static
void
readTextUnsafeIfIntegral
(
typename
std
::
enable_if
<
std
::
is_integral
<
T
>::
value
&&
std
::
is_arithmetic
<
T
>::
value
,
T
>::
type
&
x
,
ReadBuffer
&
istr
)
{
readIntTextUnsafe
(
x
,
istr
);
}
template
<
typename
T
>
static
void
readTextUnsafeIfIntegral
(
typename
std
::
enable_if
<!
std
::
is_integral
<
T
>::
value
,
T
>::
type
&
x
,
ReadBuffer
&
istr
)
static
void
readTextUnsafeIfIntegral
(
typename
std
::
enable_if
<!
std
::
is_integral
<
T
>::
value
||
!
std
::
is_arithmetic
<
T
>::
value
,
T
>::
type
&
x
,
ReadBuffer
&
istr
)
{
readText
(
x
,
istr
);
}
...
...
dbms/src/DataTypes/DataTypeUUID.h
浏览文件 @
c6a50834
...
...
@@ -14,7 +14,8 @@ class DataTypeUUID final : public DataTypeNumberBase<UInt128>
public:
bool
behavesAsNumber
()
const
override
{
return
false
;
}
std
::
string
getName
()
const
override
{
return
"UUID"
;
}
DataTypePtr
clone
()
const
override
{
return
std
::
make_shared
<
DataTypeUUID
>
();
}
void
serializeText
(
const
IColumn
&
column
,
size_t
row_num
,
WriteBuffer
&
ostr
)
const
override
;
...
...
dbms/src/DataTypes/DataTypesNumber.h
浏览文件 @
c6a50834
...
...
@@ -17,6 +17,7 @@ using DataTypeUInt8 = DataTypeNumber<UInt8>;
using
DataTypeUInt16
=
DataTypeNumber
<
UInt16
>
;
using
DataTypeUInt32
=
DataTypeNumber
<
UInt32
>
;
using
DataTypeUInt64
=
DataTypeNumber
<
UInt64
>
;
using
DataTypeUInt128
=
DataTypeNumber
<
UInt128
>
;
using
DataTypeInt8
=
DataTypeNumber
<
Int8
>
;
using
DataTypeInt16
=
DataTypeNumber
<
Int16
>
;
using
DataTypeInt32
=
DataTypeNumber
<
Int32
>
;
...
...
dbms/src/DataTypes/FieldToDataType.cpp
浏览文件 @
c6a50834
...
...
@@ -175,7 +175,7 @@ DataTypePtr FieldToDataType::operator() (Array & x) const
return
wrap_into_array
(
std
::
make_shared
<
DataTypeString
>
());
if
(
has_uint128
)
return
wrap_into_array
(
std
::
make_shared
<
DataTypeU
UID
>
());
return
wrap_into_array
(
std
::
make_shared
<
DataTypeU
Int128
>
());
if
(
has_float
&&
max_bits
==
64
)
throw
Exception
(
"Incompatible types Float64 and UInt64/Int64 of elements of array"
,
ErrorCodes
::
ILLEGAL_TYPE_OF_ARGUMENT
);
...
...
dbms/src/Dictionaries/MongoDBBlockInputStream.cpp
浏览文件 @
c6a50834
...
...
@@ -132,7 +132,6 @@ namespace
static_cast
<
const
Poco
::
MongoDB
::
ConcreteElement
<
Poco
::
Timestamp
>
&>
(
value
).
value
().
epochTime
());
break
;
}
}
}
}
...
...
dbms/src/IO/ReadHelpers.h
浏览文件 @
c6a50834
...
...
@@ -605,7 +605,7 @@ inline void readUUIDText(UUID & uuid, ReadBuffer & buf)
throw
Exception
(
std
::
string
(
"Cannot parse uuid "
)
+
s
,
ErrorCodes
::
CANNOT_PARSE_UUID
);
}
parseUUID
(
(
const
UInt8
*
)
s
,
uuid
);
parseUUID
(
reinterpret_cast
<
const
UInt8
*>
(
s
)
,
uuid
);
}
...
...
dbms/src/IO/WriteHelpers.h
浏览文件 @
c6a50834
...
...
@@ -481,7 +481,7 @@ inline void writeUUIDText(const UUID & uuid, WriteBuffer & buf)
{
char
s
[
36
];
formatUUID
(
uuid
,
(
UInt8
*
)
s
);
formatUUID
(
uuid
,
reinterpret_cast
<
UInt8
*>
(
s
)
);
buf
.
write
(
s
,
sizeof
(
s
));
}
...
...
dbms/tests/queries/0_stateless/004
63
_compare_uuid_with_constant_string.reference
→
dbms/tests/queries/0_stateless/004
72
_compare_uuid_with_constant_string.reference
浏览文件 @
c6a50834
文件已移动
dbms/tests/queries/0_stateless/004
63
_compare_uuid_with_constant_string.sql
→
dbms/tests/queries/0_stateless/004
72
_compare_uuid_with_constant_string.sql
浏览文件 @
c6a50834
文件已移动
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录