ffcchi commented on a change in pull request #1421: [HUDI-724] Parallelize
getSmallFiles for partitions
URL: https://github.com/apache/incubator-hudi/pull/1421#discussion_r395433104
##########
File path:
hudi-client/src/main/java/org/apache/hudi/table/HoodieCopyOnWriteTable.java
##########
@@ -602,18 +602,39 @@ private int addUpdateBucket(String fileIdHint) {
return bucket;
}
- private void assignInserts(WorkloadProfile profile) {
+ private void assignInserts(WorkloadProfile profile, JavaSparkContext jsc) {
// for new inserts, compute buckets depending on how many records we
have for each partition
Set<String> partitionPaths = profile.getPartitionPaths();
long averageRecordSize =
averageBytesPerRecord(metaClient.getActiveTimeline().getCommitTimeline().filterCompletedInstants(),
config.getCopyOnWriteRecordSizeEstimate());
LOG.info("AvgRecordSize => " + averageRecordSize);
+
+ HashMap<String, List<SmallFile>> partitionSmallFilesMap = new
HashMap<>();
+ if (jsc != null && partitionPaths.size() > 1) {
+ //Parellelize the GetSmallFile Operation by using RDDs
+ List<String> partitionPathsList = new ArrayList<>(partitionPaths);
+ JavaRDD<String> partitionPathRdds =
jsc.parallelize(partitionPathsList, partitionPathsList.size());
+ List<Tuple2<String, List<SmallFile>>> partitionSmallFileTuples =
+ partitionPathRdds.map(it -> new Tuple2<String,
List<SmallFile>>(it, getSmallFiles(it))).collect();
+
+ for (Tuple2<String, List<SmallFile>> tuple : partitionSmallFileTuples)
{
+ partitionSmallFilesMap.put(tuple._1, tuple._2);
+ }
+ }
+
for (String partitionPath : partitionPaths) {
WorkloadStat pStat = profile.getWorkloadStat(partitionPath);
if (pStat.getNumInserts() > 0) {
- List<SmallFile> smallFiles = getSmallFiles(partitionPath);
+ List<SmallFile> smallFiles;
+ if (partitionSmallFilesMap.isEmpty()) {
Review comment:
sounds good. will do
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services