HappenLee commented on code in PR #32580:
URL: https://github.com/apache/doris/pull/32580#discussion_r1535369277


##########
be/src/vec/functions/function_ip.h:
##########
@@ -714,24 +718,83 @@ class FunctionIsIPAddressInRange : public IFunction {
         auto col_res = ColumnUInt8::create(input_rows_count, 0);
         auto& col_res_data = col_res->get_data();
 
-        for (size_t i = 0; i < input_rows_count; ++i) {
-            if (null_map_addr && (*null_map_addr)[i]) {
+        if (!addr_const && cidr_const) {
+            if (null_map_cidr && (*null_map_cidr)[0]) {
                 throw Exception(ErrorCode::INVALID_ARGUMENT,
                                 "The arguments of function {} must be String, 
not NULL",
                                 get_name());
             }
-            if (null_map_cidr && (*null_map_cidr)[i]) {
+            std::string_view cidr_sv = 
str_cidr_column->get_data_at(0).to_string_view();
+            vector_scalar(str_addr_column, null_map_addr, cidr_sv, 
col_res_data, input_rows_count);
+        } else if (addr_const && !cidr_const) {
+            if (null_map_addr && (*null_map_addr)[0]) {
                 throw Exception(ErrorCode::INVALID_ARGUMENT,
                                 "The arguments of function {} must be String, 
not NULL",
                                 get_name());
             }
+            std::string_view addr_sv = 
str_addr_column->get_data_at(0).to_string_view();
+            scalar_vector(addr_sv, str_cidr_column, null_map_cidr, 
col_res_data, input_rows_count);
+        } else {
+            vector_vector(str_addr_column, null_map_addr, str_cidr_column, 
null_map_cidr,
+                          col_res_data, input_rows_count);
+        }
+
+        block.replace_by_position(result, std::move(col_res));
+        return Status::OK();
+    }
+
+    static void vector_vector(const ColumnString* str_addr_column, const 
NullMap* null_map_addr,
+                              const ColumnString* str_cidr_column, const 
NullMap* null_map_cidr,
+                              ColumnUInt8::Container& col_res_data, size_t 
input_rows_count) {
+        DCHECK(str_addr_column->size() == input_rows_count);
+        DCHECK(str_cidr_column->size() == input_rows_count);
+        for (size_t i = 0; i < input_rows_count; ++i) {
+            if (null_map_addr && (*null_map_addr)[i]) {

Review Comment:
   auto idx = index_check_const(i, is_const_args[j]);



-- 
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

Reply via email to