Skip to content

Commit 6a4b837

Browse files
nsivabalanyihua
authored andcommitted
fixing build issues
1 parent 16a066d commit 6a4b837

File tree

2 files changed

+35
-34
lines changed

2 files changed

+35
-34
lines changed

hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/table/action/commit/AverageRecordSizeUtils.java

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -50,42 +50,42 @@ public class AverageRecordSizeUtils {
5050
static long averageBytesPerRecord(HoodieTimeline commitTimeline, HoodieWriteConfig hoodieWriteConfig) {
5151
long avgSize = hoodieWriteConfig.getCopyOnWriteRecordSizeEstimate();
5252
long fileSizeThreshold = (long) (hoodieWriteConfig.getRecordSizeEstimationThreshold() * hoodieWriteConfig.getParquetSmallFileLimit());
53-
if (!commitTimeline.empty()) {
54-
// Go over the reverse ordered commits to get a more recent estimate of average record size.
55-
Iterator<HoodieInstant> instants = commitTimeline.getReverseOrderedInstants().iterator();
56-
while (instants.hasNext()) {
57-
HoodieInstant instant = instants.next();
58-
try {
59-
HoodieCommitMetadata commitMetadata = HoodieCommitMetadata
60-
.fromBytes(commitTimeline.getInstantDetails(instant).get(), HoodieCommitMetadata.class);
61-
if (instant.getAction().equals(COMMIT_ACTION) || instant.getAction().equals(REPLACE_COMMIT_ACTION)) {
62-
long totalBytesWritten = commitMetadata.fetchTotalBytesWritten();
63-
long totalRecordsWritten = commitMetadata.fetchTotalRecordsWritten();
64-
if (totalBytesWritten > fileSizeThreshold && totalRecordsWritten > 0) {
65-
avgSize = (long) Math.ceil((1.0 * totalBytesWritten) / totalRecordsWritten);
66-
break;
67-
}
68-
} else if (instant.getAction().equals(DELTA_COMMIT_ACTION)) {
69-
// lets consider only base files in case of delta commits
70-
AtomicLong totalBytesWritten = new AtomicLong(0L);
71-
AtomicLong totalRecordsWritten = new AtomicLong(0L);
72-
commitMetadata.getWriteStats().stream()
73-
.filter(hoodieWriteStat -> FSUtils.isBaseFile(new Path(hoodieWriteStat.getPath())))
74-
.forEach(hoodieWriteStat -> {
75-
totalBytesWritten.addAndGet(hoodieWriteStat.getTotalWriteBytes());
76-
totalRecordsWritten.addAndGet(hoodieWriteStat.getNumWrites());
77-
});
78-
if (totalBytesWritten.get() > fileSizeThreshold && totalRecordsWritten.get() > 0) {
79-
avgSize = (long) Math.ceil((1.0 * totalBytesWritten.get()) / totalRecordsWritten.get());
80-
break;
81-
}
53+
if (!commitTimeline.empty()) {
54+
// Go over the reverse ordered commits to get a more recent estimate of average record size.
55+
Iterator<HoodieInstant> instants = commitTimeline.getReverseOrderedInstants().iterator();
56+
while (instants.hasNext()) {
57+
HoodieInstant instant = instants.next();
58+
try {
59+
HoodieCommitMetadata commitMetadata = HoodieCommitMetadata
60+
.fromBytes(commitTimeline.getInstantDetails(instant).get(), HoodieCommitMetadata.class);
61+
if (instant.getAction().equals(COMMIT_ACTION) || instant.getAction().equals(REPLACE_COMMIT_ACTION)) {
62+
long totalBytesWritten = commitMetadata.fetchTotalBytesWritten();
63+
long totalRecordsWritten = commitMetadata.fetchTotalRecordsWritten();
64+
if (totalBytesWritten > fileSizeThreshold && totalRecordsWritten > 0) {
65+
avgSize = (long) Math.ceil((1.0 * totalBytesWritten) / totalRecordsWritten);
66+
break;
67+
}
68+
} else if (instant.getAction().equals(DELTA_COMMIT_ACTION)) {
69+
// lets consider only base files in case of delta commits
70+
AtomicLong totalBytesWritten = new AtomicLong(0L);
71+
AtomicLong totalRecordsWritten = new AtomicLong(0L);
72+
commitMetadata.getWriteStats().stream()
73+
.filter(hoodieWriteStat -> FSUtils.isBaseFile(new Path(hoodieWriteStat.getPath())))
74+
.forEach(hoodieWriteStat -> {
75+
totalBytesWritten.addAndGet(hoodieWriteStat.getTotalWriteBytes());
76+
totalRecordsWritten.addAndGet(hoodieWriteStat.getNumWrites());
77+
});
78+
if (totalBytesWritten.get() > fileSizeThreshold && totalRecordsWritten.get() > 0) {
79+
avgSize = (long) Math.ceil((1.0 * totalBytesWritten.get()) / totalRecordsWritten.get());
80+
break;
8281
}
83-
} catch (IOException ioe) {
84-
// make this fail safe.
85-
LOG.error("Error trying to compute average bytes/record ", ioe);
8682
}
83+
} catch (IOException ioe) {
84+
// make this fail safe.
85+
LOG.error("Error trying to compute average bytes/record ", ioe);
8786
}
8887
}
88+
}
8989
return avgSize;
9090
}
9191
}

hudi-client/hudi-spark-client/src/test/java/org/apache/hudi/table/action/commit/TestAverageRecordSizeUtils.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import java.util.stream.Stream;
4343

4444
import static org.apache.hudi.common.model.HoodieFileFormat.HOODIE_LOG;
45+
import static org.apache.hudi.common.model.HoodieFileFormat.PARQUET;
4546
import static org.junit.jupiter.api.Assertions.assertEquals;
4647
import static org.mockito.Mockito.mock;
4748
import static org.mockito.Mockito.when;
@@ -91,12 +92,12 @@ public void testAverageRecordSize(List<Pair<HoodieInstant, List<HWriteStat>>> in
9192

9293
private static String getBaseFileName(String instantTime) {
9394
String fileName = UUID.randomUUID().toString();
94-
return FSUtils.makeBaseFileName(instantTime, TEST_WRITE_TOKEN, fileName);
95+
return FSUtils.makeBaseFileName(instantTime, TEST_WRITE_TOKEN, fileName, PARQUET.getFileExtension());
9596
}
9697

9798
private static String getLogFileName(String instantTime) {
9899
String fileName = UUID.randomUUID().toString();
99-
String fullFileName = FSUtils.makeBaseFileName(instantTime, TEST_WRITE_TOKEN, fileName);
100+
String fullFileName = FSUtils.makeBaseFileName(instantTime, TEST_WRITE_TOKEN, fileName, PARQUET.getFileExtension());
100101
assertEquals(instantTime, FSUtils.getCommitTime(fullFileName));
101102
return FSUtils.makeLogFileName(fileName, HOODIE_LOG.getFileExtension(), instantTime, 1, TEST_WRITE_TOKEN);
102103
}

0 commit comments

Comments
 (0)