boneanxs commented on code in PR #6046:
URL: https://github.com/apache/hudi/pull/6046#discussion_r946552880
##########
hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/client/clustering/run/strategy/MultipleSparkJobExecutionStrategy.java:
##########
@@ -273,6 +398,62 @@ private HoodieData<HoodieRecord<T>>
readRecordsForGroupBaseFiles(JavaSparkContex
.map(record -> transform(record, writeConfig)));
}
+ /**
+ * Get dataset of all records for the group. This includes all records from
file slice (Apply updates from log files, if any).
+ */
+ private Dataset<Row> readRecordsForGroupAsRow(JavaSparkContext jsc,
+ HoodieClusteringGroup
clusteringGroup,
+ String instantTime) {
+ List<ClusteringOperation> clusteringOps =
clusteringGroup.getSlices().stream()
+ .map(ClusteringOperation::create).collect(Collectors.toList());
+ boolean hasLogFiles = clusteringOps.stream().anyMatch(op ->
op.getDeltaFilePaths().size() > 0);
+ SQLContext sqlContext = new SQLContext(jsc.sc());
+
+ String[] baseFilePaths = clusteringOps
+ .stream()
+ .map(op -> {
+ ArrayList<String> pairs = new ArrayList<>();
+ if (op.getBootstrapFilePath() != null) {
+ pairs.add(op.getBootstrapFilePath());
+ }
+ if (op.getDataFilePath() != null) {
+ pairs.add(op.getDataFilePath());
+ }
+ return pairs;
+ })
+ .flatMap(Collection::stream)
+ .filter(path -> !path.isEmpty())
+ .toArray(String[]::new);
+ String[] deltaPaths = clusteringOps
+ .stream()
+ .filter(op -> !op.getDeltaFilePaths().isEmpty())
+ .flatMap(op -> op.getDeltaFilePaths().stream())
+ .toArray(String[]::new);
+
+ Dataset<Row> inputRecords;
+ if (hasLogFiles) {
+ String compactionFractor =
Option.ofNullable(getWriteConfig().getString("compaction.memory.fraction"))
+ .orElse("0.75");
+ String[] paths = new String[baseFilePaths.length + deltaPaths.length];
+ System.arraycopy(baseFilePaths, 0, paths, 0, baseFilePaths.length);
+ System.arraycopy(deltaPaths, 0, paths, baseFilePaths.length,
deltaPaths.length);
+ inputRecords = sqlContext.read()
+ .format("org.apache.hudi")
+ .option("hoodie.datasource.query.type", "snapshot")
+ .option("compaction.memory.fraction", compactionFractor)
+ .option("as.of.instant", instantTime)
+ .option("hoodie.datasource.read.paths", String.join(",", paths))
+ .load();
+ } else {
+ inputRecords = sqlContext.read()
+ .format("org.apache.hudi")
+ .option("as.of.instant", instantTime)
Review Comment:
Just setting this to keep commits align with the parquet files, should no
harm if we remove it, but we better align them same, what do you think?
--
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]