mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-10-09 18:10:48 +00:00
Fix complex dict with two keys
This commit is contained in:
parent
a964af386c
commit
08c2f183dd
@ -192,22 +192,19 @@ namespace DB
|
|||||||
}
|
}
|
||||||
|
|
||||||
Poco::Redis::Command commandForValues("HMGET");
|
Poco::Redis::Command commandForValues("HMGET");
|
||||||
const auto & primary_key = *keys_array.begin();
|
for (size_t i = 0; i < keys_array.size(); ++i)
|
||||||
commandForValues.addRedisType(primary_key);
|
|
||||||
for (size_t i = 1; i < keys_array.size(); ++i)
|
|
||||||
{
|
{
|
||||||
const auto & secondary_key = *(keys_array.begin() + i);
|
const auto & secondary_key = *(keys_array.begin() + i);
|
||||||
insertValueByIdx(0, primary_key);
|
|
||||||
insertValueByIdx(1, secondary_key);
|
|
||||||
commandForValues.addRedisType(secondary_key);
|
commandForValues.addRedisType(secondary_key);
|
||||||
}
|
}
|
||||||
++cursor;
|
++cursor;
|
||||||
|
|
||||||
Poco::Redis::Array values = client->execute<Poco::Redis::Array>(commandForValues);
|
Poco::Redis::Array values = client->execute<Poco::Redis::Array>(commandForValues);
|
||||||
if (commandForValues.size() != values.size() + 2) // 'HMGET' primary_key secondary_keys
|
if (keys_array.size() != values.size() + 1) // 'HMGET' primary_key secondary_keys
|
||||||
throw Exception{"Inconsistent sizes of keys and values in Redis request",
|
throw Exception{"Inconsistent sizes of keys and values in Redis request",
|
||||||
ErrorCodes::NUMBER_OF_COLUMNS_DOESNT_MATCH};
|
ErrorCodes::NUMBER_OF_COLUMNS_DOESNT_MATCH};
|
||||||
|
|
||||||
|
const auto & primary_key = *keys_array.begin();
|
||||||
for (size_t i = 0; i < values.size(); ++i)
|
for (size_t i = 0; i < values.size(); ++i)
|
||||||
{
|
{
|
||||||
const auto & secondary_key = *(keys_array.begin() + i + 1);
|
const auto & secondary_key = *(keys_array.begin() + i + 1);
|
||||||
|
@ -147,14 +147,15 @@ namespace DB
|
|||||||
{
|
{
|
||||||
Poco::Redis::Command command_for_secondary_keys("HKEYS");
|
Poco::Redis::Command command_for_secondary_keys("HKEYS");
|
||||||
command_for_secondary_keys.addRedisType(key);
|
command_for_secondary_keys.addRedisType(key);
|
||||||
|
|
||||||
Poco::Redis::Array reply_for_primary_key = client->execute<Poco::Redis::Array>(command_for_secondary_keys);
|
Poco::Redis::Array reply_for_primary_key = client->execute<Poco::Redis::Array>(command_for_secondary_keys);
|
||||||
|
|
||||||
Poco::SharedPtr<Poco::Redis::Array> primary_with_secondary;
|
Poco::Redis::Array primary_with_secondary;
|
||||||
primary_with_secondary->addRedisType(key);
|
primary_with_secondary.addRedisType(key);
|
||||||
for (const auto & secondary_key : reply_for_primary_key)
|
for (const auto & secondary_key : reply_for_primary_key)
|
||||||
primary_with_secondary->addRedisType(secondary_key);
|
primary_with_secondary.addRedisType(secondary_key);
|
||||||
|
|
||||||
hkeys.add(*primary_with_secondary);
|
hkeys.add(primary_with_secondary);
|
||||||
}
|
}
|
||||||
keys = hkeys;
|
keys = hkeys;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user