Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
9778f7c2
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,发现更多精彩内容 >>
提交
9778f7c2
编写于
4月 15, 2019
作者:
C
comunodi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
More logs
上级
27d13881
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
41 addition
and
9 deletion
+41
-9
dbms/src/Dictionaries/RedisBlockInputStream.cpp
dbms/src/Dictionaries/RedisBlockInputStream.cpp
+23
-5
dbms/src/Dictionaries/RedisDictionarySource.cpp
dbms/src/Dictionaries/RedisDictionarySource.cpp
+13
-0
dbms/tests/integration/test_external_dictionaries/dictionary.py
...ests/integration/test_external_dictionaries/dictionary.py
+3
-0
dbms/tests/integration/test_external_dictionaries/test.py
dbms/tests/integration/test_external_dictionaries/test.py
+2
-4
未找到文件。
dbms/src/Dictionaries/RedisBlockInputStream.cpp
浏览文件 @
9778f7c2
...
...
@@ -25,6 +25,9 @@
# include "DictionaryStructure.h"
# include "RedisBlockInputStream.h"
# include "Poco/Logger.h"
# include "common/logger_useful.h"
namespace
DB
{
...
...
@@ -56,6 +59,12 @@ namespace DB
template
<
typename
T
>
void
insertNumber
(
IColumn
&
column
,
const
Poco
::
Redis
::
RedisType
::
Ptr
&
value
,
const
std
::
string
&
name
)
{
LOG_ERROR
(
&
Logger
::
get
(
"Redis"
),
"Got value: "
+
value
->
toString
()
+
"with type="
+
", isInteger="
+
DB
::
toString
(
value
->
isInteger
())
+
", isSimpleString="
+
DB
::
toString
(
value
->
isSimpleString
())
+
", isBulkString="
+
DB
::
toString
(
value
->
isBulkString
())
+
", isArray="
+
DB
::
toString
(
value
->
isArray
())
+
", isError="
+
DB
::
toString
(
value
->
isError
()));
switch
(
value
->
type
())
{
case
Poco
::
Redis
::
RedisTypeTraits
<
Poco
::
Int64
>::
TypeId
:
...
...
@@ -68,7 +77,7 @@ namespace DB
break
;
case
Poco
::
Redis
::
RedisTypeTraits
<
Poco
::
Redis
::
BulkString
>::
TypeId
:
{
const
auto
&
bs
=
const
auto
&
bs
=
static_cast
<
const
Poco
::
Redis
::
Type
<
Poco
::
Redis
::
BulkString
>
*>
(
value
.
get
())
->
value
();
if
(
bs
.
isNull
())
static_cast
<
ColumnVector
<
T
>
&>
(
column
).
getData
().
emplace_back
();
...
...
@@ -78,7 +87,8 @@ namespace DB
}
default:
throw
Exception
(
"Type mismatch, expected a number, got type id = "
+
toString
(
value
->
type
())
+
" for column "
+
name
,
"Type mismatch, expected a number, got "
+
value
->
toString
()
+
" with type id = "
+
toString
(
value
->
type
())
+
" for column "
+
name
,
ErrorCodes
::
TYPE_MISMATCH
);
}
}
...
...
@@ -189,6 +199,9 @@ namespace DB
if
(
all_read
)
return
{};
for
(
size_t
i
=
0
;
i
<
3
;
++
i
)
if
(
description
.
sample_block
.
columns
()
>=
i
+
1
)
LOG_ERROR
(
&
Logger
::
get
(
"Redis"
),
description
.
sample_block
.
getByPosition
(
i
).
dumpStructure
());
const
size_t
size
=
2
;
if
(
size
!=
description
.
sample_block
.
columns
())
throw
Exception
{
"Unsupported number of columns for key-value storage: "
...
...
@@ -225,21 +238,27 @@ namespace DB
break
;
}
LOG_ERROR
(
&
Logger
::
get
(
"Redis"
),
"Get key: "
+
DB
::
toString
(
cursor
));
const
auto
&
key
=
*
(
keys
.
begin
()
+
cursor
);
insertValueByIdx
(
0
,
key
);
commandForValues
.
addRedisType
(
key
);
LOG_ERROR
(
&
Logger
::
get
(
"Redis"
),
"Key has read: "
+
DB
::
toString
(
cursor
));
++
num_rows
;
++
cursor
;
}
LOG_ERROR
(
&
Logger
::
get
(
"Redis"
),
"All "
+
DB
::
toString
(
num_rows
)
+
" rows added"
);
if
(
num_rows
==
0
)
return
{};
LOG_ERROR
(
&
Logger
::
get
(
"Redis"
),
"Req to get values"
);
Poco
::
Redis
::
Array
values
=
client
->
execute
<
Poco
::
Redis
::
Array
>
(
commandForValues
);
LOG_ERROR
(
&
Logger
::
get
(
"Redis"
),
"Req executed"
);
for
(
size_t
i
=
0
;
i
<
num_rows
;
++
i
)
{
LOG_ERROR
(
&
Logger
::
get
(
"Redis"
),
"Get value from : "
+
DB
::
toString
(
i
));
const
Poco
::
Redis
::
RedisType
::
Ptr
&
value
=
*
(
values
.
begin
()
+
i
);
if
(
value
.
isNull
())
insertDefaultValue
(
*
columns
[
1
],
*
description
.
sample_block
.
getByPosition
(
1
).
column
);
...
...
@@ -249,7 +268,6 @@ namespace DB
return
description
.
sample_block
.
cloneWithColumns
(
std
::
move
(
columns
));
}
}
#endif
dbms/src/Dictionaries/RedisDictionarySource.cpp
浏览文件 @
9778f7c2
...
...
@@ -52,6 +52,9 @@ namespace DB
# include <ext/enumerate.h>
# include "RedisBlockInputStream.h"
# include "Poco/Logger.h"
# include "common/logger_useful.h"
namespace
DB
{
...
...
@@ -120,17 +123,25 @@ namespace DB
BlockInputStreamPtr
RedisDictionarySource
::
loadAll
()
{
LOG_ERROR
(
&
Logger
::
get
(
"Redis"
),
"Redis in loadAll"
);
Poco
::
Redis
::
Array
commandForKeys
;
commandForKeys
<<
"KEYS"
<<
"*"
;
LOG_ERROR
(
&
Logger
::
get
(
"Redis"
),
"Command for keys: "
+
commandForKeys
.
toString
());
Poco
::
Redis
::
Array
keys
=
client
->
execute
<
Poco
::
Redis
::
Array
>
(
commandForKeys
);
LOG_ERROR
(
&
Logger
::
get
(
"Redis"
),
"Command for keys executed"
);
LOG_ERROR
(
&
Logger
::
get
(
"Redis"
),
"KEYS: "
+
keys
.
toString
());
return
std
::
make_shared
<
RedisBlockInputStream
>
(
client
,
std
::
move
(
keys
),
sample_block
,
max_block_size
);
}
BlockInputStreamPtr
RedisDictionarySource
::
loadIds
(
const
std
::
vector
<
UInt64
>
&
ids
)
{
LOG_ERROR
(
&
Logger
::
get
(
"Redis"
),
"Redis in loadIds"
);
if
(
!
dict_struct
.
id
)
throw
Exception
{
"'id' is required for selective loading"
,
ErrorCodes
::
UNSUPPORTED_METHOD
};
...
...
@@ -139,6 +150,8 @@ namespace DB
for
(
UInt64
id
:
ids
)
keys
<<
static_cast
<
Int64
>
(
id
);
LOG_ERROR
(
&
Logger
::
get
(
"Redis"
),
"KEYS: "
+
keys
.
toString
());
return
std
::
make_shared
<
RedisBlockInputStream
>
(
client
,
std
::
move
(
keys
),
sample_block
,
max_block_size
);
}
...
...
dbms/tests/integration/test_external_dictionaries/dictionary.py
浏览文件 @
9778f7c2
...
...
@@ -118,6 +118,9 @@ class DictionaryStructure(object):
fields_strs
=
[]
for
field
in
self
.
ordinary_fields
:
fields_strs
.
append
(
field
.
get_attribute_str
())
if
self
.
is_kv
:
break
key_strs
=
[]
if
self
.
layout
.
is_complex
:
for
key_field
in
self
.
keys
:
...
...
dbms/tests/integration/test_external_dictionaries/test.py
浏览文件 @
9778f7c2
...
...
@@ -206,7 +206,7 @@ def test_complex_dictionaries(started_cluster):
'my'
,
255.543
,
3332221.44
]),
]
complex_dicts
=
[
d
for
d
in
DICTIONARIES
if
d
.
structure
.
layout
.
layout_type
==
"complex"
]
complex_dicts
=
[
d
for
d
in
DICTIONARIES
if
d
.
structure
.
layout
.
layout_type
==
"complex"
and
not
d
.
is_kv
]
for
dct
in
complex_dicts
:
dct
.
load_data
(
data
)
...
...
@@ -225,8 +225,6 @@ def test_complex_dictionaries(started_cluster):
for
query
in
dct
.
get_select_get_or_default_queries
(
field
,
row
):
queries_with_answers
.
append
((
query
,
field
.
default_value_for_get
))
if
dct
.
is_kv
:
break
for
query
,
answer
in
queries_with_answers
:
print
query
...
...
@@ -249,7 +247,7 @@ def test_ranged_dictionaries(started_cluster):
32.543
,
3332543.4
]),
]
ranged_dicts
=
[
d
for
d
in
DICTIONARIES
if
d
.
structure
.
layout
.
layout_type
==
"ranged"
]
ranged_dicts
=
[
d
for
d
in
DICTIONARIES
if
d
.
structure
.
layout
.
layout_type
==
"ranged"
and
not
d
.
is_kv
]
for
dct
in
ranged_dicts
:
dct
.
load_data
(
data
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录