Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
477c7245
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,发现更多精彩内容 >>
提交
477c7245
编写于
2月 01, 2016
作者:
A
Alexey Milovidov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
dbms: added function regionToTopContinent [#METR-19807].
上级
14854540
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
34 addition
and
5 deletion
+34
-5
dbms/include/DB/Dictionaries/Embedded/RegionsHierarchy.h
dbms/include/DB/Dictionaries/Embedded/RegionsHierarchy.h
+17
-4
dbms/include/DB/Functions/FunctionsDictionaries.h
dbms/include/DB/Functions/FunctionsDictionaries.h
+16
-1
dbms/src/Functions/FunctionsDictionaries.cpp
dbms/src/Functions/FunctionsDictionaries.cpp
+1
-0
未找到文件。
dbms/include/DB/Dictionaries/Embedded/RegionsHierarchy.h
浏览文件 @
477c7245
...
...
@@ -54,8 +54,10 @@ private:
RegionParents
area
;
/// регион -> округ, включающий его или 0, если такого нет
RegionParents
district
;
/// регион -> континет, включающий его или 0, если такого нет
/// регион -> континет
(первый при подъёме по иерархии регионов)
, включающий его или 0, если такого нет
RegionParents
continent
;
/// регион -> континет (последний при подъёме по иерархии регионов), включающий его или 0, если такого нет
RegionParents
top_continent
;
/// регион -> население или 0, если неизвестно.
RegionPopulations
populations
;
...
...
@@ -88,6 +90,7 @@ public:
RegionParents
new_area
(
initial_size
);
RegionParents
new_district
(
initial_size
);
RegionParents
new_continent
(
initial_size
);
RegionParents
new_top_continent
(
initial_size
);
RegionPopulations
new_populations
(
initial_size
);
RegionDepths
new_depths
(
initial_size
);
RegionTypes
types
(
initial_size
);
...
...
@@ -151,6 +154,7 @@ public:
new_area
.
resize
(
max_region_id
+
1
);
new_district
.
resize
(
max_region_id
+
1
);
new_continent
.
resize
(
max_region_id
+
1
);
new_top_continent
.
resize
(
max_region_id
+
1
);
new_populations
.
resize
(
max_region_id
+
1
);
new_depths
.
resize
(
max_region_id
+
1
);
types
.
resize
(
max_region_id
+
1
);
...
...
@@ -173,7 +177,7 @@ public:
if
(
types
[
i
]
==
REGION_TYPE_CONTINENT
)
{
new_continent
[
i
]
=
i
;
continue
;
new_top_continent
[
i
]
=
i
;
}
RegionDepth
depth
=
0
;
...
...
@@ -203,8 +207,9 @@ public:
if
(
types
[
current
]
==
REGION_TYPE_CONTINENT
)
{
new_continent
[
i
]
=
current
;
break
;
if
(
!
new_continent
[
i
])
new_continent
[
i
]
=
current
;
new_top_continent
[
i
]
=
current
;
}
}
...
...
@@ -217,6 +222,7 @@ public:
area
.
swap
(
new_area
);
district
.
swap
(
new_district
);
continent
.
swap
(
new_continent
);
top_continent
.
swap
(
new_top_continent
);
populations
.
swap
(
new_populations
);
depths
.
swap
(
new_depths
);
}
...
...
@@ -268,6 +274,13 @@ public:
return
continent
[
region
];
}
RegionID
toTopContinent
(
RegionID
region
)
const
{
if
(
static_cast
<
size_t
>
(
region
)
>=
top_continent
.
size
())
return
0
;
return
top_continent
[
region
];
}
RegionID
toParent
(
RegionID
region
)
const
{
if
(
static_cast
<
size_t
>
(
region
)
>=
parents
.
size
())
...
...
dbms/include/DB/Functions/FunctionsDictionaries.h
浏览文件 @
477c7245
...
...
@@ -38,7 +38,7 @@ namespace ErrorCodes
* - словари регионов, операционных систем, поисковых систем.
*
* Подняться по дереву до определенного уровня.
* regionToCity, regionToArea, regionToCountry,
* regionToCity, regionToArea, regionToCountry,
...
* OSToRoot,
* SEToRoot,
*
...
...
@@ -91,6 +91,11 @@ struct RegionToContinentImpl
static
UInt32
apply
(
UInt32
x
,
const
RegionsHierarchy
&
hierarchy
)
{
return
hierarchy
.
toContinent
(
x
);
}
};
struct
RegionToTopContinentImpl
{
static
UInt32
apply
(
UInt32
x
,
const
RegionsHierarchy
&
hierarchy
)
{
return
hierarchy
.
toTopContinent
(
x
);
}
};
struct
RegionToPopulationImpl
{
static
UInt32
apply
(
UInt32
x
,
const
RegionsHierarchy
&
hierarchy
)
{
return
hierarchy
.
getPopulation
(
x
);
}
...
...
@@ -513,6 +518,7 @@ struct NameRegionToArea { static constexpr auto name = "regionToArea"; };
struct
NameRegionToDistrict
{
static
constexpr
auto
name
=
"regionToDistrict"
;
};
struct
NameRegionToCountry
{
static
constexpr
auto
name
=
"regionToCountry"
;
};
struct
NameRegionToContinent
{
static
constexpr
auto
name
=
"regionToContinent"
;
};
struct
NameRegionToTopContinent
{
static
constexpr
auto
name
=
"regionToTopContinent"
;
};
struct
NameRegionToPopulation
{
static
constexpr
auto
name
=
"regionToPopulation"
;
};
struct
NameOSToRoot
{
static
constexpr
auto
name
=
"OSToRoot"
;
};
struct
NameSEToRoot
{
static
constexpr
auto
name
=
"SEToRoot"
;
};
...
...
@@ -571,6 +577,15 @@ struct FunctionRegionToContinent :
}
};
struct
FunctionRegionToTopContinent
:
public
FunctionTransformWithDictionary
<
UInt32
,
RegionToTopContinentImpl
,
RegionsHierarchyGetter
,
NameRegionToTopContinent
>
{
static
IFunction
*
create
(
const
Context
&
context
)
{
return
new
base_type
{
context
.
getDictionaries
().
getRegionsHierarchies
()};
}
};
struct
FunctionRegionToPopulation
:
public
FunctionTransformWithDictionary
<
UInt32
,
RegionToPopulationImpl
,
RegionsHierarchyGetter
,
NameRegionToPopulation
>
{
...
...
dbms/src/Functions/FunctionsDictionaries.cpp
浏览文件 @
477c7245
...
...
@@ -11,6 +11,7 @@ void registerFunctionsDictionaries(FunctionFactory & factory)
factory
.
registerFunction
<
FunctionRegionToDistrict
>
();
factory
.
registerFunction
<
FunctionRegionToCountry
>
();
factory
.
registerFunction
<
FunctionRegionToContinent
>
();
factory
.
registerFunction
<
FunctionRegionToTopContinent
>
();
factory
.
registerFunction
<
FunctionRegionToPopulation
>
();
factory
.
registerFunction
<
FunctionOSToRoot
>
();
factory
.
registerFunction
<
FunctionSEToRoot
>
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录