imay commented on a change in pull request #2501: Support more schema change 
from VARCHAR type
URL: https://github.com/apache/incubator-doris/pull/2501#discussion_r361185838
 
 

 ##########
 File path: be/src/olap/types.h
 ##########
 @@ -255,6 +255,32 @@ struct BaseFieldtypeTraits : public 
CppTypeTraits<field_type> {
     }
 };
 
+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);
+    StringParser::ParseResult parse_res;
+    T result = StringParser::string_to_int<T>(src_value.get_data(), 
src_value.get_size(), &parse_res);
+    if (UNLIKELY(parse_res != StringParser::PARSE_SUCCESS)) {
+        return OLAPStatus::OLAP_ERR_INVALID_SCHEMA;
+    }
+    *reinterpret_cast<T*>(dest) = result;
 
 Review comment:
   for largeint value, because dest may be not align of 16 bytes, this 
operation may cause process crash.
   So better to use memcpy for largeint

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

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

Reply via email to