Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
10f69eef
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,发现更多精彩内容 >>
提交
10f69eef
编写于
10月 21, 2019
作者:
A
alesapin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add tests for non standart dictionaries and fix bugs
上级
ff7850cf
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
49 addition
and
15 deletion
+49
-15
dbms/src/Dictionaries/CacheDictionary.cpp
dbms/src/Dictionaries/CacheDictionary.cpp
+1
-1
dbms/src/Dictionaries/ComplexKeyCacheDictionary.cpp
dbms/src/Dictionaries/ComplexKeyCacheDictionary.cpp
+1
-1
dbms/src/Dictionaries/ComplexKeyHashedDictionary.cpp
dbms/src/Dictionaries/ComplexKeyHashedDictionary.cpp
+1
-1
dbms/src/Dictionaries/DictionaryFactory.cpp
dbms/src/Dictionaries/DictionaryFactory.cpp
+4
-1
dbms/src/Dictionaries/DictionaryFactory.h
dbms/src/Dictionaries/DictionaryFactory.h
+5
-1
dbms/src/Dictionaries/FlatDictionary.cpp
dbms/src/Dictionaries/FlatDictionary.cpp
+1
-1
dbms/src/Dictionaries/HashedDictionary.cpp
dbms/src/Dictionaries/HashedDictionary.cpp
+2
-2
dbms/src/Dictionaries/RangeHashedDictionary.cpp
dbms/src/Dictionaries/RangeHashedDictionary.cpp
+1
-1
dbms/src/Dictionaries/TrieDictionary.cpp
dbms/src/Dictionaries/TrieDictionary.cpp
+1
-1
dbms/src/Dictionaries/getDictionaryConfigurationFromAST.cpp
dbms/src/Dictionaries/getDictionaryConfigurationFromAST.cpp
+3
-2
dbms/src/Dictionaries/tests/gtest_dictionary_configuration.cpp
...src/Dictionaries/tests/gtest_dictionary_configuration.cpp
+29
-3
未找到文件。
dbms/src/Dictionaries/CacheDictionary.cpp
浏览文件 @
10f69eef
...
...
@@ -611,7 +611,7 @@ void registerDictionaryCache(DictionaryFactory & factory)
const
DictionaryLifetime
dict_lifetime
{
config
,
config_prefix
+
".lifetime"
};
return
std
::
make_unique
<
CacheDictionary
>
(
name
,
dict_struct
,
std
::
move
(
source_ptr
),
dict_lifetime
,
size
);
};
factory
.
registerLayout
(
"cache"
,
create_layout
);
factory
.
registerLayout
(
"cache"
,
create_layout
,
false
);
}
...
...
dbms/src/Dictionaries/ComplexKeyCacheDictionary.cpp
浏览文件 @
10f69eef
...
...
@@ -415,7 +415,7 @@ void registerDictionaryComplexKeyCache(DictionaryFactory & factory)
const
DictionaryLifetime
dict_lifetime
{
config
,
config_prefix
+
".lifetime"
};
return
std
::
make_unique
<
ComplexKeyCacheDictionary
>
(
name
,
dict_struct
,
std
::
move
(
source_ptr
),
dict_lifetime
,
size
);
};
factory
.
registerLayout
(
"complex_key_cache"
,
create_layout
);
factory
.
registerLayout
(
"complex_key_cache"
,
create_layout
,
true
);
}
...
...
dbms/src/Dictionaries/ComplexKeyHashedDictionary.cpp
浏览文件 @
10f69eef
...
...
@@ -755,7 +755,7 @@ void registerDictionaryComplexKeyHashed(DictionaryFactory & factory)
const
bool
require_nonempty
=
config
.
getBool
(
config_prefix
+
".require_nonempty"
,
false
);
return
std
::
make_unique
<
ComplexKeyHashedDictionary
>
(
name
,
dict_struct
,
std
::
move
(
source_ptr
),
dict_lifetime
,
require_nonempty
);
};
factory
.
registerLayout
(
"complex_key_hashed"
,
create_layout
);
factory
.
registerLayout
(
"complex_key_hashed"
,
create_layout
,
true
);
}
...
...
dbms/src/Dictionaries/DictionaryFactory.cpp
浏览文件 @
10f69eef
...
...
@@ -13,10 +13,13 @@ namespace ErrorCodes
extern
const
int
UNKNOWN_ELEMENT_IN_CONFIG
;
}
void
DictionaryFactory
::
registerLayout
(
const
std
::
string
&
layout_type
,
Creator
create_layout
)
void
DictionaryFactory
::
registerLayout
(
const
std
::
string
&
layout_type
,
Creator
create_layout
,
bool
is_complex
)
{
if
(
!
registered_layouts
.
emplace
(
layout_type
,
std
::
move
(
create_layout
)).
second
)
throw
Exception
(
"DictionaryFactory: the layout name '"
+
layout_type
+
"' is not unique"
,
ErrorCodes
::
LOGICAL_ERROR
);
layout_complexity
[
layout_type
]
=
is_complex
;
}
...
...
dbms/src/Dictionaries/DictionaryFactory.h
浏览文件 @
10f69eef
...
...
@@ -45,11 +45,15 @@ public:
const
std
::
string
&
config_prefix
,
DictionarySourcePtr
source_ptr
)
>
;
void
registerLayout
(
const
std
::
string
&
layout_type
,
Creator
create_layout
);
bool
isComplex
(
const
std
::
string
&
layout_type
)
const
{
return
layout_complexity
.
at
(
layout_type
);
}
void
registerLayout
(
const
std
::
string
&
layout_type
,
Creator
create_layout
,
bool
is_complex
);
private:
using
LayoutRegistry
=
std
::
unordered_map
<
std
::
string
,
Creator
>
;
LayoutRegistry
registered_layouts
;
using
LayoutComplexity
=
std
::
unordered_map
<
std
::
string
,
bool
>
;
LayoutComplexity
layout_complexity
;
};
}
dbms/src/Dictionaries/FlatDictionary.cpp
浏览文件 @
10f69eef
...
...
@@ -724,7 +724,7 @@ void registerDictionaryFlat(DictionaryFactory & factory)
const
bool
require_nonempty
=
config
.
getBool
(
config_prefix
+
".require_nonempty"
,
false
);
return
std
::
make_unique
<
FlatDictionary
>
(
name
,
dict_struct
,
std
::
move
(
source_ptr
),
dict_lifetime
,
require_nonempty
);
};
factory
.
registerLayout
(
"flat"
,
create_layout
);
factory
.
registerLayout
(
"flat"
,
create_layout
,
false
);
}
...
...
dbms/src/Dictionaries/HashedDictionary.cpp
浏览文件 @
10f69eef
...
...
@@ -787,8 +787,8 @@ void registerDictionaryHashed(DictionaryFactory & factory)
const
bool
sparse
=
name
==
"sparse_hashed"
;
return
std
::
make_unique
<
HashedDictionary
>
(
name
,
dict_struct
,
std
::
move
(
source_ptr
),
dict_lifetime
,
require_nonempty
,
sparse
);
};
factory
.
registerLayout
(
"hashed"
,
create_layout
);
factory
.
registerLayout
(
"sparse_hashed"
,
create_layout
);
factory
.
registerLayout
(
"hashed"
,
create_layout
,
false
);
factory
.
registerLayout
(
"sparse_hashed"
,
create_layout
,
false
);
}
}
dbms/src/Dictionaries/RangeHashedDictionary.cpp
浏览文件 @
10f69eef
...
...
@@ -691,7 +691,7 @@ void registerDictionaryRangeHashed(DictionaryFactory & factory)
const
bool
require_nonempty
=
config
.
getBool
(
config_prefix
+
".require_nonempty"
,
false
);
return
std
::
make_unique
<
RangeHashedDictionary
>
(
name
,
dict_struct
,
std
::
move
(
source_ptr
),
dict_lifetime
,
require_nonempty
);
};
factory
.
registerLayout
(
"range_hashed"
,
create_layout
);
factory
.
registerLayout
(
"range_hashed"
,
create_layout
,
false
);
}
}
dbms/src/Dictionaries/TrieDictionary.cpp
浏览文件 @
10f69eef
...
...
@@ -767,7 +767,7 @@ void registerDictionaryTrie(DictionaryFactory & factory)
// This is specialised trie for storing IPv4 and IPv6 prefixes.
return
std
::
make_unique
<
TrieDictionary
>
(
name
,
dict_struct
,
std
::
move
(
source_ptr
),
dict_lifetime
,
require_nonempty
);
};
factory
.
registerLayout
(
"ip_trie"
,
create_layout
);
factory
.
registerLayout
(
"ip_trie"
,
create_layout
,
true
);
}
}
dbms/src/Dictionaries/getDictionaryConfigurationFromAST.cpp
浏览文件 @
10f69eef
...
...
@@ -13,6 +13,7 @@
#include <Core/Names.h>
#include <Parsers/ASTFunctionWithKeyValueArguments.h>
#include <Parsers/ASTDictionaryAttributeDeclaration.h>
#include <Dictionaries/DictionaryFactory.h>
namespace
DB
{
...
...
@@ -411,7 +412,7 @@ DictionaryConfigurationPtr getDictionaryConfigurationFromAST(const ASTCreateQuer
Names
pk_columns
=
getPrimaryKeyColumns
(
query
.
dictionary
->
primary_key
);
auto
dictionary_layout
=
query
.
dictionary
->
layout
;
bool
complex
=
startsWith
(
dictionary_layout
->
layout_type
,
"complex"
);
bool
complex
=
DictionaryFactory
::
instance
().
isComplex
(
dictionary_layout
->
layout_type
);
buildDictionaryAttributesConfiguration
(
xml_document
,
structure_element
,
query
.
dictionary_attributes_list
,
pk_columns
);
...
...
@@ -422,7 +423,7 @@ DictionaryConfigurationPtr getDictionaryConfigurationFromAST(const ASTCreateQuer
buildLifetimeConfiguration
(
xml_document
,
current_dictionary
,
query
.
dictionary
->
lifetime
);
if
(
query
.
dictionary
->
range
)
buildRangeConfiguration
(
xml_document
,
current_dictionary
,
query
.
dictionary
->
range
);
buildRangeConfiguration
(
xml_document
,
structure_element
,
query
.
dictionary
->
range
);
conf
->
load
(
xml_document
);
return
conf
;
...
...
dbms/src/Dictionaries/tests/gtest_dictionary_configuration.cpp
浏览文件 @
10f69eef
...
...
@@ -14,11 +14,13 @@
#include <Parsers/formatAST.h>
#include <Parsers/parseQuery.h>
#include <Dictionaries/getDictionaryConfigurationFromAST.h>
#include <Dictionaries/registerDictionaries.h>
#include <gtest/gtest.h>
using
namespace
DB
;
static
bool
registered
=
false
;
/// For debug
std
::
string
configurationToString
(
const
DictionaryConfigurationPtr
&
config
)
{
...
...
@@ -30,6 +32,12 @@ std::string configurationToString(const DictionaryConfigurationPtr & config)
TEST
(
ConvertDictionaryAST
,
SimpleDictConfiguration
)
{
if
(
!
registered
)
{
registerDictionaries
();
registered
=
true
;
}
String
input
=
" CREATE DICTIONARY test.dict1"
" ("
" key_column UInt64 DEFAULT 0,"
...
...
@@ -55,8 +63,8 @@ TEST(ConvertDictionaryAST, SimpleDictConfiguration)
EXPECT_EQ
(
config
->
getInt
(
"dictionary.lifetime.max"
),
10
);
/// range
EXPECT_EQ
(
config
->
getString
(
"dictionary.range_min"
),
"second_column"
);
EXPECT_EQ
(
config
->
getString
(
"dictionary.range_max"
),
"third_column"
);
EXPECT_EQ
(
config
->
getString
(
"dictionary.
structure.
range_min"
),
"second_column"
);
EXPECT_EQ
(
config
->
getString
(
"dictionary.
structure.
range_max"
),
"third_column"
);
/// source
EXPECT_EQ
(
config
->
getString
(
"dictionary.source.clickhouse.host"
),
"localhost"
);
...
...
@@ -70,7 +78,7 @@ TEST(ConvertDictionaryAST, SimpleDictConfiguration)
Poco
::
Util
::
AbstractConfiguration
::
Keys
keys
;
config
->
keys
(
"dictionary.structure"
,
keys
);
EXPECT_EQ
(
keys
.
size
(),
3
);
EXPECT_EQ
(
keys
.
size
(),
5
);
/// + ranged keys
EXPECT_EQ
(
config
->
getString
(
"dictionary.structure."
+
keys
[
0
]
+
".name"
),
"second_column"
);
EXPECT_EQ
(
config
->
getString
(
"dictionary.structure."
+
keys
[
0
]
+
".type"
),
"UInt8"
);
EXPECT_EQ
(
config
->
getInt
(
"dictionary.structure."
+
keys
[
0
]
+
".null_value"
),
1
);
...
...
@@ -89,6 +97,12 @@ TEST(ConvertDictionaryAST, SimpleDictConfiguration)
TEST
(
ConvertDictionaryAST
,
TrickyAttributes
)
{
if
(
!
registered
)
{
registerDictionaries
();
registered
=
true
;
}
String
input
=
" CREATE DICTIONARY dict2"
" ("
" key_column UInt64 IS_OBJECT_ID,"
...
...
@@ -127,6 +141,12 @@ TEST(ConvertDictionaryAST, TrickyAttributes)
TEST
(
ConvertDictionaryAST
,
ComplexKeyAndLayoutWithParams
)
{
if
(
!
registered
)
{
registerDictionaries
();
registered
=
true
;
}
String
input
=
" CREATE DICTIONARY dict4"
" ("
" key_column1 String,"
...
...
@@ -172,6 +192,12 @@ TEST(ConvertDictionaryAST, ComplexKeyAndLayoutWithParams)
TEST
(
ConvertDictionaryAST
,
ComplexSource
)
{
if
(
!
registered
)
{
registerDictionaries
();
registered
=
true
;
}
String
input
=
" CREATE DICTIONARY dict4"
" ("
" key_column UInt64,"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录