github-actions[bot] commented on code in PR #69196: URL: https://github.com/apache/doris/pull/69196#discussion_r4376035240
########## be/test/format/file_reader/parquet_metadata_memory_test.cpp: ########## @@ -0,0 +1,129 @@ +// 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 "format/parquet_metadata_memory.h" + +#include <gen_cpp/parquet_types.h> +#include <gtest/gtest.h> + +#include "core/data_type/data_type_nullable.h" +#include "core/data_type/data_type_number.h" +#include "core/data_type/data_type_struct.h" +#include "format/parquet/schema_desc.h" +#include "format/parquet/vparquet_file_metadata.h" +#include "format_v2/parquet/native_schema_desc.h" +#include "format_v2/parquet/parquet_file_context.h" +#include "io/fs/file_meta_cache.h" +#include "runtime/exec_env.h" + +namespace doris { +TEST(ParquetMetadataMemoryTest, ReservedVectorsStringsAndStatistics) { + tparquet::FileMetaData metadata; + const auto base = parquet_metadata_dynamic_size(metadata); + metadata.row_groups.reserve(64); + EXPECT_GE(parquet_metadata_dynamic_size(metadata) - base, 64 * sizeof(tparquet::RowGroup)); + metadata.row_groups.resize(1); + auto& columns = metadata.row_groups[0].columns; + columns.resize(1); + auto& column = columns[0]; + const auto max_value_capacity_before = column.meta_data.statistics.max_value.capacity(); + auto before = parquet_metadata_dynamic_size(metadata); + column.meta_data.statistics.max_value.assign(8192, 'm'); + // The empty string's inline capacity is already part of the baseline estimate. + EXPECT_GE(parquet_metadata_dynamic_size(metadata) - before, 8192 - max_value_capacity_before); + before = parquet_metadata_dynamic_size(metadata); + column.meta_data.path_in_schema.emplace_back(4096, 'p'); + EXPECT_GE(parquet_metadata_dynamic_size(metadata) - before, 4096 + sizeof(std::string)); + before = parquet_metadata_dynamic_size(metadata); + column.meta_data.key_value_metadata.resize(1); + column.meta_data.key_value_metadata[0].value.assign(4096, 'v'); + column.meta_data.size_statistics.definition_level_histogram.reserve(100); + EXPECT_GE(parquet_metadata_dynamic_size(metadata) - before, + 4096 + sizeof(tparquet::KeyValue) + 100 * sizeof(int64_t)); + before = parquet_metadata_dynamic_size(metadata); + column.crypto_metadata.ENCRYPTION_WITH_COLUMN_KEY.key_metadata.assign(4096, 'k'); + column.encrypted_column_metadata.assign(4096, 'e'); + metadata.footer_signing_key_metadata.assign(4096, 's'); + EXPECT_GE(parquet_metadata_dynamic_size(metadata) - before, 3 * 4096); Review Comment: [P1] Subtract the initial capacities in the encryption-size assertion The `before` estimate already includes all three empty encryption strings: `parquet_string_memory_size()` always charges `capacity() + 1`, and the metadata traversal includes these fields even when their Thrift optional flags are unset. With libstdc++ each string grows from capacity 15 to 4096, so the measured increase is `3 * (4096 - 15) = 12243`, below the asserted `12288`. This makes `ParquetMetadataMemoryTest.ReservedVectorsStringsAndStatistics` fail even after the preceding `max_value` assertion was corrected. Capture and subtract these three initial capacities, or compare their actual before/after capacity differences, as for `max_value`. -- 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]
