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


##########
be/src/vec/runtime/ipv4_value.h:
##########
@@ -34,87 +33,41 @@ class IPv4Value {
 
     explicit IPv4Value(vectorized::IPv4 ipv4) { _value = ipv4; }
 
-    explicit IPv4Value(std::string ipv4) {}
-
-    [[nodiscard]] const vectorized::IPv4& value() const { return _value; }
+    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); }
+    bool from_string(const std::string& ipv4_str) { return from_string(_value, 
ipv4_str); }
 
-    static bool from_string(vectorized::IPv4& value, std::string ipv4) {
-        remove_ipv4_space(ipv4);
+    std::string to_string() const { return to_string(_value); }
 
-        // shortest ipv4 string is `0.0.0.0` whose length is 7
-        if (ipv4.size() < 7 || !is_valid_string(ipv4)) {
+    static bool from_string(vectorized::IPv4& value, const std::string& 
ipv4_str) {
+        if (ipv4_str.empty()) {
             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) {
+        int64_t parse_value;
+        const char* src = ipv4_str.c_str();
+        const char* end = ipv4_str.c_str() + ipv4_str.size() - 1;
+        while (std::isspace(*src)) ++src;

Review Comment:
   warning: statement should be inside braces 
[readability-braces-around-statements]
   
   ```suggestion
           while (std::isspace(*src)) { ++src;
   }
   ```
   



##########
be/src/vec/runtime/ipv4_value.h:
##########
@@ -34,87 +33,41 @@
 
     explicit IPv4Value(vectorized::IPv4 ipv4) { _value = ipv4; }
 
-    explicit IPv4Value(std::string ipv4) {}
-
-    [[nodiscard]] const vectorized::IPv4& value() const { return _value; }
+    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); }
+    bool from_string(const std::string& ipv4_str) { return from_string(_value, 
ipv4_str); }
 
-    static bool from_string(vectorized::IPv4& value, std::string ipv4) {
-        remove_ipv4_space(ipv4);
+    std::string to_string() const { return to_string(_value); }
 
-        // shortest ipv4 string is `0.0.0.0` whose length is 7
-        if (ipv4.size() < 7 || !is_valid_string(ipv4)) {
+    static bool from_string(vectorized::IPv4& value, const std::string& 
ipv4_str) {
+        if (ipv4_str.empty()) {
             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) {
+        int64_t parse_value;
+        const char* src = ipv4_str.c_str();
+        const char* end = ipv4_str.c_str() + ipv4_str.size() - 1;
+        while (std::isspace(*src)) ++src;
+        while (std::isspace(*end)) --end;

Review Comment:
   warning: statement should be inside braces 
[readability-braces-around-statements]
   
   ```suggestion
           while (std::isspace(*end)) { --end;
   }
   ```
   



##########
be/src/vec/exec/scan/vscanner.cpp:
##########
@@ -58,9 +60,30 @@ Status VScanner::prepare(RuntimeState* state, const 
VExprContextSPtrs& conjuncts
         }
     }
 
+    const auto& projections = _parent ? _parent->_projections : 
_local_state->_projections;
+    if (!projections.empty()) {
+        _projections.resize(projections.size());
+        for (size_t i = 0; i != projections.size(); ++i) {
+            RETURN_IF_ERROR(projections[i]->clone(state, _projections[i]));
+        }
+    }
+
     return Status::OK();
 }
 
+Status VScanner::get_block_after_projects(RuntimeState* state, 
vectorized::Block* block,
+                                          bool* eos) {
+    auto& row_descriptor =
+            _parent ? _parent->_row_descriptor : 
_local_state->_parent->row_descriptor();
+    if (_output_row_descriptor) {
+        
_origin_block.clear_column_data(row_descriptor.num_materialized_slots());
+        auto status = get_block(state, &_origin_block, eos);
+        if (UNLIKELY(!status.ok())) return status;

Review Comment:
   warning: statement should be inside braces 
[readability-braces-around-statements]
   
   ```suggestion
           if (UNLIKELY(!status.ok())) { return status;
   }
   ```
   



##########
be/src/vec/runtime/ipv6_value.h:
##########
@@ -35,224 +34,35 @@ class IPv6Value {
 
     explicit IPv6Value(vectorized::IPv6 ipv6) { _value = ipv6; }
 
-    [[nodiscard]] const vectorized::IPv6& value() const { return _value; }
+    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;
-            }
-        }
-
-        uint64_t 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]);
-        uint64_t 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]);
-
-        x = static_cast<vectorized::IPv6>(high) << 64 | low;
-        return true;
-    }
+    bool from_string(const std::string& ipv6_str) { return from_string(_value, 
ipv6_str); }
 
-    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) {
+    static bool from_string(vectorized::IPv6& value, const std::string& 
ipv6_str) {
+        if (ipv6_str.empty()) {
             return false;
         }
-
-        uint64_t high = 0;
-        uint64_t low = 0;
-
-        const uint8_t* ipv6_binary = reinterpret_cast<const 
uint8_t*>(ipv6_binary_str.c_str());
-
-        for (int i = 0; i < 8; ++i) {
-            high |= (static_cast<uint64_t>(ipv6_binary[i]) << (56 - i * 8));
-        }
-
-        for (int i = 8; i < 16; ++i) {
-            low |= (static_cast<uint64_t>(ipv6_binary[i]) << (56 - (i - 8) * 
8));
-        }
-
-        x = static_cast<vectorized::IPv6>(high) << 64 | low;
-        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 == 0) {
-            return "::";
-        }
-
-        uint64_t low = static_cast<uint64_t>(x);
-        uint64_t high = static_cast<uint64_t>(x >> 64);
-
-        uint16_t fields[8] = {static_cast<uint16_t>((high >> 48) & 0xFFFF),
-                              static_cast<uint16_t>((high >> 32) & 0xFFFF),
-                              static_cast<uint16_t>((high >> 16) & 0xFFFF),
-                              static_cast<uint16_t>(high & 0xFFFF),
-                              static_cast<uint16_t>((low >> 48) & 0xFFFF),
-                              static_cast<uint16_t>((low >> 32) & 0xFFFF),
-                              static_cast<uint16_t>((low >> 16) & 0xFFFF),
-                              static_cast<uint16_t>(low & 0xFFFF)};
-
-        uint8_t zero_start = 0, zero_end = 0;
-
-        while (zero_start < 8 && zero_end < 8) {
-            if (fields[zero_start] != 0) {
-                zero_start++;
-                zero_end = zero_start;
-                continue;
-            }
-
-            while (zero_end < 7 && fields[zero_end + 1] == 0) {
-                zero_end++;
-            }
-
-            if (zero_end > zero_start) {
-                break;
-            }
-
-            zero_start++;
-            zero_end = zero_start;
-        }
-
-        std::stringstream ss;
-
-        if (zero_start == zero_end) {
-            for (uint8_t i = 0; i < 7; ++i) {
-                ss << std::hex << fields[i] << ":";
-            }
-            ss << std::hex << fields[7];
-        } else {
-            for (uint8_t i = 0; i < zero_start; ++i) {
-                ss << std::hex << fields[i] << ":";
-            }
-
-            if (zero_end == 7) {
-                ss << ":";
-            } else {
-                for (uint8_t j = zero_end + 1; j < 8; ++j) {
-                    ss << std::hex << ":" << fields[j];
-                }
-            }
-        }
-
-        return ss.str();
-    }
-
-    [[nodiscard]] std::string to_binary_string() const { return 
to_binary_string(_value); }
-
-    static std::string to_binary_string(vectorized::IPv6 x) {
-        uint64_t low = static_cast<uint64_t>(x);
-        uint64_t high = static_cast<uint64_t>(x >> 64);
-
-        uint8_t fields[16] = {static_cast<uint8_t>((high >> 56) & 0xFF),
-                              static_cast<uint8_t>((high >> 48) & 0xFF),
-                              static_cast<uint8_t>((high >> 40) & 0xFF),
-                              static_cast<uint8_t>((high >> 32) & 0xFF),
-                              static_cast<uint8_t>((high >> 24) & 0xFF),
-                              static_cast<uint8_t>((high >> 16) & 0xFF),
-                              static_cast<uint8_t>((high >> 8) & 0xFF),
-                              static_cast<uint8_t>(high & 0xFF),
-                              static_cast<uint8_t>((low >> 56) & 0xFF),
-                              static_cast<uint8_t>((low >> 48) & 0xFF),
-                              static_cast<uint8_t>((low >> 40) & 0xFF),
-                              static_cast<uint8_t>((low >> 32) & 0xFF),
-                              static_cast<uint8_t>((low >> 24) & 0xFF),
-                              static_cast<uint8_t>((low >> 16) & 0xFF),
-                              static_cast<uint8_t>((low >> 8) & 0xFF),
-                              static_cast<uint8_t>(low & 0xFF)};
-
-        std::stringstream ss;
-
-        for (int i = 0; i < 16; ++i) {
-            ss << (char)fields[i];
-        }
-
-        return ss.str();
+        const char* src = ipv6_str.c_str();
+        const char* end = ipv6_str.c_str() + ipv6_str.size() - 1;
+        while (std::isspace(*src)) ++src;

Review Comment:
   warning: statement should be inside braces 
[readability-braces-around-statements]
   
   ```suggestion
           while (std::isspace(*src)) { ++src;
   }
   ```
   



##########
be/src/vec/runtime/ipv6_value.h:
##########
@@ -35,224 +34,35 @@
 
     explicit IPv6Value(vectorized::IPv6 ipv6) { _value = ipv6; }
 
-    [[nodiscard]] const vectorized::IPv6& value() const { return _value; }
+    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;
-            }
-        }
-
-        uint64_t 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]);
-        uint64_t 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]);
-
-        x = static_cast<vectorized::IPv6>(high) << 64 | low;
-        return true;
-    }
+    bool from_string(const std::string& ipv6_str) { return from_string(_value, 
ipv6_str); }
 
-    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) {
+    static bool from_string(vectorized::IPv6& value, const std::string& 
ipv6_str) {
+        if (ipv6_str.empty()) {
             return false;
         }
-
-        uint64_t high = 0;
-        uint64_t low = 0;
-
-        const uint8_t* ipv6_binary = reinterpret_cast<const 
uint8_t*>(ipv6_binary_str.c_str());
-
-        for (int i = 0; i < 8; ++i) {
-            high |= (static_cast<uint64_t>(ipv6_binary[i]) << (56 - i * 8));
-        }
-
-        for (int i = 8; i < 16; ++i) {
-            low |= (static_cast<uint64_t>(ipv6_binary[i]) << (56 - (i - 8) * 
8));
-        }
-
-        x = static_cast<vectorized::IPv6>(high) << 64 | low;
-        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 == 0) {
-            return "::";
-        }
-
-        uint64_t low = static_cast<uint64_t>(x);
-        uint64_t high = static_cast<uint64_t>(x >> 64);
-
-        uint16_t fields[8] = {static_cast<uint16_t>((high >> 48) & 0xFFFF),
-                              static_cast<uint16_t>((high >> 32) & 0xFFFF),
-                              static_cast<uint16_t>((high >> 16) & 0xFFFF),
-                              static_cast<uint16_t>(high & 0xFFFF),
-                              static_cast<uint16_t>((low >> 48) & 0xFFFF),
-                              static_cast<uint16_t>((low >> 32) & 0xFFFF),
-                              static_cast<uint16_t>((low >> 16) & 0xFFFF),
-                              static_cast<uint16_t>(low & 0xFFFF)};
-
-        uint8_t zero_start = 0, zero_end = 0;
-
-        while (zero_start < 8 && zero_end < 8) {
-            if (fields[zero_start] != 0) {
-                zero_start++;
-                zero_end = zero_start;
-                continue;
-            }
-
-            while (zero_end < 7 && fields[zero_end + 1] == 0) {
-                zero_end++;
-            }
-
-            if (zero_end > zero_start) {
-                break;
-            }
-
-            zero_start++;
-            zero_end = zero_start;
-        }
-
-        std::stringstream ss;
-
-        if (zero_start == zero_end) {
-            for (uint8_t i = 0; i < 7; ++i) {
-                ss << std::hex << fields[i] << ":";
-            }
-            ss << std::hex << fields[7];
-        } else {
-            for (uint8_t i = 0; i < zero_start; ++i) {
-                ss << std::hex << fields[i] << ":";
-            }
-
-            if (zero_end == 7) {
-                ss << ":";
-            } else {
-                for (uint8_t j = zero_end + 1; j < 8; ++j) {
-                    ss << std::hex << ":" << fields[j];
-                }
-            }
-        }
-
-        return ss.str();
-    }
-
-    [[nodiscard]] std::string to_binary_string() const { return 
to_binary_string(_value); }
-
-    static std::string to_binary_string(vectorized::IPv6 x) {
-        uint64_t low = static_cast<uint64_t>(x);
-        uint64_t high = static_cast<uint64_t>(x >> 64);
-
-        uint8_t fields[16] = {static_cast<uint8_t>((high >> 56) & 0xFF),
-                              static_cast<uint8_t>((high >> 48) & 0xFF),
-                              static_cast<uint8_t>((high >> 40) & 0xFF),
-                              static_cast<uint8_t>((high >> 32) & 0xFF),
-                              static_cast<uint8_t>((high >> 24) & 0xFF),
-                              static_cast<uint8_t>((high >> 16) & 0xFF),
-                              static_cast<uint8_t>((high >> 8) & 0xFF),
-                              static_cast<uint8_t>(high & 0xFF),
-                              static_cast<uint8_t>((low >> 56) & 0xFF),
-                              static_cast<uint8_t>((low >> 48) & 0xFF),
-                              static_cast<uint8_t>((low >> 40) & 0xFF),
-                              static_cast<uint8_t>((low >> 32) & 0xFF),
-                              static_cast<uint8_t>((low >> 24) & 0xFF),
-                              static_cast<uint8_t>((low >> 16) & 0xFF),
-                              static_cast<uint8_t>((low >> 8) & 0xFF),
-                              static_cast<uint8_t>(low & 0xFF)};
-
-        std::stringstream ss;
-
-        for (int i = 0; i < 16; ++i) {
-            ss << (char)fields[i];
-        }
-
-        return ss.str();
+        const char* src = ipv6_str.c_str();
+        const char* end = ipv6_str.c_str() + ipv6_str.size() - 1;
+        while (std::isspace(*src)) ++src;
+        while (std::isspace(*end)) --end;

Review Comment:
   warning: statement should be inside braces 
[readability-braces-around-statements]
   
   ```suggestion
           while (std::isspace(*end)) { --end;
   }
   ```
   



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