BiteTheDDDDt commented on code in PR #12803: URL: https://github.com/apache/doris/pull/12803#discussion_r977146623
########## be/src/olap/rowset/segment_v2/column_reader.cpp: ########## @@ -171,6 +171,44 @@ Status ColumnReader::get_row_ranges_by_zone_map( return Status::OK(); } +Status ColumnReader::next_batch_of_zone_map(size_t* n, vectorized::MutableColumnPtr& dst) const { + // TODO: this work to get min/max value seems should only do once + FieldType type = _type_info->type(); + std::unique_ptr<WrapperField> min_value(WrapperField::create_by_type(type, _meta.length())); + std::unique_ptr<WrapperField> max_value(WrapperField::create_by_type(type, _meta.length())); + _parse_zone_map(_zone_map_index_meta->segment_zone_map(), min_value.get(), max_value.get()); + + dst->reserve(*n); + bool is_string = is_olap_string_type(type); + if (max_value->is_null()) { + assert_cast<vectorized::ColumnNullable&>(*dst).insert_default(); + } else { + if (is_string) { + auto sv = (StringValue*)max_value->cell_ptr(); + dst->insert_data(sv->ptr, sv->len); + } else { + dst->insert_many_fix_len_data(static_cast<const char*>(max_value->cell_ptr()), 1); + } + } + + auto size = *n - 1; + if (min_value->is_null()) { + assert_cast<vectorized::ColumnNullable&>(*dst).insert_null_elements(size); + } else { + if (is_string) { + auto sv = (StringValue*)min_value->cell_ptr(); + dst->insert_many_data(sv->ptr, sv->len, size); + } else { + // TODO: the work may cause performance problem, opt latter + for (int i = 0; i < size; ++i) { + dst->insert_many_fix_len_data(static_cast<const char*>(min_value->cell_ptr()), 1); + } Review Comment: Maybe we can use `insert_many_fix_len_data( ,size)` -- 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. To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org 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