github-actions[bot] commented on code in PR #24965:
URL: https://github.com/apache/doris/pull/24965#discussion_r1370286281


##########
be/src/vec/runtime/ipv4_value.h:
##########
@@ -0,0 +1,124 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+#include <stdint.h>
+
+#include <algorithm>
+#include <regex>
+#include <sstream>
+#include <string>
+
+#include "util/string_parser.hpp"
+
+namespace doris {
+
+class IPv4Value {
+public:
+    IPv4Value() = default;
+
+    explicit IPv4Value(vectorized::IPv4 ipv4) { _value = ipv4; }
+
+    explicit IPv4Value(std::string ipv4) {}
+
+    [[nodiscard]] const vectorized::IPv4& value() const { return _value; }
+
+    vectorized::IPv4& value() { return _value; }
+
+    void set_value(vectorized::IPv4 ipv4) { _value = ipv4; }
+
+    bool from_string(std::string ipv4) { return from_string(_value, ipv4); }
+
+    [[nodiscard]] std::string to_string() const { return to_string(_value); }
+
+    static bool from_string(vectorized::IPv4& value, std::string ipv4) {
+        remove_ipv4_space(ipv4);
+
+        // shortest ipv4 string is `0.0.0.0` whose length is 7
+        if (ipv4.size() < 7 || !is_valid_string(ipv4)) {
+            return false;
+        }
+
+        vectorized::IPv4 octets[4] = {0};
+        std::istringstream iss(ipv4);
+        std::string octet;
+        uint8_t octet_index = 0;
+
+        while (getline(iss, octet, '.')) {
+            if (octet_index >= 4) {
+                return false;
+            }
+
+            StringParser::ParseResult result;
+            vectorized::IPv4 val = 
StringParser::string_to_unsigned_int<vectorized::IPv4>(
+                    octet.c_str(), octet.length(), &result);
+            if (result != StringParser::PARSE_SUCCESS || val > 255) {
+                return false;
+            }
+
+            octets[octet_index++] = val;
+        }
+
+        if (octet_index != 4) {
+            return false;
+        }
+
+        value = (octets[0] << 24) | (octets[1] << 16) | (octets[2] << 8) | 
octets[3];
+        return true;
+    }
+
+    static std::string to_string(vectorized::IPv4 value) {
+        std::stringstream ss;
+        ss << ((value >> 24) & 0xFF) << '.' << ((value >> 16) & 0xFF) << '.'
+           << ((value >> 8) & 0xFF) << '.' << (value & 0xFF);

Review Comment:
   warning: 0xFF is a magic number; consider replacing it with a named constant 
[readability-magic-numbers]
   ```cpp
              << ((value >> 8) & 0xFF) << '.' << (value & 0xFF);
                                                          ^
   ```
   



##########
be/src/vec/runtime/ipv4_value.h:
##########
@@ -0,0 +1,124 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+#include <stdint.h>
+
+#include <algorithm>
+#include <regex>
+#include <sstream>
+#include <string>
+
+#include "util/string_parser.hpp"
+
+namespace doris {
+
+class IPv4Value {
+public:
+    IPv4Value() = default;
+
+    explicit IPv4Value(vectorized::IPv4 ipv4) { _value = ipv4; }
+
+    explicit IPv4Value(std::string ipv4) {}
+
+    [[nodiscard]] const vectorized::IPv4& value() const { return _value; }
+
+    vectorized::IPv4& value() { return _value; }
+
+    void set_value(vectorized::IPv4 ipv4) { _value = ipv4; }
+
+    bool from_string(std::string ipv4) { return from_string(_value, ipv4); }
+
+    [[nodiscard]] std::string to_string() const { return to_string(_value); }
+
+    static bool from_string(vectorized::IPv4& value, std::string ipv4) {
+        remove_ipv4_space(ipv4);
+
+        // shortest ipv4 string is `0.0.0.0` whose length is 7
+        if (ipv4.size() < 7 || !is_valid_string(ipv4)) {
+            return false;
+        }
+
+        vectorized::IPv4 octets[4] = {0};
+        std::istringstream iss(ipv4);
+        std::string octet;
+        uint8_t octet_index = 0;
+
+        while (getline(iss, octet, '.')) {
+            if (octet_index >= 4) {
+                return false;
+            }
+
+            StringParser::ParseResult result;
+            vectorized::IPv4 val = 
StringParser::string_to_unsigned_int<vectorized::IPv4>(
+                    octet.c_str(), octet.length(), &result);
+            if (result != StringParser::PARSE_SUCCESS || val > 255) {
+                return false;
+            }
+
+            octets[octet_index++] = val;
+        }
+
+        if (octet_index != 4) {
+            return false;
+        }
+
+        value = (octets[0] << 24) | (octets[1] << 16) | (octets[2] << 8) | 
octets[3];
+        return true;
+    }
+
+    static std::string to_string(vectorized::IPv4 value) {
+        std::stringstream ss;
+        ss << ((value >> 24) & 0xFF) << '.' << ((value >> 16) & 0xFF) << '.'
+           << ((value >> 8) & 0xFF) << '.' << (value & 0xFF);
+        return ss.str();
+    }
+
+    static void remove_ipv4_space(std::string& ipv4) {
+        if (ipv4.empty()) {
+            return;
+        }
+
+        std::string special_chars = "\r\n\t ";
+
+        size_t pos = ipv4.find_first_not_of(special_chars);
+        if (pos != std::string::npos) {
+            ipv4.erase(0, pos);
+        }
+
+        pos = ipv4.find_last_not_of(special_chars);
+        if (pos != std::string::npos) {
+            ipv4.erase(pos + 1);
+        }
+    }
+
+    static bool is_valid_string(std::string ipv4) {
+        static std::regex IPV4_STD_REGEX(
+                
"^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-"
+                "9]?)$");
+        if (ipv4.size() > 15 || !std::regex_match(ipv4, IPV4_STD_REGEX)) {
+            return false;

Review Comment:
   warning: redundant boolean literal in conditional return statement 
[readability-simplify-boolean-expr]
   
   be/src/vec/runtime/ipv4_value.h:113:
   ```diff
   -         if (ipv4.size() > 15 || !std::regex_match(ipv4, IPV4_STD_REGEX)) {
   -             return false;
   -         }
   -         return true;
   +         return !static_cast<bool>(ipv4.size() > 15 || 
!std::regex_match(ipv4, IPV4_STD_REGEX));
   ```
   



##########
be/src/vec/data_types/data_type_ipv4.h:
##########
@@ -0,0 +1,75 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+#include <gen_cpp/Types_types.h>
+#include <stddef.h>
+
+#include <algorithm>
+#include <boost/iterator/iterator_facade.hpp>
+#include <string>
+
+#include "common/status.h"
+#include "runtime/define_primitive_type.h"
+#include "vec/core/types.h"
+#include "vec/data_types/data_type.h"
+#include "vec/data_types/data_type_number_base.h"
+#include "vec/data_types/serde/data_type_ipv4_serde.h"
+
+namespace doris {
+namespace vectorized {
+class BufferWritable;
+class ReadBuffer;
+class IColumn;
+} // namespace vectorized
+} // namespace doris
+
+namespace doris::vectorized {
+
+class DataTypeIPv4 final : public DataTypeNumberBase<IPv4> {
+public:
+    TypeIndex get_type_id() const override { return TypeIndex::IPv4; }
+    TPrimitiveType::type get_type_as_tprimitive_type() const override {
+        return TPrimitiveType::IPV4;
+    }
+    const char* get_family_name() const override { return "IPv4"; }
+    std::string do_get_name() const override { return "IPv4"; }
+
+    bool can_be_inside_nullable() const override { return true; }
+
+    bool equals(const IDataType& rhs) const override;
+    std::string to_string(const IColumn& column, size_t row_num) const 
override;
+    void to_string(const IColumn& column, size_t row_num, BufferWritable& 
ostr) const override;
+    Status from_string(ReadBuffer& rb, IColumn* column) const override;
+
+    static std::string convert_ipv4_to_string(IPv4 ipv4);
+    static bool convert_string_to_ipv4(IPv4& x, std::string ipv4);
+
+    Field get_field(const TExprNode& node) const override { return 
(IPv4)node.ipv4_literal.value; }

Review Comment:
   warning: method 'get_field' can be made static 
[readability-convert-member-functions-to-static]
   
   ```suggestion
       static Field get_field(const TExprNode& node) override { return 
(IPv4)node.ipv4_literal.value; }
   ```
   



##########
be/src/vec/runtime/ipv4_value.h:
##########
@@ -0,0 +1,124 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+#include <stdint.h>
+
+#include <algorithm>
+#include <regex>
+#include <sstream>
+#include <string>
+
+#include "util/string_parser.hpp"
+
+namespace doris {
+
+class IPv4Value {
+public:
+    IPv4Value() = default;
+
+    explicit IPv4Value(vectorized::IPv4 ipv4) { _value = ipv4; }
+
+    explicit IPv4Value(std::string ipv4) {}
+
+    [[nodiscard]] const vectorized::IPv4& value() const { return _value; }
+
+    vectorized::IPv4& value() { return _value; }
+
+    void set_value(vectorized::IPv4 ipv4) { _value = ipv4; }
+
+    bool from_string(std::string ipv4) { return from_string(_value, ipv4); }
+
+    [[nodiscard]] std::string to_string() const { return to_string(_value); }
+
+    static bool from_string(vectorized::IPv4& value, std::string ipv4) {
+        remove_ipv4_space(ipv4);
+
+        // shortest ipv4 string is `0.0.0.0` whose length is 7
+        if (ipv4.size() < 7 || !is_valid_string(ipv4)) {
+            return false;
+        }
+
+        vectorized::IPv4 octets[4] = {0};
+        std::istringstream iss(ipv4);
+        std::string octet;
+        uint8_t octet_index = 0;
+
+        while (getline(iss, octet, '.')) {
+            if (octet_index >= 4) {
+                return false;
+            }
+
+            StringParser::ParseResult result;
+            vectorized::IPv4 val = 
StringParser::string_to_unsigned_int<vectorized::IPv4>(
+                    octet.c_str(), octet.length(), &result);
+            if (result != StringParser::PARSE_SUCCESS || val > 255) {
+                return false;
+            }
+
+            octets[octet_index++] = val;
+        }
+
+        if (octet_index != 4) {
+            return false;
+        }
+
+        value = (octets[0] << 24) | (octets[1] << 16) | (octets[2] << 8) | 
octets[3];
+        return true;
+    }
+
+    static std::string to_string(vectorized::IPv4 value) {
+        std::stringstream ss;
+        ss << ((value >> 24) & 0xFF) << '.' << ((value >> 16) & 0xFF) << '.'
+           << ((value >> 8) & 0xFF) << '.' << (value & 0xFF);

Review Comment:
   warning: 0xFF is a magic number; consider replacing it with a named constant 
[readability-magic-numbers]
   ```cpp
              << ((value >> 8) & 0xFF) << '.' << (value & 0xFF);
                                 ^
   ```
   



##########
be/src/vec/runtime/ipv6_value.h:
##########
@@ -0,0 +1,257 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+#include <stdint.h>
+
+#include <regex>
+#include <sstream>
+#include <string>
+
+#include "vec/core/types.h"
+#include "vec/data_types/data_type.h"
+#include "vec/data_types/data_type_number_base.h"
+
+namespace doris {
+
+class IPv6Value {
+public:
+    IPv6Value() {
+        _value.high = 0;
+        _value.low = 0;
+    }
+
+    explicit IPv6Value(vectorized::IPv6 ipv6) { _value = ipv6; }
+
+    [[nodiscard]] const vectorized::IPv6& value() const { return _value; }
+
+    vectorized::IPv6& value() { return _value; }
+
+    void set_value(vectorized::IPv6 ipv6) { _value = ipv6; }
+
+    bool from_string(std::string ipv6) { return from_string(_value, ipv6); }
+
+    bool from_binary_string(std::string ipv6_binary) {
+        return from_binary_string(_value, ipv6_binary);
+    }
+
+    static bool from_string(vectorized::IPv6& x, std::string ipv6) {
+        remove_ipv6_space(ipv6);
+
+        if (ipv6.empty() || !is_valid_string(ipv6)) {
+            return false;
+        }
+
+        std::transform(ipv6.begin(), ipv6.end(), ipv6.begin(),
+                       [](unsigned char ch) { return std::tolower(ch); });
+        std::istringstream iss(ipv6);
+        std::string field;
+        uint16_t fields[8] = {0};
+        uint8_t zero_index = 0;
+        uint8_t num_field = 0;
+        uint8_t right_field_num = 0;
+
+        while (num_field < 8) {
+            if (!getline(iss, field, ':')) {
+                break;
+            }
+
+            if (field.empty()) {
+                zero_index = num_field;
+                fields[num_field++] = 0;
+            } else {
+                try {
+                    if (field.size() > 4 || field > "ffff") {
+                        return false;
+                    }
+
+                    fields[num_field++] = std::stoi(field, nullptr, 16);
+                } catch (const std::exception& /*e*/) {
+                    return false;
+                }
+            }
+        }
+
+        if (zero_index != 0) {
+            right_field_num = num_field - zero_index - 1;
+
+            for (uint8_t i = 7; i > 7 - right_field_num; --i) {
+                fields[i] = fields[zero_index + right_field_num + i - 7];
+                fields[zero_index + right_field_num + i - 7] = 0;
+            }
+        }
+
+        x.high = (static_cast<uint64_t>(fields[0]) << 48) |
+                 (static_cast<uint64_t>(fields[1]) << 32) |
+                 (static_cast<uint64_t>(fields[2]) << 16) | 
static_cast<uint64_t>(fields[3]);
+        x.low = (static_cast<uint64_t>(fields[4]) << 48) |
+                (static_cast<uint64_t>(fields[5]) << 32) |
+                (static_cast<uint64_t>(fields[6]) << 16) | 
static_cast<uint64_t>(fields[7]);
+
+        return true;
+    }
+
+    static bool from_binary_string(vectorized::IPv6& x, std::string 
ipv6_binary_str) {
+        // Accepts a FixedString(16) value containing the IPv6 address in 
binary format
+        if (ipv6_binary_str.size() != 16) {
+            return false;
+        }
+
+        x.high = 0;
+        x.low = 0;
+
+        const uint8_t* ipv6_binary = reinterpret_cast<const 
uint8_t*>(ipv6_binary_str.c_str());
+
+        for (int i = 0; i < 8; ++i) {
+            x.high |= (static_cast<uint64_t>(ipv6_binary[i]) << (56 - i * 8));
+        }
+
+        for (int i = 8; i < 16; ++i) {
+            x.low |= (static_cast<uint64_t>(ipv6_binary[i]) << (56 - (i - 8) * 
8));
+        }
+
+        return true;
+    }
+
+    [[nodiscard]] std::string to_string() const { return to_string(_value); }
+
+    static std::string to_string(vectorized::IPv6 x) {
+        // "0000:0000:0000:0000:0000:0000:0000:0000"
+        if (x.high == 0 && x.low == 0) {
+            return "::";
+        }
+
+        uint16_t fields[8] = {static_cast<uint16_t>((x.high >> 48) & 0xFFFF),

Review Comment:
   warning: 8 is a magic number; consider replacing it with a named constant 
[readability-magic-numbers]
   ```cpp
           uint16_t fields[8] = {static_cast<uint16_t>((x.high >> 48) & 0xFFFF),
                           ^
   ```
   



##########
be/src/vec/runtime/ipv6_value.h:
##########
@@ -0,0 +1,257 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+#include <stdint.h>
+
+#include <regex>
+#include <sstream>
+#include <string>
+
+#include "vec/core/types.h"
+#include "vec/data_types/data_type.h"
+#include "vec/data_types/data_type_number_base.h"
+
+namespace doris {
+
+class IPv6Value {
+public:
+    IPv6Value() {
+        _value.high = 0;
+        _value.low = 0;
+    }
+
+    explicit IPv6Value(vectorized::IPv6 ipv6) { _value = ipv6; }
+
+    [[nodiscard]] const vectorized::IPv6& value() const { return _value; }
+
+    vectorized::IPv6& value() { return _value; }
+
+    void set_value(vectorized::IPv6 ipv6) { _value = ipv6; }
+
+    bool from_string(std::string ipv6) { return from_string(_value, ipv6); }
+
+    bool from_binary_string(std::string ipv6_binary) {
+        return from_binary_string(_value, ipv6_binary);
+    }
+
+    static bool from_string(vectorized::IPv6& x, std::string ipv6) {
+        remove_ipv6_space(ipv6);
+
+        if (ipv6.empty() || !is_valid_string(ipv6)) {
+            return false;
+        }
+
+        std::transform(ipv6.begin(), ipv6.end(), ipv6.begin(),
+                       [](unsigned char ch) { return std::tolower(ch); });
+        std::istringstream iss(ipv6);
+        std::string field;
+        uint16_t fields[8] = {0};
+        uint8_t zero_index = 0;
+        uint8_t num_field = 0;
+        uint8_t right_field_num = 0;
+
+        while (num_field < 8) {
+            if (!getline(iss, field, ':')) {
+                break;
+            }
+
+            if (field.empty()) {
+                zero_index = num_field;
+                fields[num_field++] = 0;
+            } else {
+                try {
+                    if (field.size() > 4 || field > "ffff") {
+                        return false;
+                    }
+
+                    fields[num_field++] = std::stoi(field, nullptr, 16);
+                } catch (const std::exception& /*e*/) {
+                    return false;
+                }
+            }
+        }
+
+        if (zero_index != 0) {
+            right_field_num = num_field - zero_index - 1;
+
+            for (uint8_t i = 7; i > 7 - right_field_num; --i) {
+                fields[i] = fields[zero_index + right_field_num + i - 7];
+                fields[zero_index + right_field_num + i - 7] = 0;
+            }
+        }
+
+        x.high = (static_cast<uint64_t>(fields[0]) << 48) |
+                 (static_cast<uint64_t>(fields[1]) << 32) |
+                 (static_cast<uint64_t>(fields[2]) << 16) | 
static_cast<uint64_t>(fields[3]);
+        x.low = (static_cast<uint64_t>(fields[4]) << 48) |
+                (static_cast<uint64_t>(fields[5]) << 32) |
+                (static_cast<uint64_t>(fields[6]) << 16) | 
static_cast<uint64_t>(fields[7]);
+
+        return true;
+    }
+
+    static bool from_binary_string(vectorized::IPv6& x, std::string 
ipv6_binary_str) {
+        // Accepts a FixedString(16) value containing the IPv6 address in 
binary format
+        if (ipv6_binary_str.size() != 16) {
+            return false;
+        }
+
+        x.high = 0;
+        x.low = 0;
+
+        const uint8_t* ipv6_binary = reinterpret_cast<const 
uint8_t*>(ipv6_binary_str.c_str());
+
+        for (int i = 0; i < 8; ++i) {
+            x.high |= (static_cast<uint64_t>(ipv6_binary[i]) << (56 - i * 8));
+        }
+
+        for (int i = 8; i < 16; ++i) {
+            x.low |= (static_cast<uint64_t>(ipv6_binary[i]) << (56 - (i - 8) * 
8));
+        }
+
+        return true;
+    }
+
+    [[nodiscard]] std::string to_string() const { return to_string(_value); }
+
+    static std::string to_string(vectorized::IPv6 x) {
+        // "0000:0000:0000:0000:0000:0000:0000:0000"
+        if (x.high == 0 && x.low == 0) {
+            return "::";
+        }
+
+        uint16_t fields[8] = {static_cast<uint16_t>((x.high >> 48) & 0xFFFF),

Review Comment:
   warning: 0xFFFF is a magic number; consider replacing it with a named 
constant [readability-magic-numbers]
   ```cpp
           uint16_t fields[8] = {static_cast<uint16_t>((x.high >> 48) & 0xFFFF),
                                                                        ^
   ```
   



##########
be/src/vec/runtime/ipv6_value.h:
##########
@@ -0,0 +1,257 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+#include <stdint.h>
+
+#include <regex>
+#include <sstream>
+#include <string>
+
+#include "vec/core/types.h"
+#include "vec/data_types/data_type.h"
+#include "vec/data_types/data_type_number_base.h"
+
+namespace doris {
+
+class IPv6Value {
+public:
+    IPv6Value() {
+        _value.high = 0;
+        _value.low = 0;
+    }
+
+    explicit IPv6Value(vectorized::IPv6 ipv6) { _value = ipv6; }
+
+    [[nodiscard]] const vectorized::IPv6& value() const { return _value; }
+
+    vectorized::IPv6& value() { return _value; }
+
+    void set_value(vectorized::IPv6 ipv6) { _value = ipv6; }
+
+    bool from_string(std::string ipv6) { return from_string(_value, ipv6); }
+
+    bool from_binary_string(std::string ipv6_binary) {
+        return from_binary_string(_value, ipv6_binary);
+    }
+
+    static bool from_string(vectorized::IPv6& x, std::string ipv6) {
+        remove_ipv6_space(ipv6);
+
+        if (ipv6.empty() || !is_valid_string(ipv6)) {
+            return false;
+        }
+
+        std::transform(ipv6.begin(), ipv6.end(), ipv6.begin(),
+                       [](unsigned char ch) { return std::tolower(ch); });
+        std::istringstream iss(ipv6);
+        std::string field;
+        uint16_t fields[8] = {0};
+        uint8_t zero_index = 0;
+        uint8_t num_field = 0;
+        uint8_t right_field_num = 0;
+
+        while (num_field < 8) {
+            if (!getline(iss, field, ':')) {
+                break;
+            }
+
+            if (field.empty()) {
+                zero_index = num_field;
+                fields[num_field++] = 0;
+            } else {
+                try {
+                    if (field.size() > 4 || field > "ffff") {
+                        return false;
+                    }
+
+                    fields[num_field++] = std::stoi(field, nullptr, 16);
+                } catch (const std::exception& /*e*/) {
+                    return false;
+                }
+            }
+        }
+
+        if (zero_index != 0) {
+            right_field_num = num_field - zero_index - 1;
+
+            for (uint8_t i = 7; i > 7 - right_field_num; --i) {
+                fields[i] = fields[zero_index + right_field_num + i - 7];
+                fields[zero_index + right_field_num + i - 7] = 0;
+            }
+        }
+
+        x.high = (static_cast<uint64_t>(fields[0]) << 48) |
+                 (static_cast<uint64_t>(fields[1]) << 32) |
+                 (static_cast<uint64_t>(fields[2]) << 16) | 
static_cast<uint64_t>(fields[3]);
+        x.low = (static_cast<uint64_t>(fields[4]) << 48) |
+                (static_cast<uint64_t>(fields[5]) << 32) |
+                (static_cast<uint64_t>(fields[6]) << 16) | 
static_cast<uint64_t>(fields[7]);
+
+        return true;
+    }
+
+    static bool from_binary_string(vectorized::IPv6& x, std::string 
ipv6_binary_str) {
+        // Accepts a FixedString(16) value containing the IPv6 address in 
binary format
+        if (ipv6_binary_str.size() != 16) {
+            return false;
+        }
+
+        x.high = 0;
+        x.low = 0;
+
+        const uint8_t* ipv6_binary = reinterpret_cast<const 
uint8_t*>(ipv6_binary_str.c_str());
+
+        for (int i = 0; i < 8; ++i) {
+            x.high |= (static_cast<uint64_t>(ipv6_binary[i]) << (56 - i * 8));
+        }
+
+        for (int i = 8; i < 16; ++i) {
+            x.low |= (static_cast<uint64_t>(ipv6_binary[i]) << (56 - (i - 8) * 
8));
+        }
+
+        return true;
+    }
+
+    [[nodiscard]] std::string to_string() const { return to_string(_value); }
+
+    static std::string to_string(vectorized::IPv6 x) {
+        // "0000:0000:0000:0000:0000:0000:0000:0000"
+        if (x.high == 0 && x.low == 0) {
+            return "::";
+        }
+
+        uint16_t fields[8] = {static_cast<uint16_t>((x.high >> 48) & 0xFFFF),
+                              static_cast<uint16_t>((x.high >> 32) & 0xFFFF),

Review Comment:
   warning: 0xFFFF is a magic number; consider replacing it with a named 
constant [readability-magic-numbers]
   ```cpp
                                 static_cast<uint16_t>((x.high >> 32) & 0xFFFF),
                                                                        ^
   ```
   



##########
be/src/vec/runtime/ipv6_value.h:
##########
@@ -0,0 +1,257 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+#include <stdint.h>
+
+#include <regex>
+#include <sstream>
+#include <string>
+
+#include "vec/core/types.h"
+#include "vec/data_types/data_type.h"
+#include "vec/data_types/data_type_number_base.h"
+
+namespace doris {
+
+class IPv6Value {
+public:
+    IPv6Value() {
+        _value.high = 0;
+        _value.low = 0;
+    }
+
+    explicit IPv6Value(vectorized::IPv6 ipv6) { _value = ipv6; }
+
+    [[nodiscard]] const vectorized::IPv6& value() const { return _value; }
+
+    vectorized::IPv6& value() { return _value; }
+
+    void set_value(vectorized::IPv6 ipv6) { _value = ipv6; }
+
+    bool from_string(std::string ipv6) { return from_string(_value, ipv6); }
+
+    bool from_binary_string(std::string ipv6_binary) {
+        return from_binary_string(_value, ipv6_binary);
+    }
+
+    static bool from_string(vectorized::IPv6& x, std::string ipv6) {
+        remove_ipv6_space(ipv6);
+
+        if (ipv6.empty() || !is_valid_string(ipv6)) {
+            return false;
+        }
+
+        std::transform(ipv6.begin(), ipv6.end(), ipv6.begin(),
+                       [](unsigned char ch) { return std::tolower(ch); });
+        std::istringstream iss(ipv6);
+        std::string field;
+        uint16_t fields[8] = {0};
+        uint8_t zero_index = 0;
+        uint8_t num_field = 0;
+        uint8_t right_field_num = 0;
+
+        while (num_field < 8) {
+            if (!getline(iss, field, ':')) {
+                break;
+            }
+
+            if (field.empty()) {
+                zero_index = num_field;
+                fields[num_field++] = 0;
+            } else {
+                try {
+                    if (field.size() > 4 || field > "ffff") {
+                        return false;
+                    }
+
+                    fields[num_field++] = std::stoi(field, nullptr, 16);
+                } catch (const std::exception& /*e*/) {
+                    return false;
+                }
+            }
+        }
+
+        if (zero_index != 0) {
+            right_field_num = num_field - zero_index - 1;
+
+            for (uint8_t i = 7; i > 7 - right_field_num; --i) {
+                fields[i] = fields[zero_index + right_field_num + i - 7];
+                fields[zero_index + right_field_num + i - 7] = 0;
+            }
+        }
+
+        x.high = (static_cast<uint64_t>(fields[0]) << 48) |
+                 (static_cast<uint64_t>(fields[1]) << 32) |
+                 (static_cast<uint64_t>(fields[2]) << 16) | 
static_cast<uint64_t>(fields[3]);
+        x.low = (static_cast<uint64_t>(fields[4]) << 48) |
+                (static_cast<uint64_t>(fields[5]) << 32) |
+                (static_cast<uint64_t>(fields[6]) << 16) | 
static_cast<uint64_t>(fields[7]);
+
+        return true;
+    }
+
+    static bool from_binary_string(vectorized::IPv6& x, std::string 
ipv6_binary_str) {
+        // Accepts a FixedString(16) value containing the IPv6 address in 
binary format
+        if (ipv6_binary_str.size() != 16) {
+            return false;
+        }
+
+        x.high = 0;
+        x.low = 0;
+
+        const uint8_t* ipv6_binary = reinterpret_cast<const 
uint8_t*>(ipv6_binary_str.c_str());
+
+        for (int i = 0; i < 8; ++i) {
+            x.high |= (static_cast<uint64_t>(ipv6_binary[i]) << (56 - i * 8));
+        }
+
+        for (int i = 8; i < 16; ++i) {
+            x.low |= (static_cast<uint64_t>(ipv6_binary[i]) << (56 - (i - 8) * 
8));
+        }
+
+        return true;
+    }
+
+    [[nodiscard]] std::string to_string() const { return to_string(_value); }
+
+    static std::string to_string(vectorized::IPv6 x) {
+        // "0000:0000:0000:0000:0000:0000:0000:0000"
+        if (x.high == 0 && x.low == 0) {
+            return "::";
+        }
+
+        uint16_t fields[8] = {static_cast<uint16_t>((x.high >> 48) & 0xFFFF),
+                              static_cast<uint16_t>((x.high >> 32) & 0xFFFF),
+                              static_cast<uint16_t>((x.high >> 16) & 0xFFFF),

Review Comment:
   warning: 0xFFFF is a magic number; consider replacing it with a named 
constant [readability-magic-numbers]
   ```cpp
                                 static_cast<uint16_t>((x.high >> 16) & 0xFFFF),
                                                                        ^
   ```
   



##########
be/src/vec/runtime/ipv6_value.h:
##########
@@ -0,0 +1,257 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+#include <stdint.h>
+
+#include <regex>
+#include <sstream>
+#include <string>
+
+#include "vec/core/types.h"
+#include "vec/data_types/data_type.h"
+#include "vec/data_types/data_type_number_base.h"
+
+namespace doris {
+
+class IPv6Value {
+public:
+    IPv6Value() {
+        _value.high = 0;
+        _value.low = 0;
+    }
+
+    explicit IPv6Value(vectorized::IPv6 ipv6) { _value = ipv6; }
+
+    [[nodiscard]] const vectorized::IPv6& value() const { return _value; }
+
+    vectorized::IPv6& value() { return _value; }
+
+    void set_value(vectorized::IPv6 ipv6) { _value = ipv6; }
+
+    bool from_string(std::string ipv6) { return from_string(_value, ipv6); }
+
+    bool from_binary_string(std::string ipv6_binary) {
+        return from_binary_string(_value, ipv6_binary);
+    }
+
+    static bool from_string(vectorized::IPv6& x, std::string ipv6) {
+        remove_ipv6_space(ipv6);
+
+        if (ipv6.empty() || !is_valid_string(ipv6)) {
+            return false;
+        }
+
+        std::transform(ipv6.begin(), ipv6.end(), ipv6.begin(),
+                       [](unsigned char ch) { return std::tolower(ch); });
+        std::istringstream iss(ipv6);
+        std::string field;
+        uint16_t fields[8] = {0};
+        uint8_t zero_index = 0;
+        uint8_t num_field = 0;
+        uint8_t right_field_num = 0;
+
+        while (num_field < 8) {
+            if (!getline(iss, field, ':')) {
+                break;
+            }
+
+            if (field.empty()) {
+                zero_index = num_field;
+                fields[num_field++] = 0;
+            } else {
+                try {
+                    if (field.size() > 4 || field > "ffff") {
+                        return false;
+                    }
+
+                    fields[num_field++] = std::stoi(field, nullptr, 16);
+                } catch (const std::exception& /*e*/) {
+                    return false;
+                }
+            }
+        }
+
+        if (zero_index != 0) {
+            right_field_num = num_field - zero_index - 1;
+
+            for (uint8_t i = 7; i > 7 - right_field_num; --i) {
+                fields[i] = fields[zero_index + right_field_num + i - 7];
+                fields[zero_index + right_field_num + i - 7] = 0;
+            }
+        }
+
+        x.high = (static_cast<uint64_t>(fields[0]) << 48) |
+                 (static_cast<uint64_t>(fields[1]) << 32) |
+                 (static_cast<uint64_t>(fields[2]) << 16) | 
static_cast<uint64_t>(fields[3]);
+        x.low = (static_cast<uint64_t>(fields[4]) << 48) |
+                (static_cast<uint64_t>(fields[5]) << 32) |
+                (static_cast<uint64_t>(fields[6]) << 16) | 
static_cast<uint64_t>(fields[7]);
+
+        return true;
+    }
+
+    static bool from_binary_string(vectorized::IPv6& x, std::string 
ipv6_binary_str) {
+        // Accepts a FixedString(16) value containing the IPv6 address in 
binary format
+        if (ipv6_binary_str.size() != 16) {
+            return false;
+        }
+
+        x.high = 0;
+        x.low = 0;
+
+        const uint8_t* ipv6_binary = reinterpret_cast<const 
uint8_t*>(ipv6_binary_str.c_str());
+
+        for (int i = 0; i < 8; ++i) {
+            x.high |= (static_cast<uint64_t>(ipv6_binary[i]) << (56 - i * 8));
+        }
+
+        for (int i = 8; i < 16; ++i) {
+            x.low |= (static_cast<uint64_t>(ipv6_binary[i]) << (56 - (i - 8) * 
8));
+        }
+
+        return true;
+    }
+
+    [[nodiscard]] std::string to_string() const { return to_string(_value); }
+
+    static std::string to_string(vectorized::IPv6 x) {
+        // "0000:0000:0000:0000:0000:0000:0000:0000"
+        if (x.high == 0 && x.low == 0) {
+            return "::";
+        }
+
+        uint16_t fields[8] = {static_cast<uint16_t>((x.high >> 48) & 0xFFFF),
+                              static_cast<uint16_t>((x.high >> 32) & 0xFFFF),

Review Comment:
   warning: 32 is a magic number; consider replacing it with a named constant 
[readability-magic-numbers]
   ```cpp
                                 static_cast<uint16_t>((x.high >> 32) & 0xFFFF),
                                                                  ^
   ```
   



##########
be/src/vec/runtime/ipv6_value.h:
##########
@@ -0,0 +1,257 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+#include <stdint.h>
+
+#include <regex>
+#include <sstream>
+#include <string>
+
+#include "vec/core/types.h"
+#include "vec/data_types/data_type.h"
+#include "vec/data_types/data_type_number_base.h"
+
+namespace doris {
+
+class IPv6Value {
+public:
+    IPv6Value() {
+        _value.high = 0;
+        _value.low = 0;
+    }
+
+    explicit IPv6Value(vectorized::IPv6 ipv6) { _value = ipv6; }
+
+    [[nodiscard]] const vectorized::IPv6& value() const { return _value; }
+
+    vectorized::IPv6& value() { return _value; }
+
+    void set_value(vectorized::IPv6 ipv6) { _value = ipv6; }
+
+    bool from_string(std::string ipv6) { return from_string(_value, ipv6); }
+
+    bool from_binary_string(std::string ipv6_binary) {
+        return from_binary_string(_value, ipv6_binary);
+    }
+
+    static bool from_string(vectorized::IPv6& x, std::string ipv6) {
+        remove_ipv6_space(ipv6);
+
+        if (ipv6.empty() || !is_valid_string(ipv6)) {
+            return false;
+        }
+
+        std::transform(ipv6.begin(), ipv6.end(), ipv6.begin(),
+                       [](unsigned char ch) { return std::tolower(ch); });
+        std::istringstream iss(ipv6);
+        std::string field;
+        uint16_t fields[8] = {0};
+        uint8_t zero_index = 0;
+        uint8_t num_field = 0;
+        uint8_t right_field_num = 0;
+
+        while (num_field < 8) {
+            if (!getline(iss, field, ':')) {
+                break;
+            }
+
+            if (field.empty()) {
+                zero_index = num_field;
+                fields[num_field++] = 0;
+            } else {
+                try {
+                    if (field.size() > 4 || field > "ffff") {
+                        return false;
+                    }
+
+                    fields[num_field++] = std::stoi(field, nullptr, 16);
+                } catch (const std::exception& /*e*/) {
+                    return false;
+                }
+            }
+        }
+
+        if (zero_index != 0) {
+            right_field_num = num_field - zero_index - 1;
+
+            for (uint8_t i = 7; i > 7 - right_field_num; --i) {
+                fields[i] = fields[zero_index + right_field_num + i - 7];
+                fields[zero_index + right_field_num + i - 7] = 0;
+            }
+        }
+
+        x.high = (static_cast<uint64_t>(fields[0]) << 48) |
+                 (static_cast<uint64_t>(fields[1]) << 32) |
+                 (static_cast<uint64_t>(fields[2]) << 16) | 
static_cast<uint64_t>(fields[3]);
+        x.low = (static_cast<uint64_t>(fields[4]) << 48) |
+                (static_cast<uint64_t>(fields[5]) << 32) |
+                (static_cast<uint64_t>(fields[6]) << 16) | 
static_cast<uint64_t>(fields[7]);
+
+        return true;
+    }
+
+    static bool from_binary_string(vectorized::IPv6& x, std::string 
ipv6_binary_str) {
+        // Accepts a FixedString(16) value containing the IPv6 address in 
binary format
+        if (ipv6_binary_str.size() != 16) {
+            return false;
+        }
+
+        x.high = 0;
+        x.low = 0;
+
+        const uint8_t* ipv6_binary = reinterpret_cast<const 
uint8_t*>(ipv6_binary_str.c_str());
+
+        for (int i = 0; i < 8; ++i) {
+            x.high |= (static_cast<uint64_t>(ipv6_binary[i]) << (56 - i * 8));
+        }
+
+        for (int i = 8; i < 16; ++i) {
+            x.low |= (static_cast<uint64_t>(ipv6_binary[i]) << (56 - (i - 8) * 
8));
+        }
+
+        return true;
+    }
+
+    [[nodiscard]] std::string to_string() const { return to_string(_value); }
+
+    static std::string to_string(vectorized::IPv6 x) {
+        // "0000:0000:0000:0000:0000:0000:0000:0000"
+        if (x.high == 0 && x.low == 0) {
+            return "::";
+        }
+
+        uint16_t fields[8] = {static_cast<uint16_t>((x.high >> 48) & 0xFFFF),
+                              static_cast<uint16_t>((x.high >> 32) & 0xFFFF),
+                              static_cast<uint16_t>((x.high >> 16) & 0xFFFF),

Review Comment:
   warning: 16 is a magic number; consider replacing it with a named constant 
[readability-magic-numbers]
   ```cpp
                                 static_cast<uint16_t>((x.high >> 16) & 0xFFFF),
                                                                  ^
   ```
   



##########
be/src/vec/runtime/ipv6_value.h:
##########
@@ -0,0 +1,257 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+#include <stdint.h>
+
+#include <regex>
+#include <sstream>
+#include <string>
+
+#include "vec/core/types.h"
+#include "vec/data_types/data_type.h"
+#include "vec/data_types/data_type_number_base.h"
+
+namespace doris {
+
+class IPv6Value {
+public:
+    IPv6Value() {
+        _value.high = 0;
+        _value.low = 0;
+    }
+
+    explicit IPv6Value(vectorized::IPv6 ipv6) { _value = ipv6; }
+
+    [[nodiscard]] const vectorized::IPv6& value() const { return _value; }
+
+    vectorized::IPv6& value() { return _value; }
+
+    void set_value(vectorized::IPv6 ipv6) { _value = ipv6; }
+
+    bool from_string(std::string ipv6) { return from_string(_value, ipv6); }
+
+    bool from_binary_string(std::string ipv6_binary) {
+        return from_binary_string(_value, ipv6_binary);
+    }
+
+    static bool from_string(vectorized::IPv6& x, std::string ipv6) {
+        remove_ipv6_space(ipv6);
+
+        if (ipv6.empty() || !is_valid_string(ipv6)) {
+            return false;
+        }
+
+        std::transform(ipv6.begin(), ipv6.end(), ipv6.begin(),
+                       [](unsigned char ch) { return std::tolower(ch); });
+        std::istringstream iss(ipv6);
+        std::string field;
+        uint16_t fields[8] = {0};
+        uint8_t zero_index = 0;
+        uint8_t num_field = 0;
+        uint8_t right_field_num = 0;
+
+        while (num_field < 8) {
+            if (!getline(iss, field, ':')) {
+                break;
+            }
+
+            if (field.empty()) {
+                zero_index = num_field;
+                fields[num_field++] = 0;
+            } else {
+                try {
+                    if (field.size() > 4 || field > "ffff") {
+                        return false;
+                    }
+
+                    fields[num_field++] = std::stoi(field, nullptr, 16);
+                } catch (const std::exception& /*e*/) {
+                    return false;
+                }
+            }
+        }
+
+        if (zero_index != 0) {
+            right_field_num = num_field - zero_index - 1;
+
+            for (uint8_t i = 7; i > 7 - right_field_num; --i) {
+                fields[i] = fields[zero_index + right_field_num + i - 7];
+                fields[zero_index + right_field_num + i - 7] = 0;
+            }
+        }
+
+        x.high = (static_cast<uint64_t>(fields[0]) << 48) |
+                 (static_cast<uint64_t>(fields[1]) << 32) |
+                 (static_cast<uint64_t>(fields[2]) << 16) | 
static_cast<uint64_t>(fields[3]);
+        x.low = (static_cast<uint64_t>(fields[4]) << 48) |
+                (static_cast<uint64_t>(fields[5]) << 32) |
+                (static_cast<uint64_t>(fields[6]) << 16) | 
static_cast<uint64_t>(fields[7]);
+
+        return true;
+    }
+
+    static bool from_binary_string(vectorized::IPv6& x, std::string 
ipv6_binary_str) {
+        // Accepts a FixedString(16) value containing the IPv6 address in 
binary format
+        if (ipv6_binary_str.size() != 16) {
+            return false;
+        }
+
+        x.high = 0;
+        x.low = 0;
+
+        const uint8_t* ipv6_binary = reinterpret_cast<const 
uint8_t*>(ipv6_binary_str.c_str());
+
+        for (int i = 0; i < 8; ++i) {
+            x.high |= (static_cast<uint64_t>(ipv6_binary[i]) << (56 - i * 8));
+        }
+
+        for (int i = 8; i < 16; ++i) {
+            x.low |= (static_cast<uint64_t>(ipv6_binary[i]) << (56 - (i - 8) * 
8));
+        }
+
+        return true;
+    }
+
+    [[nodiscard]] std::string to_string() const { return to_string(_value); }
+
+    static std::string to_string(vectorized::IPv6 x) {
+        // "0000:0000:0000:0000:0000:0000:0000:0000"
+        if (x.high == 0 && x.low == 0) {
+            return "::";
+        }
+
+        uint16_t fields[8] = {static_cast<uint16_t>((x.high >> 48) & 0xFFFF),
+                              static_cast<uint16_t>((x.high >> 32) & 0xFFFF),
+                              static_cast<uint16_t>((x.high >> 16) & 0xFFFF),
+                              static_cast<uint16_t>(x.high & 0xFFFF),
+                              static_cast<uint16_t>((x.low >> 48) & 0xFFFF),
+                              static_cast<uint16_t>((x.low >> 32) & 0xFFFF),
+                              static_cast<uint16_t>((x.low >> 16) & 0xFFFF),

Review Comment:
   warning: 0xFFFF is a magic number; consider replacing it with a named 
constant [readability-magic-numbers]
   ```cpp
                                 static_cast<uint16_t>((x.low >> 16) & 0xFFFF),
                                                                       ^
   ```
   



##########
be/src/vec/runtime/ipv4_value.h:
##########
@@ -0,0 +1,124 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+#include <stdint.h>
+
+#include <algorithm>
+#include <regex>
+#include <sstream>
+#include <string>
+
+#include "util/string_parser.hpp"
+
+namespace doris {
+
+class IPv4Value {
+public:
+    IPv4Value() = default;
+
+    explicit IPv4Value(vectorized::IPv4 ipv4) { _value = ipv4; }
+
+    explicit IPv4Value(std::string ipv4) {}
+
+    [[nodiscard]] const vectorized::IPv4& value() const { return _value; }
+
+    vectorized::IPv4& value() { return _value; }
+
+    void set_value(vectorized::IPv4 ipv4) { _value = ipv4; }
+
+    bool from_string(std::string ipv4) { return from_string(_value, ipv4); }
+
+    [[nodiscard]] std::string to_string() const { return to_string(_value); }
+
+    static bool from_string(vectorized::IPv4& value, std::string ipv4) {
+        remove_ipv4_space(ipv4);
+
+        // shortest ipv4 string is `0.0.0.0` whose length is 7
+        if (ipv4.size() < 7 || !is_valid_string(ipv4)) {
+            return false;
+        }
+
+        vectorized::IPv4 octets[4] = {0};
+        std::istringstream iss(ipv4);
+        std::string octet;
+        uint8_t octet_index = 0;
+
+        while (getline(iss, octet, '.')) {
+            if (octet_index >= 4) {
+                return false;
+            }
+
+            StringParser::ParseResult result;
+            vectorized::IPv4 val = 
StringParser::string_to_unsigned_int<vectorized::IPv4>(
+                    octet.c_str(), octet.length(), &result);
+            if (result != StringParser::PARSE_SUCCESS || val > 255) {
+                return false;
+            }
+
+            octets[octet_index++] = val;
+        }
+
+        if (octet_index != 4) {
+            return false;
+        }
+
+        value = (octets[0] << 24) | (octets[1] << 16) | (octets[2] << 8) | 
octets[3];
+        return true;
+    }
+
+    static std::string to_string(vectorized::IPv4 value) {
+        std::stringstream ss;
+        ss << ((value >> 24) & 0xFF) << '.' << ((value >> 16) & 0xFF) << '.'
+           << ((value >> 8) & 0xFF) << '.' << (value & 0xFF);

Review Comment:
   warning: 8 is a magic number; consider replacing it with a named constant 
[readability-magic-numbers]
   ```cpp
              << ((value >> 8) & 0xFF) << '.' << (value & 0xFF);
                            ^
   ```
   



##########
be/src/vec/runtime/ipv6_value.h:
##########
@@ -0,0 +1,257 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+#include <stdint.h>
+
+#include <regex>
+#include <sstream>
+#include <string>
+
+#include "vec/core/types.h"
+#include "vec/data_types/data_type.h"
+#include "vec/data_types/data_type_number_base.h"
+
+namespace doris {
+
+class IPv6Value {
+public:
+    IPv6Value() {
+        _value.high = 0;
+        _value.low = 0;
+    }
+
+    explicit IPv6Value(vectorized::IPv6 ipv6) { _value = ipv6; }
+
+    [[nodiscard]] const vectorized::IPv6& value() const { return _value; }
+
+    vectorized::IPv6& value() { return _value; }
+
+    void set_value(vectorized::IPv6 ipv6) { _value = ipv6; }
+
+    bool from_string(std::string ipv6) { return from_string(_value, ipv6); }
+
+    bool from_binary_string(std::string ipv6_binary) {
+        return from_binary_string(_value, ipv6_binary);
+    }
+
+    static bool from_string(vectorized::IPv6& x, std::string ipv6) {
+        remove_ipv6_space(ipv6);
+
+        if (ipv6.empty() || !is_valid_string(ipv6)) {
+            return false;
+        }
+
+        std::transform(ipv6.begin(), ipv6.end(), ipv6.begin(),
+                       [](unsigned char ch) { return std::tolower(ch); });
+        std::istringstream iss(ipv6);
+        std::string field;
+        uint16_t fields[8] = {0};
+        uint8_t zero_index = 0;
+        uint8_t num_field = 0;
+        uint8_t right_field_num = 0;
+
+        while (num_field < 8) {
+            if (!getline(iss, field, ':')) {
+                break;
+            }
+
+            if (field.empty()) {
+                zero_index = num_field;
+                fields[num_field++] = 0;
+            } else {
+                try {
+                    if (field.size() > 4 || field > "ffff") {
+                        return false;
+                    }
+
+                    fields[num_field++] = std::stoi(field, nullptr, 16);
+                } catch (const std::exception& /*e*/) {
+                    return false;
+                }
+            }
+        }
+
+        if (zero_index != 0) {
+            right_field_num = num_field - zero_index - 1;
+
+            for (uint8_t i = 7; i > 7 - right_field_num; --i) {
+                fields[i] = fields[zero_index + right_field_num + i - 7];
+                fields[zero_index + right_field_num + i - 7] = 0;
+            }
+        }
+
+        x.high = (static_cast<uint64_t>(fields[0]) << 48) |
+                 (static_cast<uint64_t>(fields[1]) << 32) |

Review Comment:
   warning: 32 is a magic number; consider replacing it with a named constant 
[readability-magic-numbers]
   ```cpp
                    (static_cast<uint64_t>(fields[1]) << 32) |
                                                         ^
   ```
   



##########
be/src/vec/runtime/ipv6_value.h:
##########
@@ -0,0 +1,257 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+#include <stdint.h>
+
+#include <regex>
+#include <sstream>
+#include <string>
+
+#include "vec/core/types.h"
+#include "vec/data_types/data_type.h"
+#include "vec/data_types/data_type_number_base.h"
+
+namespace doris {
+
+class IPv6Value {
+public:
+    IPv6Value() {
+        _value.high = 0;
+        _value.low = 0;
+    }
+
+    explicit IPv6Value(vectorized::IPv6 ipv6) { _value = ipv6; }
+
+    [[nodiscard]] const vectorized::IPv6& value() const { return _value; }
+
+    vectorized::IPv6& value() { return _value; }
+
+    void set_value(vectorized::IPv6 ipv6) { _value = ipv6; }
+
+    bool from_string(std::string ipv6) { return from_string(_value, ipv6); }
+
+    bool from_binary_string(std::string ipv6_binary) {
+        return from_binary_string(_value, ipv6_binary);
+    }
+
+    static bool from_string(vectorized::IPv6& x, std::string ipv6) {
+        remove_ipv6_space(ipv6);
+
+        if (ipv6.empty() || !is_valid_string(ipv6)) {
+            return false;
+        }
+
+        std::transform(ipv6.begin(), ipv6.end(), ipv6.begin(),
+                       [](unsigned char ch) { return std::tolower(ch); });
+        std::istringstream iss(ipv6);
+        std::string field;
+        uint16_t fields[8] = {0};
+        uint8_t zero_index = 0;
+        uint8_t num_field = 0;
+        uint8_t right_field_num = 0;
+
+        while (num_field < 8) {
+            if (!getline(iss, field, ':')) {
+                break;
+            }
+
+            if (field.empty()) {
+                zero_index = num_field;
+                fields[num_field++] = 0;
+            } else {
+                try {
+                    if (field.size() > 4 || field > "ffff") {
+                        return false;
+                    }
+
+                    fields[num_field++] = std::stoi(field, nullptr, 16);
+                } catch (const std::exception& /*e*/) {
+                    return false;
+                }
+            }
+        }
+
+        if (zero_index != 0) {
+            right_field_num = num_field - zero_index - 1;
+
+            for (uint8_t i = 7; i > 7 - right_field_num; --i) {
+                fields[i] = fields[zero_index + right_field_num + i - 7];
+                fields[zero_index + right_field_num + i - 7] = 0;
+            }
+        }
+
+        x.high = (static_cast<uint64_t>(fields[0]) << 48) |

Review Comment:
   warning: 48 is a magic number; consider replacing it with a named constant 
[readability-magic-numbers]
   ```cpp
           x.high = (static_cast<uint64_t>(fields[0]) << 48) |
                                                         ^
   ```
   



##########
be/src/vec/runtime/ipv6_value.h:
##########
@@ -0,0 +1,257 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+#include <stdint.h>
+
+#include <regex>
+#include <sstream>
+#include <string>
+
+#include "vec/core/types.h"
+#include "vec/data_types/data_type.h"
+#include "vec/data_types/data_type_number_base.h"
+
+namespace doris {
+
+class IPv6Value {
+public:
+    IPv6Value() {
+        _value.high = 0;
+        _value.low = 0;
+    }
+
+    explicit IPv6Value(vectorized::IPv6 ipv6) { _value = ipv6; }
+
+    [[nodiscard]] const vectorized::IPv6& value() const { return _value; }
+
+    vectorized::IPv6& value() { return _value; }
+
+    void set_value(vectorized::IPv6 ipv6) { _value = ipv6; }
+
+    bool from_string(std::string ipv6) { return from_string(_value, ipv6); }
+
+    bool from_binary_string(std::string ipv6_binary) {
+        return from_binary_string(_value, ipv6_binary);
+    }
+
+    static bool from_string(vectorized::IPv6& x, std::string ipv6) {
+        remove_ipv6_space(ipv6);
+
+        if (ipv6.empty() || !is_valid_string(ipv6)) {
+            return false;
+        }
+
+        std::transform(ipv6.begin(), ipv6.end(), ipv6.begin(),
+                       [](unsigned char ch) { return std::tolower(ch); });
+        std::istringstream iss(ipv6);
+        std::string field;
+        uint16_t fields[8] = {0};
+        uint8_t zero_index = 0;
+        uint8_t num_field = 0;
+        uint8_t right_field_num = 0;
+
+        while (num_field < 8) {
+            if (!getline(iss, field, ':')) {
+                break;
+            }
+
+            if (field.empty()) {
+                zero_index = num_field;
+                fields[num_field++] = 0;
+            } else {
+                try {
+                    if (field.size() > 4 || field > "ffff") {
+                        return false;
+                    }
+
+                    fields[num_field++] = std::stoi(field, nullptr, 16);
+                } catch (const std::exception& /*e*/) {
+                    return false;
+                }
+            }
+        }
+
+        if (zero_index != 0) {
+            right_field_num = num_field - zero_index - 1;
+
+            for (uint8_t i = 7; i > 7 - right_field_num; --i) {
+                fields[i] = fields[zero_index + right_field_num + i - 7];
+                fields[zero_index + right_field_num + i - 7] = 0;
+            }
+        }
+
+        x.high = (static_cast<uint64_t>(fields[0]) << 48) |
+                 (static_cast<uint64_t>(fields[1]) << 32) |
+                 (static_cast<uint64_t>(fields[2]) << 16) | 
static_cast<uint64_t>(fields[3]);
+        x.low = (static_cast<uint64_t>(fields[4]) << 48) |
+                (static_cast<uint64_t>(fields[5]) << 32) |

Review Comment:
   warning: 5 is a magic number; consider replacing it with a named constant 
[readability-magic-numbers]
   ```cpp
                   (static_cast<uint64_t>(fields[5]) << 32) |
                                                 ^
   ```
   



##########
be/src/vec/runtime/ipv6_value.h:
##########
@@ -0,0 +1,257 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+#include <stdint.h>
+
+#include <regex>
+#include <sstream>
+#include <string>
+
+#include "vec/core/types.h"
+#include "vec/data_types/data_type.h"
+#include "vec/data_types/data_type_number_base.h"
+
+namespace doris {
+
+class IPv6Value {
+public:
+    IPv6Value() {
+        _value.high = 0;
+        _value.low = 0;
+    }
+
+    explicit IPv6Value(vectorized::IPv6 ipv6) { _value = ipv6; }
+
+    [[nodiscard]] const vectorized::IPv6& value() const { return _value; }
+
+    vectorized::IPv6& value() { return _value; }
+
+    void set_value(vectorized::IPv6 ipv6) { _value = ipv6; }
+
+    bool from_string(std::string ipv6) { return from_string(_value, ipv6); }
+
+    bool from_binary_string(std::string ipv6_binary) {
+        return from_binary_string(_value, ipv6_binary);
+    }
+
+    static bool from_string(vectorized::IPv6& x, std::string ipv6) {
+        remove_ipv6_space(ipv6);
+
+        if (ipv6.empty() || !is_valid_string(ipv6)) {
+            return false;
+        }
+
+        std::transform(ipv6.begin(), ipv6.end(), ipv6.begin(),
+                       [](unsigned char ch) { return std::tolower(ch); });
+        std::istringstream iss(ipv6);
+        std::string field;
+        uint16_t fields[8] = {0};
+        uint8_t zero_index = 0;
+        uint8_t num_field = 0;
+        uint8_t right_field_num = 0;
+
+        while (num_field < 8) {
+            if (!getline(iss, field, ':')) {
+                break;
+            }
+
+            if (field.empty()) {
+                zero_index = num_field;
+                fields[num_field++] = 0;
+            } else {
+                try {
+                    if (field.size() > 4 || field > "ffff") {
+                        return false;
+                    }
+
+                    fields[num_field++] = std::stoi(field, nullptr, 16);
+                } catch (const std::exception& /*e*/) {
+                    return false;
+                }
+            }
+        }
+
+        if (zero_index != 0) {
+            right_field_num = num_field - zero_index - 1;
+
+            for (uint8_t i = 7; i > 7 - right_field_num; --i) {
+                fields[i] = fields[zero_index + right_field_num + i - 7];
+                fields[zero_index + right_field_num + i - 7] = 0;
+            }
+        }
+
+        x.high = (static_cast<uint64_t>(fields[0]) << 48) |
+                 (static_cast<uint64_t>(fields[1]) << 32) |
+                 (static_cast<uint64_t>(fields[2]) << 16) | 
static_cast<uint64_t>(fields[3]);
+        x.low = (static_cast<uint64_t>(fields[4]) << 48) |

Review Comment:
   warning: 48 is a magic number; consider replacing it with a named constant 
[readability-magic-numbers]
   ```cpp
           x.low = (static_cast<uint64_t>(fields[4]) << 48) |
                                                        ^
   ```
   



##########
be/src/vec/runtime/ipv6_value.h:
##########
@@ -0,0 +1,257 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+#include <stdint.h>
+
+#include <regex>
+#include <sstream>
+#include <string>
+
+#include "vec/core/types.h"
+#include "vec/data_types/data_type.h"
+#include "vec/data_types/data_type_number_base.h"
+
+namespace doris {
+
+class IPv6Value {
+public:
+    IPv6Value() {
+        _value.high = 0;
+        _value.low = 0;
+    }
+
+    explicit IPv6Value(vectorized::IPv6 ipv6) { _value = ipv6; }
+
+    [[nodiscard]] const vectorized::IPv6& value() const { return _value; }
+
+    vectorized::IPv6& value() { return _value; }
+
+    void set_value(vectorized::IPv6 ipv6) { _value = ipv6; }
+
+    bool from_string(std::string ipv6) { return from_string(_value, ipv6); }
+
+    bool from_binary_string(std::string ipv6_binary) {
+        return from_binary_string(_value, ipv6_binary);
+    }
+
+    static bool from_string(vectorized::IPv6& x, std::string ipv6) {
+        remove_ipv6_space(ipv6);
+
+        if (ipv6.empty() || !is_valid_string(ipv6)) {
+            return false;
+        }
+
+        std::transform(ipv6.begin(), ipv6.end(), ipv6.begin(),
+                       [](unsigned char ch) { return std::tolower(ch); });
+        std::istringstream iss(ipv6);
+        std::string field;
+        uint16_t fields[8] = {0};
+        uint8_t zero_index = 0;
+        uint8_t num_field = 0;
+        uint8_t right_field_num = 0;
+
+        while (num_field < 8) {
+            if (!getline(iss, field, ':')) {
+                break;
+            }
+
+            if (field.empty()) {
+                zero_index = num_field;
+                fields[num_field++] = 0;
+            } else {
+                try {
+                    if (field.size() > 4 || field > "ffff") {
+                        return false;
+                    }
+
+                    fields[num_field++] = std::stoi(field, nullptr, 16);
+                } catch (const std::exception& /*e*/) {
+                    return false;
+                }
+            }
+        }
+
+        if (zero_index != 0) {
+            right_field_num = num_field - zero_index - 1;
+
+            for (uint8_t i = 7; i > 7 - right_field_num; --i) {
+                fields[i] = fields[zero_index + right_field_num + i - 7];
+                fields[zero_index + right_field_num + i - 7] = 0;
+            }
+        }
+
+        x.high = (static_cast<uint64_t>(fields[0]) << 48) |
+                 (static_cast<uint64_t>(fields[1]) << 32) |
+                 (static_cast<uint64_t>(fields[2]) << 16) | 
static_cast<uint64_t>(fields[3]);
+        x.low = (static_cast<uint64_t>(fields[4]) << 48) |
+                (static_cast<uint64_t>(fields[5]) << 32) |
+                (static_cast<uint64_t>(fields[6]) << 16) | 
static_cast<uint64_t>(fields[7]);
+
+        return true;
+    }
+
+    static bool from_binary_string(vectorized::IPv6& x, std::string 
ipv6_binary_str) {
+        // Accepts a FixedString(16) value containing the IPv6 address in 
binary format
+        if (ipv6_binary_str.size() != 16) {
+            return false;
+        }
+
+        x.high = 0;
+        x.low = 0;
+
+        const uint8_t* ipv6_binary = reinterpret_cast<const 
uint8_t*>(ipv6_binary_str.c_str());
+
+        for (int i = 0; i < 8; ++i) {
+            x.high |= (static_cast<uint64_t>(ipv6_binary[i]) << (56 - i * 8));
+        }
+
+        for (int i = 8; i < 16; ++i) {
+            x.low |= (static_cast<uint64_t>(ipv6_binary[i]) << (56 - (i - 8) * 
8));
+        }
+
+        return true;
+    }
+
+    [[nodiscard]] std::string to_string() const { return to_string(_value); }
+
+    static std::string to_string(vectorized::IPv6 x) {
+        // "0000:0000:0000:0000:0000:0000:0000:0000"
+        if (x.high == 0 && x.low == 0) {
+            return "::";
+        }
+
+        uint16_t fields[8] = {static_cast<uint16_t>((x.high >> 48) & 0xFFFF),

Review Comment:
   warning: do not declare C-style arrays, use std::array<> instead 
[modernize-avoid-c-arrays]
   ```cpp
           uint16_t fields[8] = {static_cast<uint16_t>((x.high >> 48) & 0xFFFF),
           ^
   ```
   



##########
be/src/vec/runtime/ipv6_value.h:
##########
@@ -0,0 +1,257 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+#include <stdint.h>
+
+#include <regex>
+#include <sstream>
+#include <string>
+
+#include "vec/core/types.h"
+#include "vec/data_types/data_type.h"
+#include "vec/data_types/data_type_number_base.h"
+
+namespace doris {
+
+class IPv6Value {
+public:
+    IPv6Value() {
+        _value.high = 0;
+        _value.low = 0;
+    }
+
+    explicit IPv6Value(vectorized::IPv6 ipv6) { _value = ipv6; }
+
+    [[nodiscard]] const vectorized::IPv6& value() const { return _value; }
+
+    vectorized::IPv6& value() { return _value; }
+
+    void set_value(vectorized::IPv6 ipv6) { _value = ipv6; }
+
+    bool from_string(std::string ipv6) { return from_string(_value, ipv6); }
+
+    bool from_binary_string(std::string ipv6_binary) {
+        return from_binary_string(_value, ipv6_binary);
+    }
+
+    static bool from_string(vectorized::IPv6& x, std::string ipv6) {
+        remove_ipv6_space(ipv6);
+
+        if (ipv6.empty() || !is_valid_string(ipv6)) {
+            return false;
+        }
+
+        std::transform(ipv6.begin(), ipv6.end(), ipv6.begin(),
+                       [](unsigned char ch) { return std::tolower(ch); });
+        std::istringstream iss(ipv6);
+        std::string field;
+        uint16_t fields[8] = {0};
+        uint8_t zero_index = 0;
+        uint8_t num_field = 0;
+        uint8_t right_field_num = 0;
+
+        while (num_field < 8) {
+            if (!getline(iss, field, ':')) {
+                break;
+            }
+
+            if (field.empty()) {
+                zero_index = num_field;
+                fields[num_field++] = 0;
+            } else {
+                try {
+                    if (field.size() > 4 || field > "ffff") {
+                        return false;
+                    }
+
+                    fields[num_field++] = std::stoi(field, nullptr, 16);
+                } catch (const std::exception& /*e*/) {
+                    return false;
+                }
+            }
+        }
+
+        if (zero_index != 0) {
+            right_field_num = num_field - zero_index - 1;
+
+            for (uint8_t i = 7; i > 7 - right_field_num; --i) {
+                fields[i] = fields[zero_index + right_field_num + i - 7];
+                fields[zero_index + right_field_num + i - 7] = 0;
+            }
+        }
+
+        x.high = (static_cast<uint64_t>(fields[0]) << 48) |
+                 (static_cast<uint64_t>(fields[1]) << 32) |
+                 (static_cast<uint64_t>(fields[2]) << 16) | 
static_cast<uint64_t>(fields[3]);
+        x.low = (static_cast<uint64_t>(fields[4]) << 48) |
+                (static_cast<uint64_t>(fields[5]) << 32) |

Review Comment:
   warning: 32 is a magic number; consider replacing it with a named constant 
[readability-magic-numbers]
   ```cpp
                   (static_cast<uint64_t>(fields[5]) << 32) |
                                                        ^
   ```
   



##########
be/src/vec/runtime/ipv6_value.h:
##########
@@ -0,0 +1,257 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+#include <stdint.h>
+
+#include <regex>
+#include <sstream>
+#include <string>
+
+#include "vec/core/types.h"
+#include "vec/data_types/data_type.h"
+#include "vec/data_types/data_type_number_base.h"
+
+namespace doris {
+
+class IPv6Value {
+public:
+    IPv6Value() {
+        _value.high = 0;
+        _value.low = 0;
+    }
+
+    explicit IPv6Value(vectorized::IPv6 ipv6) { _value = ipv6; }
+
+    [[nodiscard]] const vectorized::IPv6& value() const { return _value; }
+
+    vectorized::IPv6& value() { return _value; }
+
+    void set_value(vectorized::IPv6 ipv6) { _value = ipv6; }
+
+    bool from_string(std::string ipv6) { return from_string(_value, ipv6); }
+
+    bool from_binary_string(std::string ipv6_binary) {
+        return from_binary_string(_value, ipv6_binary);
+    }
+
+    static bool from_string(vectorized::IPv6& x, std::string ipv6) {
+        remove_ipv6_space(ipv6);
+
+        if (ipv6.empty() || !is_valid_string(ipv6)) {
+            return false;
+        }
+
+        std::transform(ipv6.begin(), ipv6.end(), ipv6.begin(),
+                       [](unsigned char ch) { return std::tolower(ch); });
+        std::istringstream iss(ipv6);
+        std::string field;
+        uint16_t fields[8] = {0};
+        uint8_t zero_index = 0;
+        uint8_t num_field = 0;
+        uint8_t right_field_num = 0;
+
+        while (num_field < 8) {
+            if (!getline(iss, field, ':')) {
+                break;
+            }
+
+            if (field.empty()) {
+                zero_index = num_field;
+                fields[num_field++] = 0;
+            } else {
+                try {
+                    if (field.size() > 4 || field > "ffff") {
+                        return false;
+                    }
+
+                    fields[num_field++] = std::stoi(field, nullptr, 16);
+                } catch (const std::exception& /*e*/) {
+                    return false;
+                }
+            }
+        }
+
+        if (zero_index != 0) {
+            right_field_num = num_field - zero_index - 1;
+
+            for (uint8_t i = 7; i > 7 - right_field_num; --i) {
+                fields[i] = fields[zero_index + right_field_num + i - 7];
+                fields[zero_index + right_field_num + i - 7] = 0;
+            }
+        }
+
+        x.high = (static_cast<uint64_t>(fields[0]) << 48) |
+                 (static_cast<uint64_t>(fields[1]) << 32) |
+                 (static_cast<uint64_t>(fields[2]) << 16) | 
static_cast<uint64_t>(fields[3]);
+        x.low = (static_cast<uint64_t>(fields[4]) << 48) |
+                (static_cast<uint64_t>(fields[5]) << 32) |
+                (static_cast<uint64_t>(fields[6]) << 16) | 
static_cast<uint64_t>(fields[7]);
+
+        return true;
+    }
+
+    static bool from_binary_string(vectorized::IPv6& x, std::string 
ipv6_binary_str) {
+        // Accepts a FixedString(16) value containing the IPv6 address in 
binary format
+        if (ipv6_binary_str.size() != 16) {
+            return false;
+        }
+
+        x.high = 0;
+        x.low = 0;
+
+        const uint8_t* ipv6_binary = reinterpret_cast<const 
uint8_t*>(ipv6_binary_str.c_str());
+
+        for (int i = 0; i < 8; ++i) {
+            x.high |= (static_cast<uint64_t>(ipv6_binary[i]) << (56 - i * 8));
+        }
+
+        for (int i = 8; i < 16; ++i) {
+            x.low |= (static_cast<uint64_t>(ipv6_binary[i]) << (56 - (i - 8) * 
8));
+        }
+
+        return true;
+    }
+
+    [[nodiscard]] std::string to_string() const { return to_string(_value); }
+
+    static std::string to_string(vectorized::IPv6 x) {
+        // "0000:0000:0000:0000:0000:0000:0000:0000"
+        if (x.high == 0 && x.low == 0) {
+            return "::";
+        }
+
+        uint16_t fields[8] = {static_cast<uint16_t>((x.high >> 48) & 0xFFFF),

Review Comment:
   warning: 48 is a magic number; consider replacing it with a named constant 
[readability-magic-numbers]
   ```cpp
           uint16_t fields[8] = {static_cast<uint16_t>((x.high >> 48) & 0xFFFF),
                                                                  ^
   ```
   



##########
be/src/vec/runtime/ipv6_value.h:
##########
@@ -0,0 +1,257 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+#include <stdint.h>
+
+#include <regex>
+#include <sstream>
+#include <string>
+
+#include "vec/core/types.h"
+#include "vec/data_types/data_type.h"
+#include "vec/data_types/data_type_number_base.h"
+
+namespace doris {
+
+class IPv6Value {
+public:
+    IPv6Value() {
+        _value.high = 0;
+        _value.low = 0;
+    }
+
+    explicit IPv6Value(vectorized::IPv6 ipv6) { _value = ipv6; }
+
+    [[nodiscard]] const vectorized::IPv6& value() const { return _value; }
+
+    vectorized::IPv6& value() { return _value; }
+
+    void set_value(vectorized::IPv6 ipv6) { _value = ipv6; }
+
+    bool from_string(std::string ipv6) { return from_string(_value, ipv6); }
+
+    bool from_binary_string(std::string ipv6_binary) {
+        return from_binary_string(_value, ipv6_binary);
+    }
+
+    static bool from_string(vectorized::IPv6& x, std::string ipv6) {
+        remove_ipv6_space(ipv6);
+
+        if (ipv6.empty() || !is_valid_string(ipv6)) {
+            return false;
+        }
+
+        std::transform(ipv6.begin(), ipv6.end(), ipv6.begin(),
+                       [](unsigned char ch) { return std::tolower(ch); });
+        std::istringstream iss(ipv6);
+        std::string field;
+        uint16_t fields[8] = {0};
+        uint8_t zero_index = 0;
+        uint8_t num_field = 0;
+        uint8_t right_field_num = 0;
+
+        while (num_field < 8) {
+            if (!getline(iss, field, ':')) {
+                break;
+            }
+
+            if (field.empty()) {
+                zero_index = num_field;
+                fields[num_field++] = 0;
+            } else {
+                try {
+                    if (field.size() > 4 || field > "ffff") {
+                        return false;
+                    }
+
+                    fields[num_field++] = std::stoi(field, nullptr, 16);
+                } catch (const std::exception& /*e*/) {
+                    return false;
+                }
+            }
+        }
+
+        if (zero_index != 0) {
+            right_field_num = num_field - zero_index - 1;
+
+            for (uint8_t i = 7; i > 7 - right_field_num; --i) {
+                fields[i] = fields[zero_index + right_field_num + i - 7];
+                fields[zero_index + right_field_num + i - 7] = 0;
+            }
+        }
+
+        x.high = (static_cast<uint64_t>(fields[0]) << 48) |
+                 (static_cast<uint64_t>(fields[1]) << 32) |
+                 (static_cast<uint64_t>(fields[2]) << 16) | 
static_cast<uint64_t>(fields[3]);
+        x.low = (static_cast<uint64_t>(fields[4]) << 48) |
+                (static_cast<uint64_t>(fields[5]) << 32) |
+                (static_cast<uint64_t>(fields[6]) << 16) | 
static_cast<uint64_t>(fields[7]);
+
+        return true;
+    }
+
+    static bool from_binary_string(vectorized::IPv6& x, std::string 
ipv6_binary_str) {
+        // Accepts a FixedString(16) value containing the IPv6 address in 
binary format
+        if (ipv6_binary_str.size() != 16) {
+            return false;
+        }
+
+        x.high = 0;
+        x.low = 0;
+
+        const uint8_t* ipv6_binary = reinterpret_cast<const 
uint8_t*>(ipv6_binary_str.c_str());
+
+        for (int i = 0; i < 8; ++i) {
+            x.high |= (static_cast<uint64_t>(ipv6_binary[i]) << (56 - i * 8));
+        }
+
+        for (int i = 8; i < 16; ++i) {
+            x.low |= (static_cast<uint64_t>(ipv6_binary[i]) << (56 - (i - 8) * 
8));
+        }
+
+        return true;
+    }
+
+    [[nodiscard]] std::string to_string() const { return to_string(_value); }
+
+    static std::string to_string(vectorized::IPv6 x) {
+        // "0000:0000:0000:0000:0000:0000:0000:0000"
+        if (x.high == 0 && x.low == 0) {
+            return "::";
+        }
+
+        uint16_t fields[8] = {static_cast<uint16_t>((x.high >> 48) & 0xFFFF),
+                              static_cast<uint16_t>((x.high >> 32) & 0xFFFF),
+                              static_cast<uint16_t>((x.high >> 16) & 0xFFFF),
+                              static_cast<uint16_t>(x.high & 0xFFFF),

Review Comment:
   warning: 0xFFFF is a magic number; consider replacing it with a named 
constant [readability-magic-numbers]
   ```cpp
                                 static_cast<uint16_t>(x.high & 0xFFFF),
                                                                ^
   ```
   



##########
be/src/vec/runtime/ipv6_value.h:
##########
@@ -0,0 +1,257 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+#include <stdint.h>
+
+#include <regex>
+#include <sstream>
+#include <string>
+
+#include "vec/core/types.h"
+#include "vec/data_types/data_type.h"
+#include "vec/data_types/data_type_number_base.h"
+
+namespace doris {
+
+class IPv6Value {
+public:
+    IPv6Value() {
+        _value.high = 0;
+        _value.low = 0;
+    }
+
+    explicit IPv6Value(vectorized::IPv6 ipv6) { _value = ipv6; }
+
+    [[nodiscard]] const vectorized::IPv6& value() const { return _value; }
+
+    vectorized::IPv6& value() { return _value; }
+
+    void set_value(vectorized::IPv6 ipv6) { _value = ipv6; }
+
+    bool from_string(std::string ipv6) { return from_string(_value, ipv6); }
+
+    bool from_binary_string(std::string ipv6_binary) {
+        return from_binary_string(_value, ipv6_binary);
+    }
+
+    static bool from_string(vectorized::IPv6& x, std::string ipv6) {
+        remove_ipv6_space(ipv6);
+
+        if (ipv6.empty() || !is_valid_string(ipv6)) {
+            return false;
+        }
+
+        std::transform(ipv6.begin(), ipv6.end(), ipv6.begin(),
+                       [](unsigned char ch) { return std::tolower(ch); });
+        std::istringstream iss(ipv6);
+        std::string field;
+        uint16_t fields[8] = {0};
+        uint8_t zero_index = 0;
+        uint8_t num_field = 0;
+        uint8_t right_field_num = 0;
+
+        while (num_field < 8) {
+            if (!getline(iss, field, ':')) {
+                break;
+            }
+
+            if (field.empty()) {
+                zero_index = num_field;
+                fields[num_field++] = 0;
+            } else {
+                try {
+                    if (field.size() > 4 || field > "ffff") {
+                        return false;
+                    }
+
+                    fields[num_field++] = std::stoi(field, nullptr, 16);
+                } catch (const std::exception& /*e*/) {
+                    return false;
+                }
+            }
+        }
+
+        if (zero_index != 0) {
+            right_field_num = num_field - zero_index - 1;
+
+            for (uint8_t i = 7; i > 7 - right_field_num; --i) {
+                fields[i] = fields[zero_index + right_field_num + i - 7];
+                fields[zero_index + right_field_num + i - 7] = 0;
+            }
+        }
+
+        x.high = (static_cast<uint64_t>(fields[0]) << 48) |
+                 (static_cast<uint64_t>(fields[1]) << 32) |
+                 (static_cast<uint64_t>(fields[2]) << 16) | 
static_cast<uint64_t>(fields[3]);
+        x.low = (static_cast<uint64_t>(fields[4]) << 48) |
+                (static_cast<uint64_t>(fields[5]) << 32) |
+                (static_cast<uint64_t>(fields[6]) << 16) | 
static_cast<uint64_t>(fields[7]);
+
+        return true;
+    }
+
+    static bool from_binary_string(vectorized::IPv6& x, std::string 
ipv6_binary_str) {
+        // Accepts a FixedString(16) value containing the IPv6 address in 
binary format
+        if (ipv6_binary_str.size() != 16) {
+            return false;
+        }
+
+        x.high = 0;
+        x.low = 0;
+
+        const uint8_t* ipv6_binary = reinterpret_cast<const 
uint8_t*>(ipv6_binary_str.c_str());
+
+        for (int i = 0; i < 8; ++i) {
+            x.high |= (static_cast<uint64_t>(ipv6_binary[i]) << (56 - i * 8));
+        }
+
+        for (int i = 8; i < 16; ++i) {
+            x.low |= (static_cast<uint64_t>(ipv6_binary[i]) << (56 - (i - 8) * 
8));
+        }
+
+        return true;
+    }
+
+    [[nodiscard]] std::string to_string() const { return to_string(_value); }
+
+    static std::string to_string(vectorized::IPv6 x) {
+        // "0000:0000:0000:0000:0000:0000:0000:0000"
+        if (x.high == 0 && x.low == 0) {
+            return "::";
+        }
+
+        uint16_t fields[8] = {static_cast<uint16_t>((x.high >> 48) & 0xFFFF),
+                              static_cast<uint16_t>((x.high >> 32) & 0xFFFF),
+                              static_cast<uint16_t>((x.high >> 16) & 0xFFFF),
+                              static_cast<uint16_t>(x.high & 0xFFFF),
+                              static_cast<uint16_t>((x.low >> 48) & 0xFFFF),
+                              static_cast<uint16_t>((x.low >> 32) & 0xFFFF),

Review Comment:
   warning: 0xFFFF is a magic number; consider replacing it with a named 
constant [readability-magic-numbers]
   ```cpp
                                 static_cast<uint16_t>((x.low >> 32) & 0xFFFF),
                                                                       ^
   ```
   



##########
be/src/vec/runtime/ipv6_value.h:
##########
@@ -0,0 +1,257 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+#include <stdint.h>
+
+#include <regex>
+#include <sstream>
+#include <string>
+
+#include "vec/core/types.h"
+#include "vec/data_types/data_type.h"
+#include "vec/data_types/data_type_number_base.h"
+
+namespace doris {
+
+class IPv6Value {
+public:
+    IPv6Value() {
+        _value.high = 0;
+        _value.low = 0;
+    }
+
+    explicit IPv6Value(vectorized::IPv6 ipv6) { _value = ipv6; }
+
+    [[nodiscard]] const vectorized::IPv6& value() const { return _value; }
+
+    vectorized::IPv6& value() { return _value; }
+
+    void set_value(vectorized::IPv6 ipv6) { _value = ipv6; }
+
+    bool from_string(std::string ipv6) { return from_string(_value, ipv6); }
+
+    bool from_binary_string(std::string ipv6_binary) {
+        return from_binary_string(_value, ipv6_binary);
+    }
+
+    static bool from_string(vectorized::IPv6& x, std::string ipv6) {
+        remove_ipv6_space(ipv6);
+
+        if (ipv6.empty() || !is_valid_string(ipv6)) {
+            return false;
+        }
+
+        std::transform(ipv6.begin(), ipv6.end(), ipv6.begin(),
+                       [](unsigned char ch) { return std::tolower(ch); });
+        std::istringstream iss(ipv6);
+        std::string field;
+        uint16_t fields[8] = {0};
+        uint8_t zero_index = 0;
+        uint8_t num_field = 0;
+        uint8_t right_field_num = 0;
+
+        while (num_field < 8) {
+            if (!getline(iss, field, ':')) {
+                break;
+            }
+
+            if (field.empty()) {
+                zero_index = num_field;
+                fields[num_field++] = 0;
+            } else {
+                try {
+                    if (field.size() > 4 || field > "ffff") {
+                        return false;
+                    }
+
+                    fields[num_field++] = std::stoi(field, nullptr, 16);
+                } catch (const std::exception& /*e*/) {
+                    return false;
+                }
+            }
+        }
+
+        if (zero_index != 0) {
+            right_field_num = num_field - zero_index - 1;
+
+            for (uint8_t i = 7; i > 7 - right_field_num; --i) {
+                fields[i] = fields[zero_index + right_field_num + i - 7];
+                fields[zero_index + right_field_num + i - 7] = 0;
+            }
+        }
+
+        x.high = (static_cast<uint64_t>(fields[0]) << 48) |
+                 (static_cast<uint64_t>(fields[1]) << 32) |
+                 (static_cast<uint64_t>(fields[2]) << 16) | 
static_cast<uint64_t>(fields[3]);
+        x.low = (static_cast<uint64_t>(fields[4]) << 48) |
+                (static_cast<uint64_t>(fields[5]) << 32) |
+                (static_cast<uint64_t>(fields[6]) << 16) | 
static_cast<uint64_t>(fields[7]);
+
+        return true;
+    }
+
+    static bool from_binary_string(vectorized::IPv6& x, std::string 
ipv6_binary_str) {
+        // Accepts a FixedString(16) value containing the IPv6 address in 
binary format
+        if (ipv6_binary_str.size() != 16) {
+            return false;
+        }
+
+        x.high = 0;
+        x.low = 0;
+
+        const uint8_t* ipv6_binary = reinterpret_cast<const 
uint8_t*>(ipv6_binary_str.c_str());
+
+        for (int i = 0; i < 8; ++i) {
+            x.high |= (static_cast<uint64_t>(ipv6_binary[i]) << (56 - i * 8));
+        }
+
+        for (int i = 8; i < 16; ++i) {
+            x.low |= (static_cast<uint64_t>(ipv6_binary[i]) << (56 - (i - 8) * 
8));
+        }
+
+        return true;
+    }
+
+    [[nodiscard]] std::string to_string() const { return to_string(_value); }
+
+    static std::string to_string(vectorized::IPv6 x) {
+        // "0000:0000:0000:0000:0000:0000:0000:0000"
+        if (x.high == 0 && x.low == 0) {
+            return "::";
+        }
+
+        uint16_t fields[8] = {static_cast<uint16_t>((x.high >> 48) & 0xFFFF),
+                              static_cast<uint16_t>((x.high >> 32) & 0xFFFF),
+                              static_cast<uint16_t>((x.high >> 16) & 0xFFFF),
+                              static_cast<uint16_t>(x.high & 0xFFFF),
+                              static_cast<uint16_t>((x.low >> 48) & 0xFFFF),
+                              static_cast<uint16_t>((x.low >> 32) & 0xFFFF),

Review Comment:
   warning: 32 is a magic number; consider replacing it with a named constant 
[readability-magic-numbers]
   ```cpp
                                 static_cast<uint16_t>((x.low >> 32) & 0xFFFF),
                                                                 ^
   ```
   



##########
be/src/vec/runtime/ipv6_value.h:
##########
@@ -0,0 +1,257 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+#include <stdint.h>
+
+#include <regex>
+#include <sstream>
+#include <string>
+
+#include "vec/core/types.h"
+#include "vec/data_types/data_type.h"
+#include "vec/data_types/data_type_number_base.h"
+
+namespace doris {
+
+class IPv6Value {
+public:
+    IPv6Value() {
+        _value.high = 0;
+        _value.low = 0;
+    }
+
+    explicit IPv6Value(vectorized::IPv6 ipv6) { _value = ipv6; }
+
+    [[nodiscard]] const vectorized::IPv6& value() const { return _value; }
+
+    vectorized::IPv6& value() { return _value; }
+
+    void set_value(vectorized::IPv6 ipv6) { _value = ipv6; }
+
+    bool from_string(std::string ipv6) { return from_string(_value, ipv6); }
+
+    bool from_binary_string(std::string ipv6_binary) {
+        return from_binary_string(_value, ipv6_binary);
+    }
+
+    static bool from_string(vectorized::IPv6& x, std::string ipv6) {
+        remove_ipv6_space(ipv6);
+
+        if (ipv6.empty() || !is_valid_string(ipv6)) {
+            return false;
+        }
+
+        std::transform(ipv6.begin(), ipv6.end(), ipv6.begin(),
+                       [](unsigned char ch) { return std::tolower(ch); });
+        std::istringstream iss(ipv6);
+        std::string field;
+        uint16_t fields[8] = {0};
+        uint8_t zero_index = 0;
+        uint8_t num_field = 0;
+        uint8_t right_field_num = 0;
+
+        while (num_field < 8) {
+            if (!getline(iss, field, ':')) {
+                break;
+            }
+
+            if (field.empty()) {
+                zero_index = num_field;
+                fields[num_field++] = 0;
+            } else {
+                try {
+                    if (field.size() > 4 || field > "ffff") {
+                        return false;
+                    }
+
+                    fields[num_field++] = std::stoi(field, nullptr, 16);
+                } catch (const std::exception& /*e*/) {
+                    return false;
+                }
+            }
+        }
+
+        if (zero_index != 0) {
+            right_field_num = num_field - zero_index - 1;
+
+            for (uint8_t i = 7; i > 7 - right_field_num; --i) {
+                fields[i] = fields[zero_index + right_field_num + i - 7];
+                fields[zero_index + right_field_num + i - 7] = 0;
+            }
+        }
+
+        x.high = (static_cast<uint64_t>(fields[0]) << 48) |
+                 (static_cast<uint64_t>(fields[1]) << 32) |
+                 (static_cast<uint64_t>(fields[2]) << 16) | 
static_cast<uint64_t>(fields[3]);
+        x.low = (static_cast<uint64_t>(fields[4]) << 48) |
+                (static_cast<uint64_t>(fields[5]) << 32) |
+                (static_cast<uint64_t>(fields[6]) << 16) | 
static_cast<uint64_t>(fields[7]);
+
+        return true;
+    }
+
+    static bool from_binary_string(vectorized::IPv6& x, std::string 
ipv6_binary_str) {
+        // Accepts a FixedString(16) value containing the IPv6 address in 
binary format
+        if (ipv6_binary_str.size() != 16) {
+            return false;
+        }
+
+        x.high = 0;
+        x.low = 0;
+
+        const uint8_t* ipv6_binary = reinterpret_cast<const 
uint8_t*>(ipv6_binary_str.c_str());
+
+        for (int i = 0; i < 8; ++i) {
+            x.high |= (static_cast<uint64_t>(ipv6_binary[i]) << (56 - i * 8));
+        }
+
+        for (int i = 8; i < 16; ++i) {
+            x.low |= (static_cast<uint64_t>(ipv6_binary[i]) << (56 - (i - 8) * 
8));
+        }
+
+        return true;
+    }
+
+    [[nodiscard]] std::string to_string() const { return to_string(_value); }
+
+    static std::string to_string(vectorized::IPv6 x) {
+        // "0000:0000:0000:0000:0000:0000:0000:0000"
+        if (x.high == 0 && x.low == 0) {
+            return "::";
+        }
+
+        uint16_t fields[8] = {static_cast<uint16_t>((x.high >> 48) & 0xFFFF),
+                              static_cast<uint16_t>((x.high >> 32) & 0xFFFF),
+                              static_cast<uint16_t>((x.high >> 16) & 0xFFFF),
+                              static_cast<uint16_t>(x.high & 0xFFFF),
+                              static_cast<uint16_t>((x.low >> 48) & 0xFFFF),

Review Comment:
   warning: 48 is a magic number; consider replacing it with a named constant 
[readability-magic-numbers]
   ```cpp
                                 static_cast<uint16_t>((x.low >> 48) & 0xFFFF),
                                                                 ^
   ```
   



##########
be/src/vec/runtime/ipv6_value.h:
##########
@@ -0,0 +1,257 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+#include <stdint.h>
+
+#include <regex>
+#include <sstream>
+#include <string>
+
+#include "vec/core/types.h"
+#include "vec/data_types/data_type.h"
+#include "vec/data_types/data_type_number_base.h"
+
+namespace doris {
+
+class IPv6Value {
+public:
+    IPv6Value() {
+        _value.high = 0;
+        _value.low = 0;
+    }
+
+    explicit IPv6Value(vectorized::IPv6 ipv6) { _value = ipv6; }
+
+    [[nodiscard]] const vectorized::IPv6& value() const { return _value; }
+
+    vectorized::IPv6& value() { return _value; }
+
+    void set_value(vectorized::IPv6 ipv6) { _value = ipv6; }
+
+    bool from_string(std::string ipv6) { return from_string(_value, ipv6); }
+
+    bool from_binary_string(std::string ipv6_binary) {
+        return from_binary_string(_value, ipv6_binary);
+    }
+
+    static bool from_string(vectorized::IPv6& x, std::string ipv6) {
+        remove_ipv6_space(ipv6);
+
+        if (ipv6.empty() || !is_valid_string(ipv6)) {
+            return false;
+        }
+
+        std::transform(ipv6.begin(), ipv6.end(), ipv6.begin(),
+                       [](unsigned char ch) { return std::tolower(ch); });
+        std::istringstream iss(ipv6);
+        std::string field;
+        uint16_t fields[8] = {0};
+        uint8_t zero_index = 0;
+        uint8_t num_field = 0;
+        uint8_t right_field_num = 0;
+
+        while (num_field < 8) {
+            if (!getline(iss, field, ':')) {
+                break;
+            }
+
+            if (field.empty()) {
+                zero_index = num_field;
+                fields[num_field++] = 0;
+            } else {
+                try {
+                    if (field.size() > 4 || field > "ffff") {
+                        return false;
+                    }
+
+                    fields[num_field++] = std::stoi(field, nullptr, 16);
+                } catch (const std::exception& /*e*/) {
+                    return false;
+                }
+            }
+        }
+
+        if (zero_index != 0) {
+            right_field_num = num_field - zero_index - 1;
+
+            for (uint8_t i = 7; i > 7 - right_field_num; --i) {
+                fields[i] = fields[zero_index + right_field_num + i - 7];
+                fields[zero_index + right_field_num + i - 7] = 0;
+            }
+        }
+
+        x.high = (static_cast<uint64_t>(fields[0]) << 48) |
+                 (static_cast<uint64_t>(fields[1]) << 32) |
+                 (static_cast<uint64_t>(fields[2]) << 16) | 
static_cast<uint64_t>(fields[3]);
+        x.low = (static_cast<uint64_t>(fields[4]) << 48) |
+                (static_cast<uint64_t>(fields[5]) << 32) |
+                (static_cast<uint64_t>(fields[6]) << 16) | 
static_cast<uint64_t>(fields[7]);
+
+        return true;
+    }
+
+    static bool from_binary_string(vectorized::IPv6& x, std::string 
ipv6_binary_str) {
+        // Accepts a FixedString(16) value containing the IPv6 address in 
binary format
+        if (ipv6_binary_str.size() != 16) {
+            return false;
+        }
+
+        x.high = 0;
+        x.low = 0;
+
+        const uint8_t* ipv6_binary = reinterpret_cast<const 
uint8_t*>(ipv6_binary_str.c_str());
+
+        for (int i = 0; i < 8; ++i) {
+            x.high |= (static_cast<uint64_t>(ipv6_binary[i]) << (56 - i * 8));
+        }
+
+        for (int i = 8; i < 16; ++i) {
+            x.low |= (static_cast<uint64_t>(ipv6_binary[i]) << (56 - (i - 8) * 
8));
+        }
+
+        return true;
+    }
+
+    [[nodiscard]] std::string to_string() const { return to_string(_value); }
+
+    static std::string to_string(vectorized::IPv6 x) {
+        // "0000:0000:0000:0000:0000:0000:0000:0000"
+        if (x.high == 0 && x.low == 0) {
+            return "::";
+        }
+
+        uint16_t fields[8] = {static_cast<uint16_t>((x.high >> 48) & 0xFFFF),
+                              static_cast<uint16_t>((x.high >> 32) & 0xFFFF),
+                              static_cast<uint16_t>((x.high >> 16) & 0xFFFF),
+                              static_cast<uint16_t>(x.high & 0xFFFF),
+                              static_cast<uint16_t>((x.low >> 48) & 0xFFFF),
+                              static_cast<uint16_t>((x.low >> 32) & 0xFFFF),
+                              static_cast<uint16_t>((x.low >> 16) & 0xFFFF),

Review Comment:
   warning: 16 is a magic number; consider replacing it with a named constant 
[readability-magic-numbers]
   ```cpp
                                 static_cast<uint16_t>((x.low >> 16) & 0xFFFF),
                                                                 ^
   ```
   



##########
be/src/vec/runtime/ipv6_value.h:
##########
@@ -0,0 +1,257 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+#include <stdint.h>
+
+#include <regex>
+#include <sstream>
+#include <string>
+
+#include "vec/core/types.h"
+#include "vec/data_types/data_type.h"
+#include "vec/data_types/data_type_number_base.h"
+
+namespace doris {
+
+class IPv6Value {
+public:
+    IPv6Value() {
+        _value.high = 0;
+        _value.low = 0;
+    }
+
+    explicit IPv6Value(vectorized::IPv6 ipv6) { _value = ipv6; }
+
+    [[nodiscard]] const vectorized::IPv6& value() const { return _value; }
+
+    vectorized::IPv6& value() { return _value; }
+
+    void set_value(vectorized::IPv6 ipv6) { _value = ipv6; }
+
+    bool from_string(std::string ipv6) { return from_string(_value, ipv6); }
+
+    bool from_binary_string(std::string ipv6_binary) {
+        return from_binary_string(_value, ipv6_binary);
+    }
+
+    static bool from_string(vectorized::IPv6& x, std::string ipv6) {
+        remove_ipv6_space(ipv6);
+
+        if (ipv6.empty() || !is_valid_string(ipv6)) {
+            return false;
+        }
+
+        std::transform(ipv6.begin(), ipv6.end(), ipv6.begin(),
+                       [](unsigned char ch) { return std::tolower(ch); });
+        std::istringstream iss(ipv6);
+        std::string field;
+        uint16_t fields[8] = {0};
+        uint8_t zero_index = 0;
+        uint8_t num_field = 0;
+        uint8_t right_field_num = 0;
+
+        while (num_field < 8) {
+            if (!getline(iss, field, ':')) {
+                break;
+            }
+
+            if (field.empty()) {
+                zero_index = num_field;
+                fields[num_field++] = 0;
+            } else {
+                try {
+                    if (field.size() > 4 || field > "ffff") {
+                        return false;
+                    }
+
+                    fields[num_field++] = std::stoi(field, nullptr, 16);
+                } catch (const std::exception& /*e*/) {
+                    return false;
+                }
+            }
+        }
+
+        if (zero_index != 0) {
+            right_field_num = num_field - zero_index - 1;
+
+            for (uint8_t i = 7; i > 7 - right_field_num; --i) {
+                fields[i] = fields[zero_index + right_field_num + i - 7];
+                fields[zero_index + right_field_num + i - 7] = 0;
+            }
+        }
+
+        x.high = (static_cast<uint64_t>(fields[0]) << 48) |
+                 (static_cast<uint64_t>(fields[1]) << 32) |
+                 (static_cast<uint64_t>(fields[2]) << 16) | 
static_cast<uint64_t>(fields[3]);
+        x.low = (static_cast<uint64_t>(fields[4]) << 48) |
+                (static_cast<uint64_t>(fields[5]) << 32) |
+                (static_cast<uint64_t>(fields[6]) << 16) | 
static_cast<uint64_t>(fields[7]);
+
+        return true;
+    }
+
+    static bool from_binary_string(vectorized::IPv6& x, std::string 
ipv6_binary_str) {
+        // Accepts a FixedString(16) value containing the IPv6 address in 
binary format
+        if (ipv6_binary_str.size() != 16) {
+            return false;
+        }
+
+        x.high = 0;
+        x.low = 0;
+
+        const uint8_t* ipv6_binary = reinterpret_cast<const 
uint8_t*>(ipv6_binary_str.c_str());
+
+        for (int i = 0; i < 8; ++i) {
+            x.high |= (static_cast<uint64_t>(ipv6_binary[i]) << (56 - i * 8));
+        }
+
+        for (int i = 8; i < 16; ++i) {
+            x.low |= (static_cast<uint64_t>(ipv6_binary[i]) << (56 - (i - 8) * 
8));
+        }
+
+        return true;
+    }
+
+    [[nodiscard]] std::string to_string() const { return to_string(_value); }
+
+    static std::string to_string(vectorized::IPv6 x) {
+        // "0000:0000:0000:0000:0000:0000:0000:0000"
+        if (x.high == 0 && x.low == 0) {
+            return "::";
+        }
+
+        uint16_t fields[8] = {static_cast<uint16_t>((x.high >> 48) & 0xFFFF),
+                              static_cast<uint16_t>((x.high >> 32) & 0xFFFF),
+                              static_cast<uint16_t>((x.high >> 16) & 0xFFFF),
+                              static_cast<uint16_t>(x.high & 0xFFFF),
+                              static_cast<uint16_t>((x.low >> 48) & 0xFFFF),

Review Comment:
   warning: 0xFFFF is a magic number; consider replacing it with a named 
constant [readability-magic-numbers]
   ```cpp
                                 static_cast<uint16_t>((x.low >> 48) & 0xFFFF),
                                                                       ^
   ```
   



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