wangbo commented on a change in pull request #1816: v2 segment support string 
encode(#1766)
URL: https://github.com/apache/incubator-doris/pull/1816#discussion_r328041089
 
 

 ##########
 File path: be/test/olap/rowset/segment_v2/segment_test.cpp
 ##########
 @@ -606,6 +606,173 @@ TEST_F(SegmentReaderWriterTest, TestDefaultValueColumn) {
     }
 }
 
+void set_column_value_by_type(FieldType fieldType, int src, char* target, 
size_t _length = 0) {
+    if (fieldType == OLAP_FIELD_TYPE_CHAR) {
+        char* src_value = &std::to_string(src)[0];
+        int src_len = strlen(src_value);
+
+        auto* dest_slice = (Slice*)target;
+        dest_slice->size = _length;
+        dest_slice->data = new char[dest_slice->size];
+        memcpy(dest_slice->data, src_value, src_len);
+        memset(dest_slice->data + src_len, 0, dest_slice->size - src_len);
+    } else if (fieldType == OLAP_FIELD_TYPE_VARCHAR) {
+        Slice* slice = new Slice(*new string(&std::to_string(src)[0]));
 
 Review comment:
   In a for loop,if aollocate string on stack,and using memcpy to copy data to 
a char array,then all the elements in char array will be same and the value is 
the last value;

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