You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by "amorynan (via GitHub)" <gi...@apache.org> on 2024/01/05 06:41:29 UTC

Re: [PR] [feature](function) support ip functions isipv4string and isipv6string [doris]

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


##########
be/src/vec/functions/function_ip.h:
##########
@@ -348,4 +348,138 @@ class FunctionIPv6NumToString : public IFunction {
     }
 };
 
+class FunctionIsIPv4String : public IFunction {
+private:
+    Status execute_type(Block& block, const ColumnWithTypeAndName& argument, size_t result) const {
+        const ColumnPtr& column = argument.column;
+
+        if (const auto* nullable_src = typeid_cast<const ColumnNullable*>(column.get())) {
+            size_t col_size = nullable_src->size();
+            auto col_res = ColumnUInt8::create(col_size, 0);
+            auto null_map = ColumnUInt8::create(col_size, 0);
+
+            for (size_t i = 0; i < col_size; ++i) {
+                if (nullable_src->is_null_at(i)) {
+                    null_map->get_data()[i] = 1;
+                } else {
+                    StringRef ipv4_str = nullable_src->get_data_at(i);
+                    if (IPv4Value::is_valid_string(ipv4_str.data, ipv4_str.size)) {

Review Comment:
   why not deal with invalid string ?



-- 
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-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org