alexeykudinkin commented on code in PR #6046:
URL: https://github.com/apache/hudi/pull/6046#discussion_r977019700
##########
hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/client/clustering/run/strategy/MultipleSparkJobExecutionStrategy.java:
##########
@@ -275,6 +345,66 @@ 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());
+
+ Path[] baseFilePaths = clusteringOps
+ .stream()
+ .map(op -> {
+ ArrayList<String> readPaths = new ArrayList<>();
+ if (op.getBootstrapFilePath() != null) {
+ readPaths.add(op.getBootstrapFilePath());
+ }
+ if (op.getDataFilePath() != null) {
+ readPaths.add(op.getDataFilePath());
+ }
+ return readPaths;
+ })
+ .flatMap(Collection::stream)
+ .filter(path -> !path.isEmpty())
+ .map(Path::new)
+ .toArray(Path[]::new);
+
+ HashMap<String, String> params = new HashMap<>();
+ params.put("hoodie.datasource.query.type", "snapshot");
+ params.put("as.of.instant", instantTime);
+
+ Path[] paths;
+ if (hasLogFiles) {
+ String compactionFractor =
Option.ofNullable(getWriteConfig().getString("compaction.memory.fraction"))
+ .orElse("0.75");
+ params.put("compaction.memory.fraction", compactionFractor);
+
+ Path[] deltaPaths = clusteringOps
+ .stream()
+ .filter(op -> !op.getDeltaFilePaths().isEmpty())
+ .flatMap(op -> op.getDeltaFilePaths().stream())
+ .map(Path::new)
+ .toArray(Path[]::new);
+ paths = CollectionUtils.combine(baseFilePaths, deltaPaths);
+ } else {
+ paths = baseFilePaths;
+ }
+
+ String readPathString = String.join(",",
Arrays.stream(paths).map(Path::toString).toArray(String[]::new));
+ params.put("hoodie.datasource.read.paths", readPathString);
+ // Building HoodieFileIndex needs this param to decide query path
+ params.put("glob.paths", readPathString);
+
+ // Let Hudi relations to fetch the schema from the table itself
+ BaseRelation relation = SparkAdapterSupport$.MODULE$.sparkAdapter()
Review Comment:
:+1:
--
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]