github-actions[bot] commented on code in PR #68853: URL: https://github.com/apache/doris/pull/68853#discussion_r4358061072
########## be/src/exprs/function/function_fl_get_binary.cpp: ########## @@ -0,0 +1,67 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#include "core/column/column_file.h" +#include "core/data_type/data_type_file.h" +#include "core/data_type/data_type_varbinary.h" +#include "exprs/function/function.h" +#include "exprs/function/simple_function_factory.h" + +namespace doris { + +class FunctionFlGetBinary : public IFunction { +public: + static constexpr auto name = "fl_get_binary"; + static FunctionPtr create() { return std::make_shared<FunctionFlGetBinary>(); } + String get_name() const override { return name; } + size_t get_number_of_arguments() const override { return 1; } + bool use_default_implementation_for_constants() const override { return true; } + + DataTypePtr get_return_type_impl(const DataTypes&) const override { + return make_nullable(std::make_shared<DataTypeVarbinary>()); + } + + Status execute_impl(FunctionContext*, Block& block, const ColumnNumbers& arguments, + uint32_t result, size_t input_rows_count) const override { + const auto& file = + assert_cast<const ColumnFile&>(*block.get_by_position(arguments[0]).column); + const auto& inline_column = file.get_column_ptr(DataTypeFile::INLINE_FIELD_INDEX); + if (!inline_column->has_null()) { + block.replace_by_position(result, inline_column); + return Status::OK(); + } + + auto result_column = inline_column->clone_empty(); + result_column->reserve(input_rows_count); + for (size_t row = 0; row < input_rows_count; ++row) { + if (!inline_column->is_null_at(row)) { + result_column->insert_from(*inline_column, row); Review Comment: [P2] Share inline bytes when a FILE row has no inline value With a nonconstant block containing 1023 FILEs with 64 KiB inline payloads and one URI-only FILE, the missing value selects this loop and every populated payload is copied into a new `ColumnVarbinary` arena. That adds about 64 MiB of allocation and copying for each getter projection, although the result is already exactly `inline_column`: missing inline still produces NULL and no remote read is implemented. Return the existing child (as the all-populated branch does); the default nullable wrapper can merge the parent null map while sharing its binary storage. Cover the mixed case with an ownership check. This is static copy-volume arithmetic, not a benchmark. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
