XuQianJin-Stars commented on code in PR #5791:
URL: https://github.com/apache/hudi/pull/5791#discussion_r891896666
##########
hudi-common/src/main/java/org/apache/hudi/internal/schema/io/FileBasedInternalSchemaStorageManager.java:
##########
@@ -131,6 +131,27 @@ private List<String> getValidInstants() {
.filterCompletedInstants().getInstants().map(f ->
f.getTimestamp()).collect(Collectors.toList());
}
+ /**
+ * Return whether an available historySchema file exist in schema folder or
not.
+ */
+ public boolean isValidHistorySchemaExist() {
+ try {
+ List<String> validateCommits = getValidInstants();
+ FileSystem fs = FSUtils.getFs(baseSchemaPath.toString(), conf);
+ if (fs.exists(baseSchemaPath)) {
+ List<String> validaSchemaFiles =
Arrays.stream(fs.listStatus(baseSchemaPath))
+ .filter(f -> f.isFile() &&
f.getPath().getName().endsWith(SCHEMA_COMMIT_ACTION))
+ .map(file -> file.getPath().getName()).filter(f ->
validateCommits.contains(f.split("\\.")[0])).sorted().collect(Collectors.toList());
Review Comment:
``` .map(file -> file.getPath().getName()).filter(f ->
validateCommits.contains(f.split("\\.")[0])).sorted().collect(Collectors.toList());```
-> ```.map(file -> file.getPath().getName()).filter(f ->
validateCommits.contains(f.split("\\.")[0])).findFirst()``` ?;
--
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]