github-actions[bot] commented on code in PR #33890: URL: https://github.com/apache/doris/pull/33890#discussion_r1572029446
########## be/src/vec/columns/column_object.cpp: ########## @@ -148,6 +151,84 @@ class FieldVisitorToNumberOfDimensions : public StaticVisitor<size_t> { } }; +// Visitor that allows to get type of scalar field +// but include contain complex field.This is a faster version +// for FieldVisitorToScalarType which does not support complex field. +class SimpleFieldVisitorToScarlarType : public StaticVisitor<size_t> { +public: + size_t operator()(const Array& x) { + throw doris::Exception(ErrorCode::INVALID_ARGUMENT, "Array type is not supported"); + } + size_t operator()(const UInt64& x) { + if (x <= std::numeric_limits<Int8>::max()) { + type = TypeIndex::Int8; + } else if (x <= std::numeric_limits<Int16>::max()) { + type = TypeIndex::Int16; + } else if (x <= std::numeric_limits<Int32>::max()) { + type = TypeIndex::Int32; + } else { + type = TypeIndex::Int64; + } + return 1; + } + size_t operator()(const Int64& x) { + if (x <= std::numeric_limits<Int8>::max() && x >= std::numeric_limits<Int8>::min()) { + type = TypeIndex::Int8; + } else if (x <= std::numeric_limits<Int16>::max() && + x >= std::numeric_limits<Int16>::min()) { + type = TypeIndex::Int16; + } else if (x <= std::numeric_limits<Int32>::max() && + x >= std::numeric_limits<Int32>::min()) { + type = TypeIndex::Int32; + } else { + type = TypeIndex::Int64; + } + return 1; + } + size_t operator()(const JsonbField& x) { + type = TypeIndex::JSONB; + return 1; + } + size_t operator()(const Null&) { + have_nulls = true; + return 1; + } + template <typename T> + size_t operator()(const T&) { + type = TypeId<NearestFieldType<T>>::value; + return 1; + } + void get_scalar_type(DataTypePtr* data_type) const { + WhichDataType which(type); +#define DISPATCH(TYPE) \ + if (which.idx == TypeIndex::TYPE) { \ + *data_type = std::make_shared<DataTypeNumber<TYPE>>(); \ + return; \ + } + FOR_NUMERIC_TYPES(DISPATCH) +#undef DISPATCH + if (which.is_string()) { + *data_type = std::make_shared<DataTypeString>(); + return; + } + if (which.is_json()) { + *data_type = std::make_shared<DataTypeJsonb>(); + return; + } + if (which.is_nothing()) { + *data_type = std::make_shared<DataTypeNothing>(); + return; + } + } + bool contain_nulls() const { return have_nulls; } + + bool need_convert_field() const { return false; } Review Comment: warning: method 'need_convert_field' can be made static [readability-convert-member-functions-to-static] ```suggestion static bool need_convert_field() { return 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. 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