Skip to content
Closed
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.apache.hudi.common.model.HoodieWriteStat;
import org.apache.hudi.common.table.timeline.HoodieInstant;
import org.apache.hudi.common.table.timeline.HoodieTimeline;
import org.apache.hudi.common.util.CollectionUtils;
import org.apache.hudi.common.util.NumericUtils;
import org.apache.hudi.common.util.Option;
import org.apache.hudi.common.util.collection.Pair;
Expand All @@ -55,7 +54,7 @@

import scala.Tuple2;

import static org.apache.hudi.common.table.timeline.HoodieTimeline.COMMIT_ACTION;
import static org.apache.hudi.common.table.timeline.HoodieTimeline.REPLACE_COMMIT_ACTION;

/**
* Packs incoming records to be upserted, into buckets (1 bucket = 1 RDD partition).
Expand Down Expand Up @@ -164,13 +163,9 @@ private List<SmallFile> filterSmallFilesInClustering(final Set<String> pendingCl
private void assignInserts(WorkloadProfile profile, HoodieEngineContext context) {
// for new inserts, compute buckets depending on how many records we have for each partition
Set<String> partitionPaths = profile.getPartitionPaths();
/*
* NOTE: we only use commit instants to calculate average record size because replacecommit can be
* created by clustering, which has smaller average record size, which affects assigning inserts and
* may result in OOM by making spark underestimate the actual input record sizes.
*/
long averageRecordSize = averageBytesPerRecord(table.getMetaClient().getActiveTimeline()
.getTimelineOfActions(CollectionUtils.createSet(COMMIT_ACTION)).filterCompletedInstants(), config);
long averageRecordSize =
averageBytesPerRecord(table.getMetaClient().getActiveTimeline().getCommitTimeline().filterCompletedInstants(),
config);
LOG.info("AvgRecordSize => " + averageRecordSize);

Map<String, List<SmallFile>> partitionSmallFilesMap =
Expand Down Expand Up @@ -379,6 +374,9 @@ protected static long averageBytesPerRecord(HoodieTimeline commitTimeline, Hoodi
Iterator<HoodieInstant> instants = commitTimeline.getReverseOrderedInstants().iterator();
while (instants.hasNext()) {
HoodieInstant instant = instants.next();
if (instant.getAction().equals(REPLACE_COMMIT_ACTION)) {
continue;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would prefer (CollectionUtils.createSet(COMMIT_ACTION, DELTA_COMMIT_ACTION), one thing needs to note is the avro file uses the Java reflection to calcute the in-memory size of a record, while Parquet file size is the actual file size so it is more accurate, not sure whether we should include the log if there are parquets, that means, the parquet file size should have higher priority than log.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi @danny0405, I just reverted the code to the very first one.
Whether including the log or not, the current one would be better than the released one, at least for MoR tables

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, it is great if you can add a test for for the method.

}
HoodieCommitMetadata commitMetadata = HoodieCommitMetadata
.fromBytes(commitTimeline.getInstantDetails(instant).get(), HoodieCommitMetadata.class);
long totalBytesWritten = commitMetadata.fetchTotalBytesWritten();
Expand Down