HappenLee commented on a change in pull request #4938:
URL: https://github.com/apache/incubator-doris/pull/4938#discussion_r529330908



##########
File path: be/src/olap/types.h
##########
@@ -495,12 +496,32 @@ struct BaseFieldtypeTraits : public 
CppTypeTraits<field_type> {
     }
 };
 
+static void prepare_char_before_convert(const void* src) {
+    Slice* slice = const_cast<Slice*>(reinterpret_cast<const Slice*>(src));
+    char* buf = slice->data;
+    auto p = slice->size - 1;
+    while (p >= 0 && buf[p] == '\0') {
+        p--;
+    }
+    slice->size = p + 1;
+}
+
 template <typename T>
-OLAPStatus convert_int_from_varchar(void* dest, const void* src) {
-    using SrcType = typename CppTypeTraits<OLAP_FIELD_TYPE_VARCHAR>::CppType;
-    auto src_value = reinterpret_cast<const SrcType*>(src);
+T convert_from_varchar(const Slice* src_value, StringParser::ParseResult& 
parse_res, std::true_type) {
+    return StringParser::string_to_int<T>(src_value->get_data(), 
src_value->get_size(), &parse_res);
+}
+
+template <typename T>

Review comment:
       Hi, chaoyli.
   
   ```if constexpr``` only support in c++17 and ```std::is_floating_point_v``` 
support in c++14.
   
   Now, Doris only support C++11, So I use label assignment to distinguish the 
float and int.




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

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to