imay commented on a change in pull request #2013: Add arrow IPC serialization 
for Doris-Spark-Connector
URL: https://github.com/apache/incubator-doris/pull/2013#discussion_r339509134
 
 

 ##########
 File path: be/src/util/arrow/row_batch.cpp
 ##########
 @@ -172,6 +201,98 @@ class FromRowBatchConverter : public arrow::TypeVisitor {
 
 #undef PRIMITIVE_VISIT
 
+    // process string-transformable field
+    arrow::Status Visit(const arrow::StringType& type) override {
+        arrow::StringBuilder builder(_pool);
+        size_t num_rows = _batch.num_rows();
+        builder.Reserve(num_rows);
+        for (size_t i = 0; i < num_rows; ++i) {
+            auto cell_ptr = _cur_slot_ref->get_slot(_batch.get_row(i));
+            PrimitiveType primitive_type = _cur_slot_ref->type().type;
+            switch (primitive_type) {
+                case TYPE_VARCHAR:
+                case TYPE_CHAR:
+                case TYPE_HLL: {
+                    const StringValue* string_val = (const 
StringValue*)(cell_ptr);
+                    if (string_val->ptr == NULL) {
+                        if (string_val->len == 0) {
+                            // 0x01 is a magic num, not usefull actually, just 
for present ""
+                            //char* tmp_val = reinterpret_cast<char*>(0x01);
+                            ARROW_RETURN_NOT_OK(builder.Append(""));        
+                        } else {
+                            ARROW_RETURN_NOT_OK(builder.AppendNull());
+                        }
+                    } else {
+                        
ARROW_RETURN_NOT_OK(builder.Append(std::move(string_val->to_string())));
+                    }   
+                    break;
+                }
+                case TYPE_LARGEINT: {
+                    char buf[48];
+                    int len = 48;
+                    char* v = LargeIntValue::to_string(reinterpret_cast<const 
PackedInt128*>(cell_ptr)->value, buf, &len);
+                    std::string temp(v, len);
+                    ARROW_RETURN_NOT_OK(builder.Append(std::move(temp)));
+                    break;
+                }
+                case TYPE_DECIMAL: {
+                    const DecimalValue* decimal_val = reinterpret_cast<const 
DecimalValue*>(cell_ptr);
 
 Review comment:
   You should check if decimal_val is null

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


With regards,
Apache Git Services

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

Reply via email to