HappenLee commented on code in PR #31193: URL: https://github.com/apache/doris/pull/31193#discussion_r1498860216
########## be/src/vec/functions/function_hash.cpp: ########## @@ -41,21 +41,84 @@ namespace doris::vectorized { constexpr uint64_t emtpy_value = 0xe28dbde7fe22e41c; template <typename ReturnType> -struct MurmurHash3ImplName {}; +struct MurmurHash3Impl { + static constexpr auto name = + std::is_same_v<ReturnType, Int32> ? "murmur_hash3_32" : "murmur_hash3_64"; -template <> -struct MurmurHash3ImplName<Int32> { - static constexpr auto name = "murmur_hash3_32"; -}; + static Status empty_apply(IColumn& icolumn, size_t input_rows_count) { + ColumnVector<ReturnType>& vec_to = assert_cast<ColumnVector<ReturnType>&>(icolumn); + vec_to.get_data().assign(input_rows_count, static_cast<ReturnType>(emtpy_value)); + return Status::OK(); + } + + static Status first_apply(const IDataType* type, const IColumn* column, size_t input_rows_count, + IColumn& icolumn) { + return execute<true>(type, column, input_rows_count, icolumn); + } + + static Status combine_apply(const IDataType* type, const IColumn* column, + size_t input_rows_count, IColumn& icolumn) { + return execute<false>(type, column, input_rows_count, icolumn); + } -template <> -struct MurmurHash3ImplName<Int64> { - static constexpr auto name = "murmur_hash3_64"; + template <bool first> + static Status execute(const IDataType* type, const IColumn* column, size_t input_rows_count, + IColumn& col_to) { + auto& to_column = assert_cast<ColumnVector<ReturnType>&>(col_to); + if constexpr (first) { + if constexpr (std::is_same_v<ReturnType, Int32>) { + for (int i = 0; i < input_rows_count; ++i) { + to_column.insert_value(static_cast<Int32>(HashUtil::MURMUR3_32_SEED)); Review Comment: do not use insert_value resize + (memset / std::fill) to do the work -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org