Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
dbe5dda3
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,发现更多精彩内容 >>
提交
dbe5dda3
编写于
8月 15, 2011
作者:
A
Alexey Milovidov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
dbms: development [#CONV-2944].
上级
47453e75
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
116 addition
and
27 deletion
+116
-27
dbms/include/DB/Core/ErrorCodes.h
dbms/include/DB/Core/ErrorCodes.h
+1
-0
dbms/include/DB/DataTypes/DataTypeDate.h
dbms/include/DB/DataTypes/DataTypeDate.h
+2
-2
dbms/include/DB/DataTypes/DataTypeFactory.h
dbms/include/DB/DataTypes/DataTypeFactory.h
+33
-0
dbms/include/DB/DataTypes/IDataTypeNumber.h
dbms/include/DB/DataTypes/IDataTypeNumber.h
+3
-1
dbms/include/DB/Functions/FunctionsArithmetic.h
dbms/include/DB/Functions/FunctionsArithmetic.h
+30
-24
dbms/src/DataTypes/DataTypeFactory.cpp
dbms/src/DataTypes/DataTypeFactory.cpp
+47
-0
未找到文件。
dbms/include/DB/Core/ErrorCodes.h
浏览文件 @
dbe5dda3
...
...
@@ -57,6 +57,7 @@ namespace ErrorCodes
UNKNOWN_IDENTIFIER
,
NOT_IMPLEMENTED
,
LOGICAL_ERROR
,
UNKNOWN_TYPE
,
};
}
...
...
dbms/include/DB/DataTypes/DataTypeDate.h
浏览文件 @
dbe5dda3
...
...
@@ -20,14 +20,14 @@ public:
void
serializeText
(
const
Field
&
field
,
WriteBuffer
&
ostr
)
const
{
writeDateText
(
boost
::
get
<
UInt64
>
(
field
),
ostr
);
writeDateText
(
Yandex
::
DayNum_t
(
boost
::
get
<
UInt64
>
(
field
)
),
ostr
);
}
void
deserializeText
(
Field
&
field
,
ReadBuffer
&
istr
)
const
{
Yandex
::
DayNum_t
x
;
readDateText
(
x
,
istr
);
field
=
x
;
field
=
static_cast
<
UInt64
>
(
x
)
;
}
void
serializeTextEscaped
(
const
Field
&
field
,
WriteBuffer
&
ostr
)
const
...
...
dbms/include/DB/DataTypes/DataTypeFactory.h
0 → 100644
浏览文件 @
dbe5dda3
#pragma once
#include <Poco/RegularExpression.h>
#include <DB/DataTypes/DataTypesNumberFixed.h>
#include <DB/DataTypes/DataTypesNumberVariable.h>
#include <DB/DataTypes/DataTypeDate.h>
#include <DB/DataTypes/DataTypeDateTime.h>
#include <DB/DataTypes/DataTypeString.h>
#include <DB/DataTypes/DataTypeFixedString.h>
namespace
DB
{
/** Позволяет создать тип данных по его имени.
*/
class
DataTypeFactory
{
public:
DataTypeFactory
();
DataTypePtr
get
(
const
String
&
name
);
private:
typedef
std
::
map
<
String
,
DataTypePtr
>
NonParametricDataTypes
;
NonParametricDataTypes
non_parametric_data_types
;
Poco
::
RegularExpression
fixed_string_regexp
;
};
}
dbms/include/DB/DataTypes/IDataTypeNumber.h
浏览文件 @
dbe5dda3
...
...
@@ -14,10 +14,12 @@ namespace DB
/** Реализует часть интерфейса IDataType, общую для всяких чисел
* - ввод и вывод в текстовом виде.
*/
template
<
typename
F
ield
Type
>
template
<
typename
FType
>
class
IDataTypeNumber
:
public
IDataType
{
public:
typedef
FType
FieldType
;
void
serializeText
(
const
Field
&
field
,
WriteBuffer
&
ostr
)
const
{
writeText
(
boost
::
get
<
typename
NearestFieldType
<
FieldType
>::
Type
>
(
field
),
ostr
);
...
...
dbms/include/DB/Functions/FunctionsArithmetic.h
浏览文件 @
dbe5dda3
...
...
@@ -3,6 +3,7 @@
#include <Poco/NumberFormatter.h>
#include <DB/DataTypes/DataTypesNumberFixed.h>
#include <DB/DataTypes/DataTypesNumberVariable.h>
#include <DB/Functions/IFunction.h>
#include <DB/Functions/NumberTraits.h>
...
...
@@ -12,7 +13,7 @@ namespace DB
/** Арифметические функции: +, -, *, /, %,
* div (целочисленное деление),
* TODO: <<, >>, <<<, >>>, &, |, ^,
&&, ||, ^^, !
* TODO: <<, >>, <<<, >>>, &, |, ^,
~
*/
template
<
typename
A
,
typename
B
>
...
...
@@ -215,9 +216,10 @@ private:
template
<
typename
T0
,
typename
T1
>
bool
checkRightType
(
const
DataTypes
&
arguments
,
DataTypes
&
types_res
)
const
{
if
(
dynamic_cast
<
const
typename
DataTypeFromFieldType
<
T1
>::
Type
*>
(
&*
arguments
[
1
]))
if
(
dynamic_cast
<
const
T1
*>
(
&*
arguments
[
1
]))
{
types_res
.
push_back
(
new
typename
DataTypeFromFieldType
<
typename
Impl
<
T0
,
T1
>::
ResultType
>::
Type
);
types_res
.
push_back
(
new
typename
DataTypeFromFieldType
<
typename
Impl
<
typename
T0
::
FieldType
,
typename
T1
::
FieldType
>::
ResultType
>::
Type
);
return
true
;
}
return
false
;
...
...
@@ -226,18 +228,20 @@ private:
template
<
typename
T0
>
bool
checkLeftType
(
const
DataTypes
&
arguments
,
DataTypes
&
types_res
)
const
{
if
(
dynamic_cast
<
const
typename
DataTypeFromFieldType
<
T0
>::
Type
*>
(
&*
arguments
[
0
]))
if
(
dynamic_cast
<
const
T0
*>
(
&*
arguments
[
0
]))
{
if
(
checkRightType
<
T0
,
UInt8
>
(
arguments
,
types_res
)
||
checkRightType
<
T0
,
UInt16
>
(
arguments
,
types_res
)
||
checkRightType
<
T0
,
UInt32
>
(
arguments
,
types_res
)
||
checkRightType
<
T0
,
UInt64
>
(
arguments
,
types_res
)
||
checkRightType
<
T0
,
Int8
>
(
arguments
,
types_res
)
||
checkRightType
<
T0
,
Int16
>
(
arguments
,
types_res
)
||
checkRightType
<
T0
,
Int32
>
(
arguments
,
types_res
)
||
checkRightType
<
T0
,
Int64
>
(
arguments
,
types_res
)
||
checkRightType
<
T0
,
Float32
>
(
arguments
,
types_res
)
||
checkRightType
<
T0
,
Float64
>
(
arguments
,
types_res
))
if
(
checkRightType
<
T0
,
DataTypeUInt8
>
(
arguments
,
types_res
)
||
checkRightType
<
T0
,
DataTypeUInt16
>
(
arguments
,
types_res
)
||
checkRightType
<
T0
,
DataTypeUInt32
>
(
arguments
,
types_res
)
||
checkRightType
<
T0
,
DataTypeUInt64
>
(
arguments
,
types_res
)
||
checkRightType
<
T0
,
DataTypeInt8
>
(
arguments
,
types_res
)
||
checkRightType
<
T0
,
DataTypeInt16
>
(
arguments
,
types_res
)
||
checkRightType
<
T0
,
DataTypeInt32
>
(
arguments
,
types_res
)
||
checkRightType
<
T0
,
DataTypeInt64
>
(
arguments
,
types_res
)
||
checkRightType
<
T0
,
DataTypeFloat32
>
(
arguments
,
types_res
)
||
checkRightType
<
T0
,
DataTypeFloat64
>
(
arguments
,
types_res
)
||
checkRightType
<
T0
,
DataTypeVarUInt
>
(
arguments
,
types_res
)
||
checkRightType
<
T0
,
DataTypeVarInt
>
(
arguments
,
types_res
))
return
true
;
else
throw
Exception
(
"Illegal type "
+
arguments
[
1
]
->
getName
()
+
" of second argument of function "
+
getName
(),
...
...
@@ -370,16 +374,18 @@ public:
DataTypes
types_res
;
if
(
!
(
checkLeftType
<
UInt8
>
(
arguments
,
types_res
)
||
checkLeftType
<
UInt16
>
(
arguments
,
types_res
)
||
checkLeftType
<
UInt32
>
(
arguments
,
types_res
)
||
checkLeftType
<
UInt64
>
(
arguments
,
types_res
)
||
checkLeftType
<
Int8
>
(
arguments
,
types_res
)
||
checkLeftType
<
Int16
>
(
arguments
,
types_res
)
||
checkLeftType
<
Int32
>
(
arguments
,
types_res
)
||
checkLeftType
<
Int64
>
(
arguments
,
types_res
)
||
checkLeftType
<
Float32
>
(
arguments
,
types_res
)
||
checkLeftType
<
Float64
>
(
arguments
,
types_res
)))
if
(
!
(
checkLeftType
<
DataTypeUInt8
>
(
arguments
,
types_res
)
||
checkLeftType
<
DataTypeUInt16
>
(
arguments
,
types_res
)
||
checkLeftType
<
DataTypeUInt32
>
(
arguments
,
types_res
)
||
checkLeftType
<
DataTypeUInt64
>
(
arguments
,
types_res
)
||
checkLeftType
<
DataTypeInt8
>
(
arguments
,
types_res
)
||
checkLeftType
<
DataTypeInt16
>
(
arguments
,
types_res
)
||
checkLeftType
<
DataTypeInt32
>
(
arguments
,
types_res
)
||
checkLeftType
<
DataTypeInt64
>
(
arguments
,
types_res
)
||
checkLeftType
<
DataTypeFloat32
>
(
arguments
,
types_res
)
||
checkLeftType
<
DataTypeFloat64
>
(
arguments
,
types_res
)
||
checkLeftType
<
DataTypeVarUInt
>
(
arguments
,
types_res
)
||
checkLeftType
<
DataTypeVarInt
>
(
arguments
,
types_res
)))
throw
Exception
(
"Illegal type "
+
arguments
[
0
]
->
getName
()
+
" of first argument of function "
+
getName
(),
ErrorCodes
::
ILLEGAL_TYPE_OF_ARGUMENT
);
...
...
dbms/src/DataTypes/DataTypeFactory.cpp
0 → 100644
浏览文件 @
dbe5dda3
#include <boost/assign/list_inserter.hpp>
#include <mysqlxx/String.h>
#include <DB/DataTypes/DataTypeFactory.h>
namespace
DB
{
DataTypeFactory
::
DataTypeFactory
()
:
fixed_string_regexp
(
"^FixedString
\\
s*
\\
(
\\
s*(
\\
d+)
\\
s*
\\
)$"
)
{
boost
::
assign
::
insert
(
non_parametric_data_types
)
(
"UInt8"
,
new
DataTypeUInt8
)
(
"UInt16"
,
new
DataTypeUInt16
)
(
"UInt32"
,
new
DataTypeUInt32
)
(
"UInt64"
,
new
DataTypeUInt64
)
(
"Int8"
,
new
DataTypeInt8
)
(
"Int16"
,
new
DataTypeInt16
)
(
"Int32"
,
new
DataTypeInt32
)
(
"Int64"
,
new
DataTypeInt64
)
(
"Float32"
,
new
DataTypeFloat32
)
(
"Float64"
,
new
DataTypeFloat64
)
(
"VarUInt"
,
new
DataTypeVarUInt
)
(
"VarInt"
,
new
DataTypeVarInt
)
(
"String"
,
new
DataTypeString
)
;
}
DataTypePtr
DataTypeFactory
::
get
(
const
String
&
name
)
{
NonParametricDataTypes
::
iterator
it
=
non_parametric_data_types
.
find
(
name
);
if
(
it
!=
non_parametric_data_types
.
end
())
return
it
->
second
;
Poco
::
RegularExpression
::
MatchVec
matches
;
if
(
fixed_string_regexp
.
match
(
name
,
0
,
matches
)
&&
matches
.
size
()
==
2
)
return
new
DataTypeFixedString
(
mysqlxx
::
String
(
name
.
data
()
+
matches
[
0
].
offset
,
matches
[
0
].
length
,
NULL
).
getUInt
());
throw
Exception
(
"Unknown type "
+
name
,
ErrorCodes
::
UNKNOWN_TYPE
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录