imay commented on a change in pull request #3739:
URL: https://github.com/apache/incubator-doris/pull/3739#discussion_r435767964



##########
File path: be/src/olap/schema_change.cpp
##########
@@ -266,6 +260,92 @@ bool RowBlockChanger::change_row_block(
         int32_t ref_column = _schema_mapping[i].ref_column;
 
         if (_schema_mapping[i].ref_column >= 0) {
+            if (!_schema_mapping[i].materialized_function.empty()) {
+                VLOG(3) << "_schema_mapping[" << i << "].materialized_function 
: " << _schema_mapping[i].materialized_function;
+                // 效率低下,也可以直接计算变长域拷贝,但仍然会破坏封装

Review comment:
       English first

##########
File path: be/src/olap/schema_change.cpp
##########
@@ -266,6 +260,92 @@ bool RowBlockChanger::change_row_block(
         int32_t ref_column = _schema_mapping[i].ref_column;
 
         if (_schema_mapping[i].ref_column >= 0) {
+            if (!_schema_mapping[i].materialized_function.empty()) {
+                VLOG(3) << "_schema_mapping[" << i << "].materialized_function 
: " << _schema_mapping[i].materialized_function;
+                // 效率低下,也可以直接计算变长域拷贝,但仍然会破坏封装
+                for (size_t row_index = 0, new_row_index = 0;
+                     row_index < ref_block->row_block_info().row_num; 
++row_index) {
+                    // 不需要的row,每次处理到这个row时就跳过
+                    if (need_filter_data && is_data_left_vec[row_index] == 0) {
+                        continue;
+                    }
+
+                    // 指定新的要写入的row index(不同于读的row_index)
+                    mutable_block->get_row(new_row_index++, &write_helper);
+                    ref_block->get_row(row_index, &read_helper);
+
+                    if (_schema_mapping[i].materialized_function == 
"to_bitmap") {

Review comment:
       better do this if and switch out of for loop

##########
File path: be/src/olap/schema_change.cpp
##########
@@ -266,6 +260,92 @@ bool RowBlockChanger::change_row_block(
         int32_t ref_column = _schema_mapping[i].ref_column;
 
         if (_schema_mapping[i].ref_column >= 0) {
+            if (!_schema_mapping[i].materialized_function.empty()) {
+                VLOG(3) << "_schema_mapping[" << i << "].materialized_function 
: " << _schema_mapping[i].materialized_function;
+                // 效率低下,也可以直接计算变长域拷贝,但仍然会破坏封装
+                for (size_t row_index = 0, new_row_index = 0;
+                     row_index < ref_block->row_block_info().row_num; 
++row_index) {
+                    // 不需要的row,每次处理到这个row时就跳过
+                    if (need_filter_data && is_data_left_vec[row_index] == 0) {
+                        continue;
+                    }
+
+                    // 指定新的要写入的row index(不同于读的row_index)
+                    mutable_block->get_row(new_row_index++, &write_helper);
+                    ref_block->get_row(row_index, &read_helper);
+
+                    if (_schema_mapping[i].materialized_function == 
"to_bitmap") {
+                        write_helper.set_not_null(i);
+                        BitmapValue bitmap;
+                        if (!read_helper.is_null(ref_column)) {
+                            uint64_t origin_value;
+                            char *src = read_helper.cell_ptr(ref_column);
+                            switch 
(ref_block->tablet_schema().column(ref_column).type()) {
+                                case OLAP_FIELD_TYPE_TINYINT:
+                                    origin_value = *(int8_t *) src;
+                                    break;
+                                case OLAP_FIELD_TYPE_UNSIGNED_TINYINT:
+                                    origin_value = *(uint8_t *) src;
+                                    break;
+                                case OLAP_FIELD_TYPE_SMALLINT:
+                                    origin_value = *(int16_t *) src;
+                                    break;
+                                case OLAP_FIELD_TYPE_UNSIGNED_SMALLINT:
+                                    origin_value = *(uint16_t *) src;
+                                    break;
+                                case OLAP_FIELD_TYPE_INT:
+                                    origin_value = *(int32_t *) src;
+                                    break;
+                                case OLAP_FIELD_TYPE_UNSIGNED_INT:
+                                    origin_value = *(uint32_t *) src;
+                                    break;
+                                case OLAP_FIELD_TYPE_BIGINT:
+                                    origin_value = *(int64_t *) src;
+                                    break;
+                                case OLAP_FIELD_TYPE_UNSIGNED_BIGINT:
+                                    origin_value = *(uint64_t *) src;
+                                    break;
+                                default:
+                                    LOG(WARNING) << "the column type which was 
altered from was unsupported."
+                                                 << " from_type="
+                                                 << 
ref_block->tablet_schema().column(ref_column).type();
+                                    return false;
+                            }
+                            if (origin_value < 0) {

Review comment:
       origin_value is unsigned, this will always be false




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



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

Reply via email to