1 | #include <AggregateFunctions/UniqVariadicHash.h> |
---|---|
2 | #include <DataTypes/DataTypeTuple.h> |
3 | #include <Common/typeid_cast.h> |
4 | |
5 | |
6 | namespace DB |
7 | { |
8 | |
9 | /// If some arguments are not contiguous, we cannot use simple hash function, |
10 | /// because it requires method IColumn::getDataAt to work. |
11 | /// Note that we treat single tuple argument in the same way as multiple arguments. |
12 | bool isAllArgumentsContiguousInMemory(const DataTypes & argument_types) |
13 | { |
14 | auto check_all_arguments_are_contiguous_in_memory = [](const DataTypes & types) |
15 | { |
16 | for (const auto & type : types) |
17 | if (!type->isValueUnambiguouslyRepresentedInContiguousMemoryRegion()) |
18 | return false; |
19 | return true; |
20 | }; |
21 | |
22 | const DataTypeTuple * single_argument_as_tuple = nullptr; |
23 | if (argument_types.size() == 1) |
24 | single_argument_as_tuple = typeid_cast<const DataTypeTuple *>(argument_types[0].get()); |
25 | |
26 | if (single_argument_as_tuple) |
27 | return check_all_arguments_are_contiguous_in_memory(single_argument_as_tuple->getElements()); |
28 | else |
29 | return check_all_arguments_are_contiguous_in_memory(argument_types); |
30 | } |
31 | |
32 | } |
33 |