amorynan commented on code in PR #29819:
URL: https://github.com/apache/doris/pull/29819#discussion_r1450070282


##########
be/src/vec/functions/function_ip.h:
##########
@@ -832,4 +845,170 @@ class FunctionIsIPAddressInRange : public IFunction {
     }
 };
 
+class FunctionIPv4CIDRToRange : public IFunction {
+private:
+    static inline std::pair<UInt32, UInt32> apply_cidr_mask(UInt32 src, UInt8 
bits_to_keep) {
+        if (bits_to_keep >= 8 * sizeof(UInt32)) {
+            return {src, src};
+        }
+        if (bits_to_keep == 0) {
+            return {static_cast<UInt32>(0), static_cast<UInt32>(-1)};
+        }
+        UInt32 mask = static_cast<UInt32>(-1) << (8 * sizeof(UInt32) - 
bits_to_keep);
+        UInt32 lower = src & mask;
+        UInt32 upper = lower | ~mask;
+
+        return {lower, upper};
+    }
+
+    template <typename ArgType>
+    Status execute_type(Block& block, const ColumnsWithTypeAndName& argments, 
size_t result) const {
+        auto ip_argment = argments[0];
+        auto cidr_argment = argments[1];
+        using ColumnType = ColumnVector<ArgType>;
+        const ColumnPtr& ip_column = ip_argment.column;
+        const ColumnPtr& cidr_column = cidr_argment.column;
+        DCHECK(ip_column->size() == cidr_column->size());
+        size_t col_size = ip_column->size();
+
+        ColumnPtr argument_nullmap[2] = {nullptr, nullptr};
+
+        if (ip_column->is_nullable()) {
+            const auto* col_ip_nullable = 
check_and_get_column<ColumnNullable>(ip_column.get());
+            if (!col_ip_nullable) {
+                return Status::InvalidArgument("Illegal column {} of first 
argument of function {}",
+                                               ip_column->get_name(), 
get_name());
+            }
+            argument_nullmap[0] = col_ip_nullable->get_null_map_column_ptr();
+        }
+
+        if (cidr_column->is_nullable()) {

Review Comment:
   same with IPV6 problems



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