boneanxs commented on code in PR #7978:
URL: https://github.com/apache/hudi/pull/7978#discussion_r1121015235
##########
hudi-client/hudi-spark-client/src/test/java/org/apache/hudi/io/storage/row/TestHoodieInternalRowParquetWriter.java:
##########
@@ -123,6 +125,45 @@ public void testProperWriting(boolean
parquetWriteLegacyFormatEnabled) throws Ex
});
}
+ @Test
+ @Timeout(value = 60)
+ public void testFileSizeCheck() throws Exception {
+ HoodieWriteConfig.Builder writeConfigBuilder =
+ SparkDatasetTestUtils.getConfigBuilder(basePath, timelineServicePort);
+
+ HoodieRowParquetWriteSupport writeSupport =
getWriteSupport(writeConfigBuilder, hadoopConf, true);
+ HoodieWriteConfig cfg = writeConfigBuilder.build();
+
+ // Make the written records could exceed maxRowCountForSizeCheck
+ cfg.setValue(HoodieStorageConfig.PARQUET_MAX_FILE_SIZE, String.valueOf(5 *
1024 * 1024));
+ HoodieParquetConfig<HoodieRowParquetWriteSupport> parquetConfig = new
HoodieParquetConfig<>(writeSupport,
+ CompressionCodecName.SNAPPY, cfg.getParquetBlockSize(),
cfg.getParquetPageSize(), cfg.getParquetMaxFileSize(),
+ writeSupport.getHadoopConf(), cfg.getParquetCompressionRatio(),
cfg.parquetDictionaryEnabled());
+
+ Path filePath = new Path(basePath + "/check_file_size.parquet");
+
+ try (HoodieInternalRowParquetWriter writer = new
HoodieInternalRowParquetWriter(filePath, parquetConfig)) {
+
+ while (writer.canWrite()) {
+ Dataset<Row> inputRows =
SparkDatasetTestUtils.getRandomRows(sqlContext, 100,
Review Comment:
If we make the max file size too small, we cannot ensure the written records
reach `maxRowCountForSizeCheck`, whereas we cannot test the logic of
`DEFAULT_MAXIMUM_RECORD_COUNT_FOR_CHECK`, so here we need to make the
maxFileSize larger.
```java
Math.min(
// Do check it in the halfway
Math.max(DEFAULT_MINIMUM_RECORD_COUNT_FOR_CHECK, (maxFileSize /
avgRecordSize - writtenCount) / 2),
DEFAULT_MAXIMUM_RECORD_COUNT_FOR_CHECK)
```
I test it several times, the test usually finished in 8 - 12 sec, maybe it
doesn't hurt too much for the performance?
--
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]