nsivabalan commented on code in PR #12423:
URL: https://github.com/apache/hudi/pull/12423#discussion_r1870521673
##########
hudi-common/src/test/java/org/apache/hudi/common/table/read/TestHoodieFileGroupReaderBase.java:
##########
@@ -157,6 +168,65 @@ public void
testReadLogFilesOnlyInMergeOnReadTable(RecordMergeMode recordMergeMo
}
}
+ @ParameterizedTest
+ @EnumSource(value = ExternalSpillableMap.DiskMapType.class)
+ public void testSpillableMapUsage(ExternalSpillableMap.DiskMapType
diskMapType) throws Exception {
+ Map<String, String> writeConfigs = new
HashMap<>(getCommonConfigs(RecordMergeMode.COMMIT_TIME_ORDERING));
+ Option<Schema.Type> orderingFieldType = Option.of(Schema.Type.STRING);
+ try (HoodieTestDataGenerator dataGen = new
HoodieTestDataGenerator(0xDEEF)) {
+ commitToTable(dataGen.generateInserts("001", 100), INSERT.value(),
writeConfigs);
+ String baseMapPath = Files.createTempDirectory(null).toString();
+ HoodieTableMetaClient metaClient =
HoodieTestUtils.createMetaClient(getStorageConf(), getBasePath());
+ Schema avroSchema = new
TableSchemaResolver(metaClient).getTableAvroSchema();
+ FileSlice fileSlice = getFileSliceToRead(getStorageConf(),
getBasePath(), metaClient, dataGen.getPartitionPaths(), true, 0);
+ List<T> records = readRecordsFromFileGroup(getStorageConf(),
getBasePath(), metaClient, fileSlice,
+ avroSchema, RecordMergeMode.COMMIT_TIME_ORDERING, false);
+ HoodieReaderContext<T> readerContext =
getHoodieReaderContext(getBasePath(), avroSchema, getStorageConf());
+ Comparable castedOrderingField = readerContext.castValue(100,
Schema.Type.STRING);
+ for (Boolean isCompressionEnabled : new boolean[] {true, false}) {
+ try (ExternalSpillableMap<Serializable, Pair<Option<T>, Map<String,
Object>>> spillableMap =
+ new ExternalSpillableMap<>(16L, baseMapPath, new
DefaultSizeEstimator(),
+ new HoodieRecordSizeEstimator(avroSchema), diskMapType,
isCompressionEnabled)) {
+ Long position = 0L;
+ for (T record : records) {
+ String recordKey = readerContext.getRecordKey(record, avroSchema);
+ //test key based
+ spillableMap.put(recordKey,
+ Pair.of(
+ Option.ofNullable(readerContext.seal(record)),
+ readerContext.generateMetadataForRecord(record,
avroSchema)));
+
+ //test position based
+ spillableMap.put(position++,
+ Pair.of(
+ Option.ofNullable(readerContext.seal(record)),
+ readerContext.generateMetadataForRecord(recordKey,
+ dataGen.getPartitionPaths()[0], 100,
orderingFieldType)));
+ }
+
+ assertEquals(records.size() * 2, spillableMap.size());
Review Comment:
how did we validate the spilling actually happened?
--
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]