umehrot2 commented on a change in pull request #1421: [HUDI-724] Parallelize 
getSmallFiles for partitions
URL: https://github.com/apache/incubator-hudi/pull/1421#discussion_r395562779
 
 

 ##########
 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);
+        }
 
 Review comment:
   You may want to refactor this to something like:
   ```
   partitionSmallFilesMap = partitionPathRdds.mapToPair((PairFunction<String, 
String, List<SmallFile>>) 
     partitionPath -> new Tuple2<>(partitionPath, 
getSmallFiles(partitionPath))).collectAsMap();
   ```

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to