github-actions[bot] commented on code in PR #42485: URL: https://github.com/apache/doris/pull/42485#discussion_r1822412938
########## be/src/vec/functions/function_ip.h: ########## @@ -652,91 +652,180 @@ class FunctionIsIPAddressInRange : public IFunction { size_t get_number_of_arguments() const override { return 2; } DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { - if (arguments.size() != 2) { - throw Exception( - ErrorCode::INVALID_ARGUMENT, - "Number of arguments for function {} doesn't match: passed {}, should be 2", - get_name(), arguments.size()); - } - const auto& addr_type = arguments[0]; - const auto& cidr_type = arguments[1]; - if (!is_string(remove_nullable(addr_type)) || !is_string(remove_nullable(cidr_type))) { - throw Exception(ErrorCode::INVALID_ARGUMENT, - "The arguments of function {} must be String", get_name()); + return make_nullable(std::make_shared<DataTypeUInt8>()); + } + + template <PrimitiveType PT, typename ColumnType> + void execute_impl_with_ip(size_t input_rows_count, bool addr_const, bool cidr_const, + const ColumnString* str_cidr_column, const ColumnPtr addr_column, + ColumnUInt8* col_res) const { + auto& col_res_data = col_res->get_data(); + const auto& ip_data = assert_cast<const ColumnType*>(addr_column.get())->get_data(); + for (size_t i = 0; i < input_rows_count; ++i) { + auto addr_idx = index_check_const(i, addr_const); + auto cidr_idx = index_check_const(i, cidr_const); + const auto cidr = + parse_ip_with_cidr(str_cidr_column->get_data_at(cidr_idx).to_string_view()); + if constexpr (PT == PrimitiveType::TYPE_IPV4) { + if (cidr._address.as_v4()) { + col_res_data[i] = match_ipv4_subnet(ip_data[addr_idx], cidr._address.as_v4(), + cidr._prefix) + ? 1 + : 0; + } else { + col_res_data[i] = 0; + } + } else if constexpr (PT == PrimitiveType::TYPE_IPV6) { + if (cidr._address.as_v6()) { + col_res_data[i] = match_ipv6_subnet((uint8*)(&ip_data[addr_idx]), + cidr._address.as_v6(), cidr._prefix) + ? 1 + : 0; + } else { + col_res_data[i] = 0; + } + } } - return std::make_shared<DataTypeUInt8>(); } - bool use_default_implementation_for_nulls() const override { return false; } + Status evaluate_inverted_index( Review Comment: warning: function 'evaluate_inverted_index' exceeds recommended size/complexity thresholds [readability-function-size] ```cpp Status evaluate_inverted_index( ^ ``` <details> <summary>Additional context</summary> **be/src/vec/functions/function_ip.h:690:** 90 lines including whitespace and comments (threshold 80) ```cpp Status evaluate_inverted_index( ^ ``` </details> -- 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