ClickHouse/dbms/AggregateFunctions/UniqVariadicHash.cpp
Ivan 97f2a2213e
Move all folders inside /dbms one level up (#9974)
* Move some code outside dbms/src folder
* Fix paths
2020-04-02 02:51:21 +03:00

33 lines
1.1 KiB
C++

#include <AggregateFunctions/UniqVariadicHash.h>
#include <DataTypes/DataTypeTuple.h>
#include <Common/typeid_cast.h>
namespace DB
{
/// If some arguments are not contiguous, we cannot use simple hash function,
/// because it requires method IColumn::getDataAt to work.
/// Note that we treat single tuple argument in the same way as multiple arguments.
bool isAllArgumentsContiguousInMemory(const DataTypes & argument_types)
{
auto check_all_arguments_are_contiguous_in_memory = [](const DataTypes & types)
{
for (const auto & type : types)
if (!type->isValueUnambiguouslyRepresentedInContiguousMemoryRegion())
return false;
return true;
};
const DataTypeTuple * single_argument_as_tuple = nullptr;
if (argument_types.size() == 1)
single_argument_as_tuple = typeid_cast<const DataTypeTuple *>(argument_types[0].get());
if (single_argument_as_tuple)
return check_all_arguments_are_contiguous_in_memory(single_argument_as_tuple->getElements());
else
return check_all_arguments_are_contiguous_in_memory(argument_types);
}
}