morningman commented on a change in pull request #8240: URL: https://github.com/apache/incubator-doris/pull/8240#discussion_r816456289
########## File path: be/src/olap/types.cpp ########## @@ -97,30 +98,51 @@ bool is_scalar_type(FieldType field_type) { } } -TypeInfo* get_scalar_type_info(FieldType field_type) { +std::shared_ptr<const TypeInfo> get_scalar_type_info(FieldType field_type) { return ScalarTypeInfoResolver::instance()->get_type_info(field_type); } class ArrayTypeInfoResolver { DECLARE_SINGLETON(ArrayTypeInfoResolver); public: - TypeInfo* get_type_info(const FieldType t) { + std::shared_ptr<const TypeInfo> get_type_info(const FieldType t) { auto pair = _type_mapping.find(t); DCHECK(pair != _type_mapping.end()) << "Bad field type: list<" << t << ">"; - return pair->second.get(); + return pair->second; + } + + std::shared_ptr<const TypeInfo> get_type_info(const TabletColumn& column) { + DCHECK(column.get_subtype_count() == 1) << "more than 1 child type."; + const auto &sub_column = column.get_sub_column(0); + if (is_scalar_type(sub_column.type())) { + return get_type_info(sub_column.type()); + } else { + return std::shared_ptr<const TypeInfo>(new ArrayTypeInfo(get_type_info(sub_column))); Review comment: ```suggestion return std::make_shared<const ArrayTypeInfo>(get_type_info(sub_column)); ``` ########## File path: be/src/olap/types.cpp ########## @@ -97,30 +98,51 @@ bool is_scalar_type(FieldType field_type) { } } -TypeInfo* get_scalar_type_info(FieldType field_type) { +std::shared_ptr<const TypeInfo> get_scalar_type_info(FieldType field_type) { return ScalarTypeInfoResolver::instance()->get_type_info(field_type); } class ArrayTypeInfoResolver { DECLARE_SINGLETON(ArrayTypeInfoResolver); public: - TypeInfo* get_type_info(const FieldType t) { + std::shared_ptr<const TypeInfo> get_type_info(const FieldType t) { auto pair = _type_mapping.find(t); DCHECK(pair != _type_mapping.end()) << "Bad field type: list<" << t << ">"; - return pair->second.get(); + return pair->second; + } + + std::shared_ptr<const TypeInfo> get_type_info(const TabletColumn& column) { + DCHECK(column.get_subtype_count() == 1) << "more than 1 child type."; + const auto &sub_column = column.get_sub_column(0); + if (is_scalar_type(sub_column.type())) { + return get_type_info(sub_column.type()); + } else { + return std::shared_ptr<const TypeInfo>(new ArrayTypeInfo(get_type_info(sub_column))); + } + } + + std::shared_ptr<const TypeInfo> get_type_info(const segment_v2::ColumnMetaPB& column_meta_pb) { + DCHECK(column_meta_pb.children_columns_size() >= 1 && column_meta_pb.children_columns_size() <= 3) + << "more than 3 children or no children."; + const auto& child_type = column_meta_pb.children_columns(0); + if (is_scalar_type((FieldType)child_type.type())) { + return get_type_info((FieldType)child_type.type()); + } else { + return std::shared_ptr<const TypeInfo>(new ArrayTypeInfo(get_type_info(child_type))); Review comment: ```suggestion return std::make_shared<const ArrayTypeInfo>(get_type_info(child_type)); ``` -- 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