nsivabalan commented on code in PR #18174:
URL: https://github.com/apache/hudi/pull/18174#discussion_r2886017363
##########
hudi-client/hudi-spark-client/src/test/java/org/apache/hudi/client/clustering/plan/strategy/TestSparkSizeBasedClusteringPlanStrategy.java:
##########
@@ -82,10 +83,182 @@ public void testBuildClusteringGroup() {
Assertions.assertEquals(1,
clusteringGroups.get(1).getNumOutputFileGroups());
}
+ @Test
+ public void testSortByInstantTimeThenSize() {
+ HoodieWriteConfig config = HoodieWriteConfig.newBuilder()
+ .withPath("")
+ .withClusteringConfig(HoodieClusteringConfig.newBuilder()
+
.withClusteringPlanStrategyClass(SparkSizeBasedClusteringPlanStrategy.class.getName())
+ .withClusteringMaxBytesInGroup(3000)
+ .withClusteringTargetFileMaxBytes(1000)
+ .withClusteringPlanSmallFileLimit(50)
+ .withFileSlicesSortBy("INSTANT_TIME,SIZE")
+ .build())
+ .build();
+
+ SparkSizeBasedClusteringPlanStrategy planStrategy = new
SparkSizeBasedClusteringPlanStrategy(table, context, config);
+
+ ArrayList<FileSlice> fileSlices = new ArrayList<>();
+ fileSlices.add(createFileSliceWithCommitTime(400, "003"));
+ fileSlices.add(createFileSliceWithCommitTime(500, "001"));
+ fileSlices.add(createFileSliceWithCommitTime(200, "001"));
+ fileSlices.add(createFileSliceWithCommitTime(100, "002"));
+ fileSlices.add(createFileSliceWithCommitTime(300, "002"));
+
+ Stream<HoodieClusteringGroup> clusteringGroupStream =
+ (Stream<HoodieClusteringGroup>)
planStrategy.buildClusteringGroupsForPartition("p0", fileSlices).getLeft();
+ List<HoodieClusteringGroup> clusteringGroups =
clusteringGroupStream.collect(Collectors.toList());
+
+ Assertions.assertTrue(clusteringGroups.size() > 0);
+
+ List<HoodieSliceInfo> allSlices = new ArrayList<>();
+ for (HoodieClusteringGroup group : clusteringGroups) {
+ allSlices.addAll(group.getSlices());
+ }
+
+ Assertions.assertEquals(5, allSlices.size());
+
+ List<String> actualOrder = new ArrayList<>();
+ for (HoodieSliceInfo slice : allSlices) {
+ actualOrder.add(slice.getFileId());
+ }
+
+ Assertions.assertEquals(5, actualOrder.size());
Review Comment:
can we enhance the test to try out, max clustering groups to 1. and validate
that only file slices pertaining to commit "001" or the earliest is part of the
plan.
--
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]