wchevreuil commented on code in PR #7129:
URL: https://github.com/apache/hbase/pull/7129#discussion_r2175186670
##########
hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/snapshot/ExportSnapshot.java:
##########
@@ -800,29 +857,63 @@ public List<InputSplit> getSplits(JobContext context)
throws IOException, Interr
conf.setInt(MR_NUM_MAPS, mappers);
}
- List<List<Pair<SnapshotFileInfo, Long>>> groups =
getBalancedSplits(snapshotFiles, mappers);
- List<InputSplit> splits = new ArrayList(groups.size());
- for (List<Pair<SnapshotFileInfo, Long>> files : groups) {
- splits.add(new ExportSnapshotInputSplit(files));
+ Class<? extends CustomFileGrouper> inputFileGrouperClass = conf.getClass(
+ CONF_INPUT_FILE_GROUPER_CLASS, NoopCustomFileGrouper.class,
CustomFileGrouper.class);
+ CustomFileGrouper customFileGrouper =
+ ReflectionUtils.newInstance(inputFileGrouperClass, conf);
+ Collection<Collection<Pair<SnapshotFileInfo, Long>>> groups =
+ customFileGrouper.getGroupedInputFiles(snapshotFiles);
+
+ LOG.info("CustomFileGrouper {} split input files into {} groups",
inputFileGrouperClass,
+ groups.size());
+ int mappersPerGroup = groups.isEmpty() ? 1 : Math.max(mappers /
groups.size(), 1);
Review Comment:
Is this check needed? The NoopCustomFileGrouper always return a List of the
snapshot files anyway.
Also can we add UT in TestExportSnapshotHelpers that certifies we don't grow
the number of mappers if groups >1 ?
##########
hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/snapshot/ExportSnapshot.java:
##########
@@ -724,8 +787,9 @@ private static Pair<SnapshotFileInfo, Long>
getSnapshotFileAndSize(FileSystem fs
* The algorithm used is pretty straightforward; the file list is sorted by
size, and then each
* group fetch the bigger file available, iterating through groups
alternating the direction.
*/
- static List<List<Pair<SnapshotFileInfo, Long>>>
- getBalancedSplits(final List<Pair<SnapshotFileInfo, Long>> files, final
int ngroups) {
+ static List<List<Pair<SnapshotFileInfo, Long>>> getBalancedSplits(
+ final Collection<Pair<SnapshotFileInfo, Long>> unsortedFiles, final int
ngroups) {
Review Comment:
nit: do we need to change signature parameter from List to Collection?
##########
hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/snapshot/ExportSnapshot.java:
##########
@@ -800,29 +857,63 @@ public List<InputSplit> getSplits(JobContext context)
throws IOException, Interr
conf.setInt(MR_NUM_MAPS, mappers);
}
- List<List<Pair<SnapshotFileInfo, Long>>> groups =
getBalancedSplits(snapshotFiles, mappers);
- List<InputSplit> splits = new ArrayList(groups.size());
- for (List<Pair<SnapshotFileInfo, Long>> files : groups) {
- splits.add(new ExportSnapshotInputSplit(files));
+ Class<? extends CustomFileGrouper> inputFileGrouperClass = conf.getClass(
+ CONF_INPUT_FILE_GROUPER_CLASS, NoopCustomFileGrouper.class,
CustomFileGrouper.class);
+ CustomFileGrouper customFileGrouper =
+ ReflectionUtils.newInstance(inputFileGrouperClass, conf);
+ Collection<Collection<Pair<SnapshotFileInfo, Long>>> groups =
+ customFileGrouper.getGroupedInputFiles(snapshotFiles);
+
+ LOG.info("CustomFileGrouper {} split input files into {} groups",
inputFileGrouperClass,
+ groups.size());
+ int mappersPerGroup = groups.isEmpty() ? 1 : Math.max(mappers /
groups.size(), 1);
+ LOG.info(
+ "Splitting each group into {} InputSplits, "
+ + "to achieve closest possible amount of mappers to target of {}",
+ mappersPerGroup, mappers);
+
+ Collection<List<Pair<SnapshotFileInfo, Long>>> balancedGroups =
+ groups.stream().map(g -> getBalancedSplits(g,
mappersPerGroup)).flatMap(Collection::stream)
+ .collect(Collectors.toList());
+
Review Comment:
Can we add a comment explaining we now do size splitting within each group
only?
--
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]