Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
ed107f67
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,发现更多精彩内容 >>
提交
ed107f67
编写于
1月 04, 2017
作者:
A
Alexey Milovidov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Preparations [#METR-20307].
上级
37e1c9d1
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
37 addition
and
24 deletion
+37
-24
dbms/include/DB/Core/Block.h
dbms/include/DB/Core/Block.h
+4
-10
dbms/include/DB/DataTypes/FieldToDataType.h
dbms/include/DB/DataTypes/FieldToDataType.h
+7
-7
dbms/src/Core/Block.cpp
dbms/src/Core/Block.cpp
+20
-1
dbms/src/DataTypes/FieldToDataType.cpp
dbms/src/DataTypes/FieldToDataType.cpp
+6
-6
未找到文件。
dbms/include/DB/Core/Block.h
浏览文件 @
ed107f67
...
@@ -29,7 +29,7 @@ class Context;
...
@@ -29,7 +29,7 @@ class Context;
class
Block
class
Block
{
{
private:
private:
using
Container
=
std
::
vector
<
ColumnWithTypeAndName
>
;
using
Container
=
ColumnsWithTypeAndName
;
using
IndexByName
=
std
::
map
<
String
,
size_t
>
;
using
IndexByName
=
std
::
map
<
String
,
size_t
>
;
Container
data
;
Container
data
;
...
@@ -39,15 +39,8 @@ public:
...
@@ -39,15 +39,8 @@ public:
BlockInfo
info
;
BlockInfo
info
;
Block
()
=
default
;
Block
()
=
default
;
Block
(
std
::
initializer_list
<
ColumnWithTypeAndName
>
il
)
:
data
{
il
}
Block
(
std
::
initializer_list
<
ColumnWithTypeAndName
>
il
);
{
Block
(
const
ColumnsWithTypeAndName
&
data_
);
size_t
i
=
0
;
for
(
const
auto
&
elem
:
il
)
{
index_by_name
[
elem
.
name
]
=
i
;
++
i
;
}
}
/// вставить столбец в заданную позицию
/// вставить столбец в заданную позицию
void
insert
(
size_t
position
,
const
ColumnWithTypeAndName
&
elem
);
void
insert
(
size_t
position
,
const
ColumnWithTypeAndName
&
elem
);
...
@@ -128,6 +121,7 @@ public:
...
@@ -128,6 +121,7 @@ public:
private:
private:
void
eraseImpl
(
size_t
position
);
void
eraseImpl
(
size_t
position
);
void
initializeIndexByName
();
};
};
using
Blocks
=
std
::
vector
<
Block
>
;
using
Blocks
=
std
::
vector
<
Block
>
;
...
...
dbms/include/DB/DataTypes/FieldToDataType.h
浏览文件 @
ed107f67
...
@@ -19,12 +19,12 @@ namespace DB
...
@@ -19,12 +19,12 @@ namespace DB
class
FieldToDataType
:
public
StaticVisitor
<
DataTypePtr
>
class
FieldToDataType
:
public
StaticVisitor
<
DataTypePtr
>
{
{
public:
public:
DataTypePtr
operator
()
(
Null
&
x
)
const
DataTypePtr
operator
()
(
const
Null
&
x
)
const
{
{
return
std
::
make_shared
<
DataTypeNull
>
();
return
std
::
make_shared
<
DataTypeNull
>
();
}
}
DataTypePtr
operator
()
(
UInt64
&
x
)
const
DataTypePtr
operator
()
(
const
UInt64
&
x
)
const
{
{
if
(
x
<=
std
::
numeric_limits
<
UInt8
>::
max
())
return
std
::
make_shared
<
DataTypeUInt8
>
();
if
(
x
<=
std
::
numeric_limits
<
UInt8
>::
max
())
return
std
::
make_shared
<
DataTypeUInt8
>
();
if
(
x
<=
std
::
numeric_limits
<
UInt16
>::
max
())
return
std
::
make_shared
<
DataTypeUInt16
>
();
if
(
x
<=
std
::
numeric_limits
<
UInt16
>::
max
())
return
std
::
make_shared
<
DataTypeUInt16
>
();
...
@@ -32,7 +32,7 @@ public:
...
@@ -32,7 +32,7 @@ public:
return
std
::
make_shared
<
DataTypeUInt64
>
();
return
std
::
make_shared
<
DataTypeUInt64
>
();
}
}
DataTypePtr
operator
()
(
Int64
&
x
)
const
DataTypePtr
operator
()
(
const
Int64
&
x
)
const
{
{
if
(
x
<=
std
::
numeric_limits
<
Int8
>::
max
()
&&
x
>=
std
::
numeric_limits
<
Int8
>::
min
())
return
std
::
make_shared
<
DataTypeInt8
>
();
if
(
x
<=
std
::
numeric_limits
<
Int8
>::
max
()
&&
x
>=
std
::
numeric_limits
<
Int8
>::
min
())
return
std
::
make_shared
<
DataTypeInt8
>
();
if
(
x
<=
std
::
numeric_limits
<
Int16
>::
max
()
&&
x
>=
std
::
numeric_limits
<
Int16
>::
min
())
return
std
::
make_shared
<
DataTypeInt16
>
();
if
(
x
<=
std
::
numeric_limits
<
Int16
>::
max
()
&&
x
>=
std
::
numeric_limits
<
Int16
>::
min
())
return
std
::
make_shared
<
DataTypeInt16
>
();
...
@@ -40,19 +40,19 @@ public:
...
@@ -40,19 +40,19 @@ public:
return
std
::
make_shared
<
DataTypeInt64
>
();
return
std
::
make_shared
<
DataTypeInt64
>
();
}
}
DataTypePtr
operator
()
(
Float64
&
x
)
const
DataTypePtr
operator
()
(
const
Float64
&
x
)
const
{
{
return
std
::
make_shared
<
DataTypeFloat64
>
();
return
std
::
make_shared
<
DataTypeFloat64
>
();
}
}
DataTypePtr
operator
()
(
String
&
x
)
const
DataTypePtr
operator
()
(
const
String
&
x
)
const
{
{
return
std
::
make_shared
<
DataTypeString
>
();
return
std
::
make_shared
<
DataTypeString
>
();
}
}
DataTypePtr
operator
()
(
Array
&
x
)
const
;
DataTypePtr
operator
()
(
const
Array
&
x
)
const
;
DataTypePtr
operator
()
(
Tuple
&
x
)
const
;
DataTypePtr
operator
()
(
const
Tuple
&
x
)
const
;
};
};
}
}
...
...
dbms/src/Core/Block.cpp
浏览文件 @
ed107f67
...
@@ -89,6 +89,25 @@ void Block::addDefaults(const NamesAndTypesList & required_columns)
...
@@ -89,6 +89,25 @@ void Block::addDefaults(const NamesAndTypesList & required_columns)
}
}
Block
::
Block
(
std
::
initializer_list
<
ColumnWithTypeAndName
>
il
)
:
data
{
il
}
{
initializeIndexByName
();
}
Block
::
Block
(
const
ColumnsWithTypeAndName
&
data_
)
:
data
{
data_
}
{
initializeIndexByName
();
}
void
Block
::
initializeIndexByName
()
{
for
(
size_t
i
=
0
,
size
=
data
.
size
();
i
<
size
;
++
i
)
index_by_name
[
data
[
i
].
name
]
=
i
;
}
void
Block
::
insert
(
size_t
position
,
const
ColumnWithTypeAndName
&
elem
)
void
Block
::
insert
(
size_t
position
,
const
ColumnWithTypeAndName
&
elem
)
{
{
if
(
position
>
data
.
size
())
if
(
position
>
data
.
size
())
...
@@ -359,7 +378,7 @@ Block Block::sortColumns() const
...
@@ -359,7 +378,7 @@ Block Block::sortColumns() const
ColumnsWithTypeAndName
Block
::
getColumns
()
const
ColumnsWithTypeAndName
Block
::
getColumns
()
const
{
{
return
ColumnsWithTypeAndName
(
data
.
begin
(),
data
.
end
())
;
return
data
;
}
}
...
...
dbms/src/DataTypes/FieldToDataType.cpp
浏览文件 @
ed107f67
...
@@ -17,9 +17,9 @@ namespace ErrorCodes
...
@@ -17,9 +17,9 @@ namespace ErrorCodes
template
<
typename
T
>
template
<
typename
T
>
static
void
convertArrayToCommonType
(
Array
&
arr
)
static
void
convertArrayToCommonType
(
const
Array
&
arr
)
{
{
for
(
auto
&
elem
:
arr
)
for
(
const
auto
&
elem
:
arr
)
{
{
if
(
!
elem
.
isNull
())
if
(
!
elem
.
isNull
())
elem
=
apply_visitor
(
FieldVisitorConvertToNumber
<
T
>
(),
elem
);
elem
=
apply_visitor
(
FieldVisitorConvertToNumber
<
T
>
(),
elem
);
...
@@ -27,7 +27,7 @@ static void convertArrayToCommonType(Array & arr)
...
@@ -27,7 +27,7 @@ static void convertArrayToCommonType(Array & arr)
}
}
DataTypePtr
FieldToDataType
::
operator
()
(
Array
&
x
)
const
DataTypePtr
FieldToDataType
::
operator
()
(
const
Array
&
x
)
const
{
{
if
(
x
.
empty
())
if
(
x
.
empty
())
throw
Exception
(
"Cannot infer type of empty array"
,
ErrorCodes
::
EMPTY_DATA_PASSED
);
throw
Exception
(
"Cannot infer type of empty array"
,
ErrorCodes
::
EMPTY_DATA_PASSED
);
...
@@ -207,16 +207,16 @@ DataTypePtr FieldToDataType::operator() (Array & x) const
...
@@ -207,16 +207,16 @@ DataTypePtr FieldToDataType::operator() (Array & x) const
}
}
DataTypePtr
FieldToDataType
::
operator
()
(
Tuple
&
x
)
const
DataTypePtr
FieldToDataType
::
operator
()
(
const
Tuple
&
x
)
const
{
{
auto
&
tuple
=
static_cast
<
TupleBackend
&>
(
x
);
const
auto
&
tuple
=
static_cast
<
const
TupleBackend
&>
(
x
);
if
(
tuple
.
empty
())
if
(
tuple
.
empty
())
throw
Exception
(
"Cannot infer type of an empty tuple"
,
ErrorCodes
::
EMPTY_DATA_PASSED
);
throw
Exception
(
"Cannot infer type of an empty tuple"
,
ErrorCodes
::
EMPTY_DATA_PASSED
);
DataTypes
element_types
;
DataTypes
element_types
;
element_types
.
reserve
(
ext
::
size
(
tuple
));
element_types
.
reserve
(
ext
::
size
(
tuple
));
for
(
auto
&
element
:
tuple
)
for
(
const
auto
&
element
:
tuple
)
element_types
.
push_back
(
apply_visitor
(
FieldToDataType
{},
element
));
element_types
.
push_back
(
apply_visitor
(
FieldToDataType
{},
element
));
return
std
::
make_shared
<
DataTypeTuple
>
(
element_types
);
return
std
::
make_shared
<
DataTypeTuple
>
(
element_types
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录