cshuo commented on code in PR #12967: URL: https://github.com/apache/hudi/pull/12967#discussion_r2006706843
########## hudi-client/hudi-flink-client/src/main/java/org/apache/hudi/io/log/block/HoodieFlinkParquetDataBlock.java: ########## @@ -0,0 +1,105 @@ +/* + * 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. + */ + +package org.apache.hudi.io.log.block; + +import org.apache.hudi.avro.AvroSchemaCache; +import org.apache.hudi.common.model.HoodieColumnRangeMetadata; +import org.apache.hudi.common.model.HoodieRecord; +import org.apache.hudi.common.table.log.block.HoodieLogBlock; +import org.apache.hudi.common.table.log.block.HoodieParquetDataBlock; +import org.apache.hudi.common.util.Option; +import org.apache.hudi.common.util.ParquetUtils; +import org.apache.hudi.common.util.ValidationUtils; +import org.apache.hudi.common.util.collection.Pair; +import org.apache.hudi.io.storage.ColumnRangeMetadataProvider; +import org.apache.hudi.io.storage.HoodieIOFactory; +import org.apache.hudi.storage.HoodieStorage; + +import org.apache.avro.Schema; +import org.apache.parquet.hadoop.metadata.ParquetMetadata; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +import static org.apache.hudi.common.config.HoodieStorageConfig.PARQUET_COMPRESSION_CODEC_NAME; +import static org.apache.hudi.common.config.HoodieStorageConfig.PARQUET_COMPRESSION_RATIO_FRACTION; +import static org.apache.hudi.common.config.HoodieStorageConfig.PARQUET_DICTIONARY_ENABLED; +import static org.apache.hudi.common.model.HoodieFileFormat.PARQUET; + +/** + * HoodieFlinkParquetDataBlock employs an HoodieRecord iterator rather than a HoodieRecord list for + * parquet data block, aiming to better utilize the optimizations of {@code BinaryInMemorySortBuffer}, + * for example, object reusing to decrease GC costs. + */ +public class HoodieFlinkParquetDataBlock extends HoodieParquetDataBlock implements ColumnRangeMetadataProvider { + + private final Iterator<HoodieRecord> recordIterator; + /** + * Parquet metadata collected during serializing the records, used to build column range metadata. + */ + protected ParquetMetadata parquetMetadata; Review Comment: fix ########## hudi-common/src/main/java/org/apache/hudi/common/model/HoodieColumnRangeMetadata.java: ########## @@ -124,6 +124,10 @@ public int hashCode() { return Objects.hash(getColumnName(), getMinValue(), getMaxValue(), getNullCount()); } + public HoodieColumnRangeMetadata<T> copy(String filePath) { Review Comment: remove ########## hudi-flink-datasource/hudi-flink/src/test/java/org/apache/hudi/table/ITTestHoodieDataSource.java: ########## @@ -2362,6 +2362,48 @@ void testReadWithParquetPredicatePushDown() { + "+I[id8, Han, 56, 1970-01-01T00:00:08, par4]]"); } + @ParameterizedTest + @MethodSource("indexAndPartitioningParams") + void testWriteMultipleCommitWithLegacyAndRowDataWrite(String indexType, boolean hiveStylePartitioning) throws Exception { + // create filesystem table named source + String createSource = TestConfigurations.getFileSourceDDL("source"); + streamTableEnv.executeSql(createSource); + + // insert first batch of data with rowdata mode writing disabled + String hoodieTableDDL = sql("t1") + .option(FlinkOptions.PATH, tempFile.getAbsolutePath()) + .option(FlinkOptions.TABLE_TYPE, HoodieTableType.MERGE_ON_READ) + .option(FlinkOptions.INDEX_TYPE, indexType) + .option(FlinkOptions.HIVE_STYLE_PARTITIONING, hiveStylePartitioning) + .option(FlinkOptions.INSERT_ROWDATA_MODE_ENABLED, false) + .option(HoodieWriteConfig.ALLOW_EMPTY_COMMIT.key(), false) + .end(); + streamTableEnv.executeSql(hoodieTableDDL); + String insertInto = "insert into t1 select * from source"; + execInsertSql(streamTableEnv, insertInto); + + streamTableEnv.executeSql("drop table t1"); + + // insert second batch of data with rowdata mode writing enabled + hoodieTableDDL = sql("t1") + .option(FlinkOptions.PATH, tempFile.getAbsolutePath()) + .option(FlinkOptions.TABLE_TYPE, HoodieTableType.MERGE_ON_READ) + .option(FlinkOptions.INDEX_TYPE, indexType) + .option(FlinkOptions.READ_AS_STREAMING, true) + .option(FlinkOptions.READ_START_COMMIT, FlinkOptions.START_COMMIT_EARLIEST) + .option(FlinkOptions.HIVE_STYLE_PARTITIONING, hiveStylePartitioning) + .option(FlinkOptions.INSERT_ROWDATA_MODE_ENABLED, true) Review Comment: test 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
