Coverage Report

Created: 2026-04-02 10:16

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/exprs/function/function_hash.cpp
Line
Count
Source
1
// Licensed to the Apache Software Foundation (ASF) under one
2
// or more contributor license agreements.  See the NOTICE file
3
// distributed with this work for additional information
4
// regarding copyright ownership.  The ASF licenses this file
5
// to you under the Apache License, Version 2.0 (the
6
// "License"); you may not use this file except in compliance
7
// with the License.  You may obtain a copy of the License at
8
//
9
//   http://www.apache.org/licenses/LICENSE-2.0
10
//
11
// Unless required by applicable law or agreed to in writing,
12
// software distributed under the License is distributed on an
13
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
// KIND, either express or implied.  See the License for the
15
// specific language governing permissions and limitations
16
// under the License.
17
// This file is copied from
18
// https://github.com/ClickHouse/ClickHouse/blob/master/src/Functions/FunctionHash.cpp
19
// and modified by Doris
20
21
#include "exprs/function/function_hash.h"
22
23
#include "common/status.h"
24
#include "core/assert_cast.h"
25
#include "core/column/column.h"
26
#include "core/column/column_const.h"
27
#include "core/column/column_string.h"
28
#include "core/column/column_varbinary.h"
29
#include "core/column/column_vector.h"
30
#include "core/data_type/data_type.h"
31
#include "core/data_type/data_type_number.h"
32
#include "core/field.h"
33
#include "exec/common/template_helpers.hpp"
34
#include "exprs/function/function_helpers.h"
35
#include "exprs/function/function_variadic_arguments.h"
36
#include "exprs/function/simple_function_factory.h"
37
#include "util/hash/murmur_hash3.h"
38
#include "util/hash_util.hpp"
39
40
namespace doris {
41
#include "common/compile_check_begin.h"
42
constexpr uint64_t emtpy_value = 0xe28dbde7fe22e41c;
43
44
template <PrimitiveType ReturnType, bool is_mmh64_v2 = false>
45
struct MurmurHash3Impl {
46
0
    static constexpr auto get_name() {
47
0
        if constexpr (ReturnType == TYPE_INT) {
48
0
            return "murmur_hash3_32";
49
0
        } else if constexpr (ReturnType == TYPE_LARGEINT) {
50
0
            return "murmur_hash3_u64_v2";
51
0
        } else if constexpr (is_mmh64_v2) {
52
0
            return "murmur_hash3_64_v2";
53
0
        } else {
54
0
            return "murmur_hash3_64";
55
0
        }
56
0
    }
57
    static constexpr auto name = get_name();
58
59
0
    static Status empty_apply(IColumn& icolumn, size_t input_rows_count) {
60
0
        ColumnVector<ReturnType>& vec_to = assert_cast<ColumnVector<ReturnType>&>(icolumn);
61
0
        vec_to.get_data().assign(
62
0
                input_rows_count,
63
0
                static_cast<typename PrimitiveTypeTraits<ReturnType>::CppType>(emtpy_value));
64
0
        return Status::OK();
65
0
    }
Unexecuted instantiation: _ZN5doris15MurmurHash3ImplILNS_13PrimitiveTypeE5ELb0EE11empty_applyERNS_7IColumnEm
Unexecuted instantiation: _ZN5doris15MurmurHash3ImplILNS_13PrimitiveTypeE6ELb0EE11empty_applyERNS_7IColumnEm
Unexecuted instantiation: _ZN5doris15MurmurHash3ImplILNS_13PrimitiveTypeE6ELb1EE11empty_applyERNS_7IColumnEm
Unexecuted instantiation: _ZN5doris15MurmurHash3ImplILNS_13PrimitiveTypeE7ELb1EE11empty_applyERNS_7IColumnEm
66
67
    static Status first_apply(const IDataType* type, const IColumn* column, size_t input_rows_count,
68
81
                              IColumn& icolumn) {
69
81
        return execute<true>(type, column, input_rows_count, icolumn);
70
81
    }
_ZN5doris15MurmurHash3ImplILNS_13PrimitiveTypeE5ELb0EE11first_applyEPKNS_9IDataTypeEPKNS_7IColumnEmRS6_
Line
Count
Source
68
21
                              IColumn& icolumn) {
69
21
        return execute<true>(type, column, input_rows_count, icolumn);
70
21
    }
_ZN5doris15MurmurHash3ImplILNS_13PrimitiveTypeE6ELb0EE11first_applyEPKNS_9IDataTypeEPKNS_7IColumnEmRS6_
Line
Count
Source
68
21
                              IColumn& icolumn) {
69
21
        return execute<true>(type, column, input_rows_count, icolumn);
70
21
    }
_ZN5doris15MurmurHash3ImplILNS_13PrimitiveTypeE6ELb1EE11first_applyEPKNS_9IDataTypeEPKNS_7IColumnEmRS6_
Line
Count
Source
68
18
                              IColumn& icolumn) {
69
18
        return execute<true>(type, column, input_rows_count, icolumn);
70
18
    }
_ZN5doris15MurmurHash3ImplILNS_13PrimitiveTypeE7ELb1EE11first_applyEPKNS_9IDataTypeEPKNS_7IColumnEmRS6_
Line
Count
Source
68
21
                              IColumn& icolumn) {
69
21
        return execute<true>(type, column, input_rows_count, icolumn);
70
21
    }
71
72
    static Status combine_apply(const IDataType* type, const IColumn* column,
73
13
                                size_t input_rows_count, IColumn& icolumn) {
74
13
        return execute<false>(type, column, input_rows_count, icolumn);
75
13
    }
_ZN5doris15MurmurHash3ImplILNS_13PrimitiveTypeE5ELb0EE13combine_applyEPKNS_9IDataTypeEPKNS_7IColumnEmRS6_
Line
Count
Source
73
4
                                size_t input_rows_count, IColumn& icolumn) {
74
4
        return execute<false>(type, column, input_rows_count, icolumn);
75
4
    }
_ZN5doris15MurmurHash3ImplILNS_13PrimitiveTypeE6ELb0EE13combine_applyEPKNS_9IDataTypeEPKNS_7IColumnEmRS6_
Line
Count
Source
73
4
                                size_t input_rows_count, IColumn& icolumn) {
74
4
        return execute<false>(type, column, input_rows_count, icolumn);
75
4
    }
_ZN5doris15MurmurHash3ImplILNS_13PrimitiveTypeE6ELb1EE13combine_applyEPKNS_9IDataTypeEPKNS_7IColumnEmRS6_
Line
Count
Source
73
1
                                size_t input_rows_count, IColumn& icolumn) {
74
1
        return execute<false>(type, column, input_rows_count, icolumn);
75
1
    }
_ZN5doris15MurmurHash3ImplILNS_13PrimitiveTypeE7ELb1EE13combine_applyEPKNS_9IDataTypeEPKNS_7IColumnEmRS6_
Line
Count
Source
73
4
                                size_t input_rows_count, IColumn& icolumn) {
74
4
        return execute<false>(type, column, input_rows_count, icolumn);
75
4
    }
76
77
    template <bool first>
78
    static Status execute(const IDataType* type, const IColumn* column, size_t input_rows_count,
79
94
                          IColumn& col_to) {
80
94
        auto& to_column = assert_cast<ColumnVector<ReturnType>&>(col_to);
81
94
        if constexpr (first) {
82
81
            if constexpr (ReturnType == TYPE_INT) {
83
21
                to_column.insert_many_vals(static_cast<Int32>(HashUtil::MURMUR3_32_SEED),
84
21
                                           input_rows_count);
85
60
            } else {
86
60
                to_column.insert_many_defaults(input_rows_count);
87
60
            }
88
81
        }
89
94
        auto& col_to_data = to_column.get_data();
90
94
        if (const auto* col_from = check_and_get_column<ColumnString>(column)) {
91
94
            const typename ColumnString::Chars& data = col_from->get_chars();
92
94
            const typename ColumnString::Offsets& offsets = col_from->get_offsets();
93
94
            size_t size = offsets.size();
94
94
            ColumnString::Offset current_offset = 0;
95
286
            for (size_t i = 0; i < size; ++i) {
96
192
                if constexpr (ReturnType == TYPE_INT) {
97
65
                    col_to_data[i] = HashUtil::murmur_hash3_32(
98
65
                            reinterpret_cast<const char*>(&data[current_offset]),
99
65
                            offsets[i] - current_offset, col_to_data[i]);
100
127
                } else {
101
127
                    col_to_data[i] = HashUtil::murmur_hash3_64<is_mmh64_v2>(
102
127
                            reinterpret_cast<const char*>(&data[current_offset]),
103
127
                            offsets[i] - current_offset, static_cast<uint64_t>(col_to_data[i]));
104
127
                }
105
192
                current_offset = offsets[i];
106
192
            }
107
94
        } else if (const ColumnConst* col_from_const =
108
0
                           check_and_get_column_const_string_or_fixedstring(column)) {
109
0
            auto value = col_from_const->get_value<TYPE_STRING>();
110
0
            for (size_t i = 0; i < input_rows_count; ++i) {
111
0
                if constexpr (ReturnType == TYPE_INT) {
112
0
                    col_to_data[i] =
113
0
                            HashUtil::murmur_hash3_32(value.data(), value.size(), col_to_data[i]);
114
0
                } else {
115
0
                    col_to_data[i] = HashUtil::murmur_hash3_64<is_mmh64_v2>(
116
0
                            value.data(), value.size(), static_cast<uint64_t>(col_to_data[i]));
117
0
                }
118
0
            }
119
0
        } else {
120
0
            DCHECK(false);
121
0
            return Status::NotSupported("Illegal column {} of argument of function {}",
122
0
                                        column->get_name(), name);
123
0
        }
124
94
        return Status::OK();
125
94
    }
_ZN5doris15MurmurHash3ImplILNS_13PrimitiveTypeE5ELb0EE7executeILb1EEENS_6StatusEPKNS_9IDataTypeEPKNS_7IColumnEmRS8_
Line
Count
Source
79
21
                          IColumn& col_to) {
80
21
        auto& to_column = assert_cast<ColumnVector<ReturnType>&>(col_to);
81
21
        if constexpr (first) {
82
21
            if constexpr (ReturnType == TYPE_INT) {
83
21
                to_column.insert_many_vals(static_cast<Int32>(HashUtil::MURMUR3_32_SEED),
84
21
                                           input_rows_count);
85
            } else {
86
                to_column.insert_many_defaults(input_rows_count);
87
            }
88
21
        }
89
21
        auto& col_to_data = to_column.get_data();
90
21
        if (const auto* col_from = check_and_get_column<ColumnString>(column)) {
91
21
            const typename ColumnString::Chars& data = col_from->get_chars();
92
21
            const typename ColumnString::Offsets& offsets = col_from->get_offsets();
93
21
            size_t size = offsets.size();
94
21
            ColumnString::Offset current_offset = 0;
95
79
            for (size_t i = 0; i < size; ++i) {
96
58
                if constexpr (ReturnType == TYPE_INT) {
97
58
                    col_to_data[i] = HashUtil::murmur_hash3_32(
98
58
                            reinterpret_cast<const char*>(&data[current_offset]),
99
58
                            offsets[i] - current_offset, col_to_data[i]);
100
                } else {
101
                    col_to_data[i] = HashUtil::murmur_hash3_64<is_mmh64_v2>(
102
                            reinterpret_cast<const char*>(&data[current_offset]),
103
                            offsets[i] - current_offset, static_cast<uint64_t>(col_to_data[i]));
104
                }
105
58
                current_offset = offsets[i];
106
58
            }
107
21
        } else if (const ColumnConst* col_from_const =
108
0
                           check_and_get_column_const_string_or_fixedstring(column)) {
109
0
            auto value = col_from_const->get_value<TYPE_STRING>();
110
0
            for (size_t i = 0; i < input_rows_count; ++i) {
111
0
                if constexpr (ReturnType == TYPE_INT) {
112
0
                    col_to_data[i] =
113
0
                            HashUtil::murmur_hash3_32(value.data(), value.size(), col_to_data[i]);
114
                } else {
115
                    col_to_data[i] = HashUtil::murmur_hash3_64<is_mmh64_v2>(
116
                            value.data(), value.size(), static_cast<uint64_t>(col_to_data[i]));
117
                }
118
0
            }
119
0
        } else {
120
0
            DCHECK(false);
121
0
            return Status::NotSupported("Illegal column {} of argument of function {}",
122
0
                                        column->get_name(), name);
123
0
        }
124
21
        return Status::OK();
125
21
    }
_ZN5doris15MurmurHash3ImplILNS_13PrimitiveTypeE5ELb0EE7executeILb0EEENS_6StatusEPKNS_9IDataTypeEPKNS_7IColumnEmRS8_
Line
Count
Source
79
4
                          IColumn& col_to) {
80
4
        auto& to_column = assert_cast<ColumnVector<ReturnType>&>(col_to);
81
        if constexpr (first) {
82
            if constexpr (ReturnType == TYPE_INT) {
83
                to_column.insert_many_vals(static_cast<Int32>(HashUtil::MURMUR3_32_SEED),
84
                                           input_rows_count);
85
            } else {
86
                to_column.insert_many_defaults(input_rows_count);
87
            }
88
        }
89
4
        auto& col_to_data = to_column.get_data();
90
4
        if (const auto* col_from = check_and_get_column<ColumnString>(column)) {
91
4
            const typename ColumnString::Chars& data = col_from->get_chars();
92
4
            const typename ColumnString::Offsets& offsets = col_from->get_offsets();
93
4
            size_t size = offsets.size();
94
4
            ColumnString::Offset current_offset = 0;
95
11
            for (size_t i = 0; i < size; ++i) {
96
7
                if constexpr (ReturnType == TYPE_INT) {
97
7
                    col_to_data[i] = HashUtil::murmur_hash3_32(
98
7
                            reinterpret_cast<const char*>(&data[current_offset]),
99
7
                            offsets[i] - current_offset, col_to_data[i]);
100
                } else {
101
                    col_to_data[i] = HashUtil::murmur_hash3_64<is_mmh64_v2>(
102
                            reinterpret_cast<const char*>(&data[current_offset]),
103
                            offsets[i] - current_offset, static_cast<uint64_t>(col_to_data[i]));
104
                }
105
7
                current_offset = offsets[i];
106
7
            }
107
4
        } else if (const ColumnConst* col_from_const =
108
0
                           check_and_get_column_const_string_or_fixedstring(column)) {
109
0
            auto value = col_from_const->get_value<TYPE_STRING>();
110
0
            for (size_t i = 0; i < input_rows_count; ++i) {
111
0
                if constexpr (ReturnType == TYPE_INT) {
112
0
                    col_to_data[i] =
113
0
                            HashUtil::murmur_hash3_32(value.data(), value.size(), col_to_data[i]);
114
                } else {
115
                    col_to_data[i] = HashUtil::murmur_hash3_64<is_mmh64_v2>(
116
                            value.data(), value.size(), static_cast<uint64_t>(col_to_data[i]));
117
                }
118
0
            }
119
0
        } else {
120
0
            DCHECK(false);
121
0
            return Status::NotSupported("Illegal column {} of argument of function {}",
122
0
                                        column->get_name(), name);
123
0
        }
124
4
        return Status::OK();
125
4
    }
_ZN5doris15MurmurHash3ImplILNS_13PrimitiveTypeE6ELb0EE7executeILb1EEENS_6StatusEPKNS_9IDataTypeEPKNS_7IColumnEmRS8_
Line
Count
Source
79
21
                          IColumn& col_to) {
80
21
        auto& to_column = assert_cast<ColumnVector<ReturnType>&>(col_to);
81
21
        if constexpr (first) {
82
            if constexpr (ReturnType == TYPE_INT) {
83
                to_column.insert_many_vals(static_cast<Int32>(HashUtil::MURMUR3_32_SEED),
84
                                           input_rows_count);
85
21
            } else {
86
21
                to_column.insert_many_defaults(input_rows_count);
87
21
            }
88
21
        }
89
21
        auto& col_to_data = to_column.get_data();
90
21
        if (const auto* col_from = check_and_get_column<ColumnString>(column)) {
91
21
            const typename ColumnString::Chars& data = col_from->get_chars();
92
21
            const typename ColumnString::Offsets& offsets = col_from->get_offsets();
93
21
            size_t size = offsets.size();
94
21
            ColumnString::Offset current_offset = 0;
95
79
            for (size_t i = 0; i < size; ++i) {
96
                if constexpr (ReturnType == TYPE_INT) {
97
                    col_to_data[i] = HashUtil::murmur_hash3_32(
98
                            reinterpret_cast<const char*>(&data[current_offset]),
99
                            offsets[i] - current_offset, col_to_data[i]);
100
58
                } else {
101
58
                    col_to_data[i] = HashUtil::murmur_hash3_64<is_mmh64_v2>(
102
58
                            reinterpret_cast<const char*>(&data[current_offset]),
103
58
                            offsets[i] - current_offset, static_cast<uint64_t>(col_to_data[i]));
104
58
                }
105
58
                current_offset = offsets[i];
106
58
            }
107
21
        } else if (const ColumnConst* col_from_const =
108
0
                           check_and_get_column_const_string_or_fixedstring(column)) {
109
0
            auto value = col_from_const->get_value<TYPE_STRING>();
110
0
            for (size_t i = 0; i < input_rows_count; ++i) {
111
                if constexpr (ReturnType == TYPE_INT) {
112
                    col_to_data[i] =
113
                            HashUtil::murmur_hash3_32(value.data(), value.size(), col_to_data[i]);
114
0
                } else {
115
0
                    col_to_data[i] = HashUtil::murmur_hash3_64<is_mmh64_v2>(
116
0
                            value.data(), value.size(), static_cast<uint64_t>(col_to_data[i]));
117
0
                }
118
0
            }
119
0
        } else {
120
0
            DCHECK(false);
121
0
            return Status::NotSupported("Illegal column {} of argument of function {}",
122
0
                                        column->get_name(), name);
123
0
        }
124
21
        return Status::OK();
125
21
    }
_ZN5doris15MurmurHash3ImplILNS_13PrimitiveTypeE6ELb0EE7executeILb0EEENS_6StatusEPKNS_9IDataTypeEPKNS_7IColumnEmRS8_
Line
Count
Source
79
4
                          IColumn& col_to) {
80
4
        auto& to_column = assert_cast<ColumnVector<ReturnType>&>(col_to);
81
        if constexpr (first) {
82
            if constexpr (ReturnType == TYPE_INT) {
83
                to_column.insert_many_vals(static_cast<Int32>(HashUtil::MURMUR3_32_SEED),
84
                                           input_rows_count);
85
            } else {
86
                to_column.insert_many_defaults(input_rows_count);
87
            }
88
        }
89
4
        auto& col_to_data = to_column.get_data();
90
4
        if (const auto* col_from = check_and_get_column<ColumnString>(column)) {
91
4
            const typename ColumnString::Chars& data = col_from->get_chars();
92
4
            const typename ColumnString::Offsets& offsets = col_from->get_offsets();
93
4
            size_t size = offsets.size();
94
4
            ColumnString::Offset current_offset = 0;
95
11
            for (size_t i = 0; i < size; ++i) {
96
                if constexpr (ReturnType == TYPE_INT) {
97
                    col_to_data[i] = HashUtil::murmur_hash3_32(
98
                            reinterpret_cast<const char*>(&data[current_offset]),
99
                            offsets[i] - current_offset, col_to_data[i]);
100
7
                } else {
101
7
                    col_to_data[i] = HashUtil::murmur_hash3_64<is_mmh64_v2>(
102
7
                            reinterpret_cast<const char*>(&data[current_offset]),
103
7
                            offsets[i] - current_offset, static_cast<uint64_t>(col_to_data[i]));
104
7
                }
105
7
                current_offset = offsets[i];
106
7
            }
107
4
        } else if (const ColumnConst* col_from_const =
108
0
                           check_and_get_column_const_string_or_fixedstring(column)) {
109
0
            auto value = col_from_const->get_value<TYPE_STRING>();
110
0
            for (size_t i = 0; i < input_rows_count; ++i) {
111
                if constexpr (ReturnType == TYPE_INT) {
112
                    col_to_data[i] =
113
                            HashUtil::murmur_hash3_32(value.data(), value.size(), col_to_data[i]);
114
0
                } else {
115
0
                    col_to_data[i] = HashUtil::murmur_hash3_64<is_mmh64_v2>(
116
0
                            value.data(), value.size(), static_cast<uint64_t>(col_to_data[i]));
117
0
                }
118
0
            }
119
0
        } else {
120
0
            DCHECK(false);
121
0
            return Status::NotSupported("Illegal column {} of argument of function {}",
122
0
                                        column->get_name(), name);
123
0
        }
124
4
        return Status::OK();
125
4
    }
_ZN5doris15MurmurHash3ImplILNS_13PrimitiveTypeE6ELb1EE7executeILb1EEENS_6StatusEPKNS_9IDataTypeEPKNS_7IColumnEmRS8_
Line
Count
Source
79
18
                          IColumn& col_to) {
80
18
        auto& to_column = assert_cast<ColumnVector<ReturnType>&>(col_to);
81
18
        if constexpr (first) {
82
            if constexpr (ReturnType == TYPE_INT) {
83
                to_column.insert_many_vals(static_cast<Int32>(HashUtil::MURMUR3_32_SEED),
84
                                           input_rows_count);
85
18
            } else {
86
18
                to_column.insert_many_defaults(input_rows_count);
87
18
            }
88
18
        }
89
18
        auto& col_to_data = to_column.get_data();
90
18
        if (const auto* col_from = check_and_get_column<ColumnString>(column)) {
91
18
            const typename ColumnString::Chars& data = col_from->get_chars();
92
18
            const typename ColumnString::Offsets& offsets = col_from->get_offsets();
93
18
            size_t size = offsets.size();
94
18
            ColumnString::Offset current_offset = 0;
95
46
            for (size_t i = 0; i < size; ++i) {
96
                if constexpr (ReturnType == TYPE_INT) {
97
                    col_to_data[i] = HashUtil::murmur_hash3_32(
98
                            reinterpret_cast<const char*>(&data[current_offset]),
99
                            offsets[i] - current_offset, col_to_data[i]);
100
28
                } else {
101
28
                    col_to_data[i] = HashUtil::murmur_hash3_64<is_mmh64_v2>(
102
28
                            reinterpret_cast<const char*>(&data[current_offset]),
103
28
                            offsets[i] - current_offset, static_cast<uint64_t>(col_to_data[i]));
104
28
                }
105
28
                current_offset = offsets[i];
106
28
            }
107
18
        } else if (const ColumnConst* col_from_const =
108
0
                           check_and_get_column_const_string_or_fixedstring(column)) {
109
0
            auto value = col_from_const->get_value<TYPE_STRING>();
110
0
            for (size_t i = 0; i < input_rows_count; ++i) {
111
                if constexpr (ReturnType == TYPE_INT) {
112
                    col_to_data[i] =
113
                            HashUtil::murmur_hash3_32(value.data(), value.size(), col_to_data[i]);
114
0
                } else {
115
0
                    col_to_data[i] = HashUtil::murmur_hash3_64<is_mmh64_v2>(
116
0
                            value.data(), value.size(), static_cast<uint64_t>(col_to_data[i]));
117
0
                }
118
0
            }
119
0
        } else {
120
0
            DCHECK(false);
121
0
            return Status::NotSupported("Illegal column {} of argument of function {}",
122
0
                                        column->get_name(), name);
123
0
        }
124
18
        return Status::OK();
125
18
    }
_ZN5doris15MurmurHash3ImplILNS_13PrimitiveTypeE6ELb1EE7executeILb0EEENS_6StatusEPKNS_9IDataTypeEPKNS_7IColumnEmRS8_
Line
Count
Source
79
1
                          IColumn& col_to) {
80
1
        auto& to_column = assert_cast<ColumnVector<ReturnType>&>(col_to);
81
        if constexpr (first) {
82
            if constexpr (ReturnType == TYPE_INT) {
83
                to_column.insert_many_vals(static_cast<Int32>(HashUtil::MURMUR3_32_SEED),
84
                                           input_rows_count);
85
            } else {
86
                to_column.insert_many_defaults(input_rows_count);
87
            }
88
        }
89
1
        auto& col_to_data = to_column.get_data();
90
1
        if (const auto* col_from = check_and_get_column<ColumnString>(column)) {
91
1
            const typename ColumnString::Chars& data = col_from->get_chars();
92
1
            const typename ColumnString::Offsets& offsets = col_from->get_offsets();
93
1
            size_t size = offsets.size();
94
1
            ColumnString::Offset current_offset = 0;
95
2
            for (size_t i = 0; i < size; ++i) {
96
                if constexpr (ReturnType == TYPE_INT) {
97
                    col_to_data[i] = HashUtil::murmur_hash3_32(
98
                            reinterpret_cast<const char*>(&data[current_offset]),
99
                            offsets[i] - current_offset, col_to_data[i]);
100
1
                } else {
101
1
                    col_to_data[i] = HashUtil::murmur_hash3_64<is_mmh64_v2>(
102
1
                            reinterpret_cast<const char*>(&data[current_offset]),
103
1
                            offsets[i] - current_offset, static_cast<uint64_t>(col_to_data[i]));
104
1
                }
105
1
                current_offset = offsets[i];
106
1
            }
107
1
        } else if (const ColumnConst* col_from_const =
108
0
                           check_and_get_column_const_string_or_fixedstring(column)) {
109
0
            auto value = col_from_const->get_value<TYPE_STRING>();
110
0
            for (size_t i = 0; i < input_rows_count; ++i) {
111
                if constexpr (ReturnType == TYPE_INT) {
112
                    col_to_data[i] =
113
                            HashUtil::murmur_hash3_32(value.data(), value.size(), col_to_data[i]);
114
0
                } else {
115
0
                    col_to_data[i] = HashUtil::murmur_hash3_64<is_mmh64_v2>(
116
0
                            value.data(), value.size(), static_cast<uint64_t>(col_to_data[i]));
117
0
                }
118
0
            }
119
0
        } else {
120
0
            DCHECK(false);
121
0
            return Status::NotSupported("Illegal column {} of argument of function {}",
122
0
                                        column->get_name(), name);
123
0
        }
124
1
        return Status::OK();
125
1
    }
_ZN5doris15MurmurHash3ImplILNS_13PrimitiveTypeE7ELb1EE7executeILb1EEENS_6StatusEPKNS_9IDataTypeEPKNS_7IColumnEmRS8_
Line
Count
Source
79
21
                          IColumn& col_to) {
80
21
        auto& to_column = assert_cast<ColumnVector<ReturnType>&>(col_to);
81
21
        if constexpr (first) {
82
            if constexpr (ReturnType == TYPE_INT) {
83
                to_column.insert_many_vals(static_cast<Int32>(HashUtil::MURMUR3_32_SEED),
84
                                           input_rows_count);
85
21
            } else {
86
21
                to_column.insert_many_defaults(input_rows_count);
87
21
            }
88
21
        }
89
21
        auto& col_to_data = to_column.get_data();
90
21
        if (const auto* col_from = check_and_get_column<ColumnString>(column)) {
91
21
            const typename ColumnString::Chars& data = col_from->get_chars();
92
21
            const typename ColumnString::Offsets& offsets = col_from->get_offsets();
93
21
            size_t size = offsets.size();
94
21
            ColumnString::Offset current_offset = 0;
95
50
            for (size_t i = 0; i < size; ++i) {
96
                if constexpr (ReturnType == TYPE_INT) {
97
                    col_to_data[i] = HashUtil::murmur_hash3_32(
98
                            reinterpret_cast<const char*>(&data[current_offset]),
99
                            offsets[i] - current_offset, col_to_data[i]);
100
29
                } else {
101
29
                    col_to_data[i] = HashUtil::murmur_hash3_64<is_mmh64_v2>(
102
29
                            reinterpret_cast<const char*>(&data[current_offset]),
103
29
                            offsets[i] - current_offset, static_cast<uint64_t>(col_to_data[i]));
104
29
                }
105
29
                current_offset = offsets[i];
106
29
            }
107
21
        } else if (const ColumnConst* col_from_const =
108
0
                           check_and_get_column_const_string_or_fixedstring(column)) {
109
0
            auto value = col_from_const->get_value<TYPE_STRING>();
110
0
            for (size_t i = 0; i < input_rows_count; ++i) {
111
                if constexpr (ReturnType == TYPE_INT) {
112
                    col_to_data[i] =
113
                            HashUtil::murmur_hash3_32(value.data(), value.size(), col_to_data[i]);
114
0
                } else {
115
0
                    col_to_data[i] = HashUtil::murmur_hash3_64<is_mmh64_v2>(
116
0
                            value.data(), value.size(), static_cast<uint64_t>(col_to_data[i]));
117
0
                }
118
0
            }
119
0
        } else {
120
0
            DCHECK(false);
121
0
            return Status::NotSupported("Illegal column {} of argument of function {}",
122
0
                                        column->get_name(), name);
123
0
        }
124
21
        return Status::OK();
125
21
    }
_ZN5doris15MurmurHash3ImplILNS_13PrimitiveTypeE7ELb1EE7executeILb0EEENS_6StatusEPKNS_9IDataTypeEPKNS_7IColumnEmRS8_
Line
Count
Source
79
4
                          IColumn& col_to) {
80
4
        auto& to_column = assert_cast<ColumnVector<ReturnType>&>(col_to);
81
        if constexpr (first) {
82
            if constexpr (ReturnType == TYPE_INT) {
83
                to_column.insert_many_vals(static_cast<Int32>(HashUtil::MURMUR3_32_SEED),
84
                                           input_rows_count);
85
            } else {
86
                to_column.insert_many_defaults(input_rows_count);
87
            }
88
        }
89
4
        auto& col_to_data = to_column.get_data();
90
4
        if (const auto* col_from = check_and_get_column<ColumnString>(column)) {
91
4
            const typename ColumnString::Chars& data = col_from->get_chars();
92
4
            const typename ColumnString::Offsets& offsets = col_from->get_offsets();
93
4
            size_t size = offsets.size();
94
4
            ColumnString::Offset current_offset = 0;
95
8
            for (size_t i = 0; i < size; ++i) {
96
                if constexpr (ReturnType == TYPE_INT) {
97
                    col_to_data[i] = HashUtil::murmur_hash3_32(
98
                            reinterpret_cast<const char*>(&data[current_offset]),
99
                            offsets[i] - current_offset, col_to_data[i]);
100
4
                } else {
101
4
                    col_to_data[i] = HashUtil::murmur_hash3_64<is_mmh64_v2>(
102
4
                            reinterpret_cast<const char*>(&data[current_offset]),
103
4
                            offsets[i] - current_offset, static_cast<uint64_t>(col_to_data[i]));
104
4
                }
105
4
                current_offset = offsets[i];
106
4
            }
107
4
        } else if (const ColumnConst* col_from_const =
108
0
                           check_and_get_column_const_string_or_fixedstring(column)) {
109
0
            auto value = col_from_const->get_value<TYPE_STRING>();
110
0
            for (size_t i = 0; i < input_rows_count; ++i) {
111
                if constexpr (ReturnType == TYPE_INT) {
112
                    col_to_data[i] =
113
                            HashUtil::murmur_hash3_32(value.data(), value.size(), col_to_data[i]);
114
0
                } else {
115
0
                    col_to_data[i] = HashUtil::murmur_hash3_64<is_mmh64_v2>(
116
0
                            value.data(), value.size(), static_cast<uint64_t>(col_to_data[i]));
117
0
                }
118
0
            }
119
0
        } else {
120
0
            DCHECK(false);
121
0
            return Status::NotSupported("Illegal column {} of argument of function {}",
122
0
                                        column->get_name(), name);
123
0
        }
124
4
        return Status::OK();
125
4
    }
126
};
127
128
using FunctionMurmurHash3_32 =
129
        FunctionVariadicArgumentsBase<DataTypeInt32, MurmurHash3Impl<TYPE_INT>>;
130
using FunctionMurmurHash3_64 =
131
        FunctionVariadicArgumentsBase<DataTypeInt64, MurmurHash3Impl<TYPE_BIGINT>>;
132
using FunctionMurmurHash3_64_V2 =
133
        FunctionVariadicArgumentsBase<DataTypeInt64, MurmurHash3Impl<TYPE_BIGINT, true>>;
134
using FunctionMurmurHash3U64V2 =
135
        FunctionVariadicArgumentsBase<DataTypeInt128, MurmurHash3Impl<TYPE_LARGEINT, true>>;
136
137
#ifdef BE_TEST
138
const char* murmur_hash3_get_name_type_int_for_test() {
139
    return MurmurHash3Impl<TYPE_INT>::get_name();
140
}
141
142
const char* murmur_hash3_get_name_type_bigint_for_test() {
143
    return MurmurHash3Impl<TYPE_BIGINT>::get_name();
144
}
145
146
const char* murmur_hash3_get_name_type_bigint_v2_for_test() {
147
    return MurmurHash3Impl<TYPE_BIGINT, true>::get_name();
148
}
149
#endif
150
151
template <PrimitiveType ReturnType>
152
struct XxHashImpl {
153
    static constexpr auto name = ReturnType == TYPE_INT ? "xxhash_32" : "xxhash_64";
154
155
0
    static Status empty_apply(IColumn& icolumn, size_t input_rows_count) {
156
0
        ColumnVector<ReturnType>& vec_to = assert_cast<ColumnVector<ReturnType>&>(icolumn);
157
0
        vec_to.get_data().assign(
158
0
                input_rows_count,
159
0
                static_cast<typename PrimitiveTypeTraits<ReturnType>::CppType>(emtpy_value));
160
0
        return Status::OK();
161
0
    }
Unexecuted instantiation: _ZN5doris10XxHashImplILNS_13PrimitiveTypeE5EE11empty_applyERNS_7IColumnEm
Unexecuted instantiation: _ZN5doris10XxHashImplILNS_13PrimitiveTypeE6EE11empty_applyERNS_7IColumnEm
162
163
    static Status first_apply(const IDataType* type, const IColumn* column, size_t input_rows_count,
164
126
                              IColumn& icolumn) {
165
126
        return execute<true>(type, column, input_rows_count, icolumn);
166
126
    }
_ZN5doris10XxHashImplILNS_13PrimitiveTypeE5EE11first_applyEPKNS_9IDataTypeEPKNS_7IColumnEmRS6_
Line
Count
Source
164
77
                              IColumn& icolumn) {
165
77
        return execute<true>(type, column, input_rows_count, icolumn);
166
77
    }
_ZN5doris10XxHashImplILNS_13PrimitiveTypeE6EE11first_applyEPKNS_9IDataTypeEPKNS_7IColumnEmRS6_
Line
Count
Source
164
49
                              IColumn& icolumn) {
165
49
        return execute<true>(type, column, input_rows_count, icolumn);
166
49
    }
167
168
    static Status combine_apply(const IDataType* type, const IColumn* column,
169
16
                                size_t input_rows_count, IColumn& icolumn) {
170
16
        return execute<false>(type, column, input_rows_count, icolumn);
171
16
    }
_ZN5doris10XxHashImplILNS_13PrimitiveTypeE5EE13combine_applyEPKNS_9IDataTypeEPKNS_7IColumnEmRS6_
Line
Count
Source
169
7
                                size_t input_rows_count, IColumn& icolumn) {
170
7
        return execute<false>(type, column, input_rows_count, icolumn);
171
7
    }
_ZN5doris10XxHashImplILNS_13PrimitiveTypeE6EE13combine_applyEPKNS_9IDataTypeEPKNS_7IColumnEmRS6_
Line
Count
Source
169
9
                                size_t input_rows_count, IColumn& icolumn) {
170
9
        return execute<false>(type, column, input_rows_count, icolumn);
171
9
    }
172
173
    template <bool first>
174
    static Status execute(const IDataType* type, const IColumn* column, size_t input_rows_count,
175
142
                          IColumn& col_to) {
176
142
        auto& to_column = assert_cast<ColumnVector<ReturnType>&>(col_to);
177
142
        if constexpr (first) {
178
126
            to_column.insert_many_defaults(input_rows_count);
179
126
        }
180
142
        auto& col_to_data = to_column.get_data();
181
142
        if (const auto* col_from = check_and_get_column<ColumnString>(column)) {
182
130
            const typename ColumnString::Chars& data = col_from->get_chars();
183
130
            const typename ColumnString::Offsets& offsets = col_from->get_offsets();
184
130
            size_t size = offsets.size();
185
130
            ColumnString::Offset current_offset = 0;
186
21.1k
            for (size_t i = 0; i < size; ++i) {
187
20.9k
                if constexpr (ReturnType == TYPE_INT) {
188
373
                    col_to_data[i] = HashUtil::xxHash32WithSeed(
189
373
                            reinterpret_cast<const char*>(&data[current_offset]),
190
373
                            offsets[i] - current_offset, col_to_data[i]);
191
20.6k
                } else {
192
20.6k
                    col_to_data[i] = HashUtil::xxHash64WithSeed(
193
20.6k
                            reinterpret_cast<const char*>(&data[current_offset]),
194
20.6k
                            offsets[i] - current_offset, col_to_data[i]);
195
20.6k
                }
196
20.9k
                current_offset = offsets[i];
197
20.9k
            }
198
130
        } else if (const ColumnConst* col_from_const =
199
12
                           check_and_get_column_const_string_or_fixedstring(column)) {
200
0
            auto value = col_from_const->get_value<TYPE_STRING>();
201
0
            for (size_t i = 0; i < input_rows_count; ++i) {
202
0
                if constexpr (ReturnType == TYPE_INT) {
203
0
                    col_to_data[i] =
204
0
                            HashUtil::xxHash32WithSeed(value.data(), value.size(), col_to_data[i]);
205
0
                } else {
206
0
                    col_to_data[i] =
207
0
                            HashUtil::xxHash64WithSeed(value.data(), value.size(), col_to_data[i]);
208
0
                }
209
0
            }
210
12
        } else if (const auto* vb_col = check_and_get_column<ColumnVarbinary>(column)) {
211
36
            for (size_t i = 0; i < input_rows_count; ++i) {
212
24
                auto data_ref = vb_col->get_data_at(i);
213
24
                if constexpr (ReturnType == TYPE_INT) {
214
12
                    col_to_data[i] = HashUtil::xxHash32WithSeed(data_ref.data, data_ref.size,
215
12
                                                                col_to_data[i]);
216
12
                } else {
217
12
                    col_to_data[i] = HashUtil::xxHash64WithSeed(data_ref.data, data_ref.size,
218
12
                                                                col_to_data[i]);
219
12
                }
220
24
            }
221
12
        } else {
222
0
            DCHECK(false);
223
0
            return Status::NotSupported("Illegal column {} of argument of function {}",
224
0
                                        column->get_name(), name);
225
0
        }
226
142
        return Status::OK();
227
142
    }
_ZN5doris10XxHashImplILNS_13PrimitiveTypeE5EE7executeILb1EEENS_6StatusEPKNS_9IDataTypeEPKNS_7IColumnEmRS8_
Line
Count
Source
175
77
                          IColumn& col_to) {
176
77
        auto& to_column = assert_cast<ColumnVector<ReturnType>&>(col_to);
177
77
        if constexpr (first) {
178
77
            to_column.insert_many_defaults(input_rows_count);
179
77
        }
180
77
        auto& col_to_data = to_column.get_data();
181
77
        if (const auto* col_from = check_and_get_column<ColumnString>(column)) {
182
74
            const typename ColumnString::Chars& data = col_from->get_chars();
183
74
            const typename ColumnString::Offsets& offsets = col_from->get_offsets();
184
74
            size_t size = offsets.size();
185
74
            ColumnString::Offset current_offset = 0;
186
440
            for (size_t i = 0; i < size; ++i) {
187
366
                if constexpr (ReturnType == TYPE_INT) {
188
366
                    col_to_data[i] = HashUtil::xxHash32WithSeed(
189
366
                            reinterpret_cast<const char*>(&data[current_offset]),
190
366
                            offsets[i] - current_offset, col_to_data[i]);
191
                } else {
192
                    col_to_data[i] = HashUtil::xxHash64WithSeed(
193
                            reinterpret_cast<const char*>(&data[current_offset]),
194
                            offsets[i] - current_offset, col_to_data[i]);
195
                }
196
366
                current_offset = offsets[i];
197
366
            }
198
74
        } else if (const ColumnConst* col_from_const =
199
3
                           check_and_get_column_const_string_or_fixedstring(column)) {
200
0
            auto value = col_from_const->get_value<TYPE_STRING>();
201
0
            for (size_t i = 0; i < input_rows_count; ++i) {
202
0
                if constexpr (ReturnType == TYPE_INT) {
203
0
                    col_to_data[i] =
204
0
                            HashUtil::xxHash32WithSeed(value.data(), value.size(), col_to_data[i]);
205
                } else {
206
                    col_to_data[i] =
207
                            HashUtil::xxHash64WithSeed(value.data(), value.size(), col_to_data[i]);
208
                }
209
0
            }
210
3
        } else if (const auto* vb_col = check_and_get_column<ColumnVarbinary>(column)) {
211
9
            for (size_t i = 0; i < input_rows_count; ++i) {
212
6
                auto data_ref = vb_col->get_data_at(i);
213
6
                if constexpr (ReturnType == TYPE_INT) {
214
6
                    col_to_data[i] = HashUtil::xxHash32WithSeed(data_ref.data, data_ref.size,
215
6
                                                                col_to_data[i]);
216
                } else {
217
                    col_to_data[i] = HashUtil::xxHash64WithSeed(data_ref.data, data_ref.size,
218
                                                                col_to_data[i]);
219
                }
220
6
            }
221
3
        } else {
222
0
            DCHECK(false);
223
0
            return Status::NotSupported("Illegal column {} of argument of function {}",
224
0
                                        column->get_name(), name);
225
0
        }
226
77
        return Status::OK();
227
77
    }
_ZN5doris10XxHashImplILNS_13PrimitiveTypeE5EE7executeILb0EEENS_6StatusEPKNS_9IDataTypeEPKNS_7IColumnEmRS8_
Line
Count
Source
175
7
                          IColumn& col_to) {
176
7
        auto& to_column = assert_cast<ColumnVector<ReturnType>&>(col_to);
177
        if constexpr (first) {
178
            to_column.insert_many_defaults(input_rows_count);
179
        }
180
7
        auto& col_to_data = to_column.get_data();
181
7
        if (const auto* col_from = check_and_get_column<ColumnString>(column)) {
182
4
            const typename ColumnString::Chars& data = col_from->get_chars();
183
4
            const typename ColumnString::Offsets& offsets = col_from->get_offsets();
184
4
            size_t size = offsets.size();
185
4
            ColumnString::Offset current_offset = 0;
186
11
            for (size_t i = 0; i < size; ++i) {
187
7
                if constexpr (ReturnType == TYPE_INT) {
188
7
                    col_to_data[i] = HashUtil::xxHash32WithSeed(
189
7
                            reinterpret_cast<const char*>(&data[current_offset]),
190
7
                            offsets[i] - current_offset, col_to_data[i]);
191
                } else {
192
                    col_to_data[i] = HashUtil::xxHash64WithSeed(
193
                            reinterpret_cast<const char*>(&data[current_offset]),
194
                            offsets[i] - current_offset, col_to_data[i]);
195
                }
196
7
                current_offset = offsets[i];
197
7
            }
198
4
        } else if (const ColumnConst* col_from_const =
199
3
                           check_and_get_column_const_string_or_fixedstring(column)) {
200
0
            auto value = col_from_const->get_value<TYPE_STRING>();
201
0
            for (size_t i = 0; i < input_rows_count; ++i) {
202
0
                if constexpr (ReturnType == TYPE_INT) {
203
0
                    col_to_data[i] =
204
0
                            HashUtil::xxHash32WithSeed(value.data(), value.size(), col_to_data[i]);
205
                } else {
206
                    col_to_data[i] =
207
                            HashUtil::xxHash64WithSeed(value.data(), value.size(), col_to_data[i]);
208
                }
209
0
            }
210
3
        } else if (const auto* vb_col = check_and_get_column<ColumnVarbinary>(column)) {
211
9
            for (size_t i = 0; i < input_rows_count; ++i) {
212
6
                auto data_ref = vb_col->get_data_at(i);
213
6
                if constexpr (ReturnType == TYPE_INT) {
214
6
                    col_to_data[i] = HashUtil::xxHash32WithSeed(data_ref.data, data_ref.size,
215
6
                                                                col_to_data[i]);
216
                } else {
217
                    col_to_data[i] = HashUtil::xxHash64WithSeed(data_ref.data, data_ref.size,
218
                                                                col_to_data[i]);
219
                }
220
6
            }
221
3
        } else {
222
0
            DCHECK(false);
223
0
            return Status::NotSupported("Illegal column {} of argument of function {}",
224
0
                                        column->get_name(), name);
225
0
        }
226
7
        return Status::OK();
227
7
    }
_ZN5doris10XxHashImplILNS_13PrimitiveTypeE6EE7executeILb1EEENS_6StatusEPKNS_9IDataTypeEPKNS_7IColumnEmRS8_
Line
Count
Source
175
49
                          IColumn& col_to) {
176
49
        auto& to_column = assert_cast<ColumnVector<ReturnType>&>(col_to);
177
49
        if constexpr (first) {
178
49
            to_column.insert_many_defaults(input_rows_count);
179
49
        }
180
49
        auto& col_to_data = to_column.get_data();
181
49
        if (const auto* col_from = check_and_get_column<ColumnString>(column)) {
182
46
            const typename ColumnString::Chars& data = col_from->get_chars();
183
46
            const typename ColumnString::Offsets& offsets = col_from->get_offsets();
184
46
            size_t size = offsets.size();
185
46
            ColumnString::Offset current_offset = 0;
186
20.6k
            for (size_t i = 0; i < size; ++i) {
187
                if constexpr (ReturnType == TYPE_INT) {
188
                    col_to_data[i] = HashUtil::xxHash32WithSeed(
189
                            reinterpret_cast<const char*>(&data[current_offset]),
190
                            offsets[i] - current_offset, col_to_data[i]);
191
20.5k
                } else {
192
20.5k
                    col_to_data[i] = HashUtil::xxHash64WithSeed(
193
20.5k
                            reinterpret_cast<const char*>(&data[current_offset]),
194
20.5k
                            offsets[i] - current_offset, col_to_data[i]);
195
20.5k
                }
196
20.5k
                current_offset = offsets[i];
197
20.5k
            }
198
46
        } else if (const ColumnConst* col_from_const =
199
3
                           check_and_get_column_const_string_or_fixedstring(column)) {
200
0
            auto value = col_from_const->get_value<TYPE_STRING>();
201
0
            for (size_t i = 0; i < input_rows_count; ++i) {
202
                if constexpr (ReturnType == TYPE_INT) {
203
                    col_to_data[i] =
204
                            HashUtil::xxHash32WithSeed(value.data(), value.size(), col_to_data[i]);
205
0
                } else {
206
0
                    col_to_data[i] =
207
0
                            HashUtil::xxHash64WithSeed(value.data(), value.size(), col_to_data[i]);
208
0
                }
209
0
            }
210
3
        } else if (const auto* vb_col = check_and_get_column<ColumnVarbinary>(column)) {
211
9
            for (size_t i = 0; i < input_rows_count; ++i) {
212
6
                auto data_ref = vb_col->get_data_at(i);
213
                if constexpr (ReturnType == TYPE_INT) {
214
                    col_to_data[i] = HashUtil::xxHash32WithSeed(data_ref.data, data_ref.size,
215
                                                                col_to_data[i]);
216
6
                } else {
217
6
                    col_to_data[i] = HashUtil::xxHash64WithSeed(data_ref.data, data_ref.size,
218
6
                                                                col_to_data[i]);
219
6
                }
220
6
            }
221
3
        } else {
222
0
            DCHECK(false);
223
0
            return Status::NotSupported("Illegal column {} of argument of function {}",
224
0
                                        column->get_name(), name);
225
0
        }
226
49
        return Status::OK();
227
49
    }
_ZN5doris10XxHashImplILNS_13PrimitiveTypeE6EE7executeILb0EEENS_6StatusEPKNS_9IDataTypeEPKNS_7IColumnEmRS8_
Line
Count
Source
175
9
                          IColumn& col_to) {
176
9
        auto& to_column = assert_cast<ColumnVector<ReturnType>&>(col_to);
177
        if constexpr (first) {
178
            to_column.insert_many_defaults(input_rows_count);
179
        }
180
9
        auto& col_to_data = to_column.get_data();
181
9
        if (const auto* col_from = check_and_get_column<ColumnString>(column)) {
182
6
            const typename ColumnString::Chars& data = col_from->get_chars();
183
6
            const typename ColumnString::Offsets& offsets = col_from->get_offsets();
184
6
            size_t size = offsets.size();
185
6
            ColumnString::Offset current_offset = 0;
186
15
            for (size_t i = 0; i < size; ++i) {
187
                if constexpr (ReturnType == TYPE_INT) {
188
                    col_to_data[i] = HashUtil::xxHash32WithSeed(
189
                            reinterpret_cast<const char*>(&data[current_offset]),
190
                            offsets[i] - current_offset, col_to_data[i]);
191
9
                } else {
192
9
                    col_to_data[i] = HashUtil::xxHash64WithSeed(
193
9
                            reinterpret_cast<const char*>(&data[current_offset]),
194
9
                            offsets[i] - current_offset, col_to_data[i]);
195
9
                }
196
9
                current_offset = offsets[i];
197
9
            }
198
6
        } else if (const ColumnConst* col_from_const =
199
3
                           check_and_get_column_const_string_or_fixedstring(column)) {
200
0
            auto value = col_from_const->get_value<TYPE_STRING>();
201
0
            for (size_t i = 0; i < input_rows_count; ++i) {
202
                if constexpr (ReturnType == TYPE_INT) {
203
                    col_to_data[i] =
204
                            HashUtil::xxHash32WithSeed(value.data(), value.size(), col_to_data[i]);
205
0
                } else {
206
0
                    col_to_data[i] =
207
0
                            HashUtil::xxHash64WithSeed(value.data(), value.size(), col_to_data[i]);
208
0
                }
209
0
            }
210
3
        } else if (const auto* vb_col = check_and_get_column<ColumnVarbinary>(column)) {
211
9
            for (size_t i = 0; i < input_rows_count; ++i) {
212
6
                auto data_ref = vb_col->get_data_at(i);
213
                if constexpr (ReturnType == TYPE_INT) {
214
                    col_to_data[i] = HashUtil::xxHash32WithSeed(data_ref.data, data_ref.size,
215
                                                                col_to_data[i]);
216
6
                } else {
217
6
                    col_to_data[i] = HashUtil::xxHash64WithSeed(data_ref.data, data_ref.size,
218
6
                                                                col_to_data[i]);
219
6
                }
220
6
            }
221
3
        } else {
222
0
            DCHECK(false);
223
0
            return Status::NotSupported("Illegal column {} of argument of function {}",
224
0
                                        column->get_name(), name);
225
0
        }
226
9
        return Status::OK();
227
9
    }
228
};
229
230
using FunctionXxHash_32 = FunctionVariadicArgumentsBase<DataTypeInt32, XxHashImpl<TYPE_INT>>;
231
using FunctionXxHash_64 = FunctionVariadicArgumentsBase<DataTypeInt64, XxHashImpl<TYPE_BIGINT>>;
232
233
6
void register_function_hash(SimpleFunctionFactory& factory) {
234
6
    factory.register_function<FunctionMurmurHash3_32>();
235
6
    factory.register_function<FunctionMurmurHash3_64>();
236
6
    factory.register_function<FunctionMurmurHash3_64_V2>();
237
6
    factory.register_function<FunctionMurmurHash3U64V2>();
238
6
    factory.register_function<FunctionXxHash_32>();
239
6
    factory.register_function<FunctionXxHash_64>();
240
6
    factory.register_alias("xxhash_64", "xxhash3_64");
241
6
}
242
} // namespace doris