Hierarchical dictionaries performance: continued [#CLICKHOUSE-2144].

This commit is contained in:
Alexey Milovidov 2017-03-26 03:42:01 +03:00
parent d4992da546
commit e6ba252507
7 changed files with 20 additions and 13 deletions

View File

@ -79,14 +79,11 @@ void CacheDictionary::isInImpl(
const auto null_value = std::get<UInt64>(hierarchical_attribute->null_values);
const PaddedPODArray<Key> * current_children = &child_ids;
PaddedPODArray<Key> children(size);
PaddedPODArray<Key> parents(size);
PaddedPODArray<Key> parents(child_ids.begin(), child_ids.end());
while (true)
{
toParent(*current_children, parents);
size_t out_idx = 0;
size_t parents_idx = 0;
size_t new_children_idx = 0;
@ -124,10 +121,11 @@ void CacheDictionary::isInImpl(
if (new_children_idx == 0)
break;
/// Will process new children at next loop iteration.
/// Transform all children to its parents.
children.resize(new_children_idx);
parents.resize(new_children_idx);
current_children = &children;
toParent(children, parents);
}
}

View File

@ -80,7 +80,7 @@ void FlatDictionary::isInImpl(
while (id < loaded_size && id != null_value && id != ancestor_id)
id = attr[id];
out[row] = id == ancestor_id;
out[row] = id != null_value && id == ancestor_id;
}
query_count.fetch_add(rows, std::memory_order_relaxed);

View File

@ -78,7 +78,7 @@ void HashedDictionary::isInImpl(
break;
}
out[row] = id == ancestor_id;
out[row] = id != null_value && id == ancestor_id;
}
query_count.fetch_add(rows, std::memory_order_relaxed);

View File

@ -21,7 +21,8 @@ void registerFunctionsComparison(FunctionFactory &);
void registerFunctionsConditional(FunctionFactory &);
void registerFunctionsConversion(FunctionFactory &);
void registerFunctionsDateTime(FunctionFactory &);
void registerFunctionsDictionaries(FunctionFactory &);
void registerFunctionsEmbeddedDictionaries(FunctionFactory &);
void registerFunctionsExternalDictionaries(FunctionFactory &);
void registerFunctionsFormatting(FunctionFactory &);
void registerFunctionsHashing(FunctionFactory &);
void registerFunctionsHigherOrder(FunctionFactory &);
@ -51,7 +52,8 @@ FunctionFactory::FunctionFactory()
registerFunctionsConditional(*this);
registerFunctionsConversion(*this);
registerFunctionsDateTime(*this);
registerFunctionsDictionaries(*this);
registerFunctionsEmbeddedDictionaries(*this);
registerFunctionsExternalDictionaries(*this);
registerFunctionsFormatting(*this);
registerFunctionsHashing(*this);
registerFunctionsHigherOrder(*this);

View File

@ -4,7 +4,7 @@
namespace DB
{
void registerFunctionsDictionaries(FunctionFactory & factory)
void registerFunctionsEmbeddedDictionaries(FunctionFactory & factory)
{
factory.registerFunction<FunctionRegionToCity>();
factory.registerFunction<FunctionRegionToArea>();

View File

@ -4,7 +4,7 @@
namespace DB
{
void registerFunctionsDictionaries(FunctionFactory & factory)
void registerFunctionsExternalDictionaries(FunctionFactory & factory)
{
factory.registerFunction<FunctionDictHas>();
factory.registerFunction<FunctionDictGetUInt8>();

View File

@ -1,6 +1,13 @@
# Automatic tests for external dictionaries
Example:
## Prerequisites:
```
sudo apt install python-lxml python-termcolor
```
## Example
```
MYSQL_OPTIONS=--user=root ./run.sh
```