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_r339508968
 
 

 ##########
 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())));
 
 Review comment:
   ```suggestion
                           
ARROW_RETURN_NOT_OK(builder.Append(string_val->to_string()));
   ```
   There is no need to add std::move here, because string_val->to_string() is 
already a r-value reference.

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