JingsongLi commented on a change in pull request #21:
URL: https://github.com/apache/flink-table-store/pull/21#discussion_r806558516
##########
File path:
flink-table-store-core/src/main/java/org/apache/flink/table/store/file/manifest/ManifestFileMeta.java
##########
@@ -162,54 +176,44 @@ public String toString() {
return result;
}
- private static void merge(
- List<ManifestFileMeta> metas,
- ManifestFile manifestFile,
- List<ManifestFileMeta> result,
- List<ManifestFileMeta> newMetas) {
- if (metas.size() > 1) {
- ManifestFileMeta newMeta = merge(metas, manifestFile);
- result.add(newMeta);
- newMetas.add(newMeta);
- } else {
- result.addAll(metas);
+ private static ManifestFileMeta merge(
+ List<ManifestFileMeta> metas, List<ManifestEntry> entries,
ManifestFile manifestFile) {
+ Map<ManifestEntry.Identifier, ManifestEntry> map = new
LinkedHashMap<>();
+ for (ManifestFileMeta manifest : metas) {
+ merge(manifestFile.read(manifest.fileName), map);
}
+ merge(entries, map);
+ return manifestFile.write(new ArrayList<>(map.values()));
}
- private static ManifestFileMeta merge(List<ManifestFileMeta> metas,
ManifestFile manifestFile) {
- Preconditions.checkArgument(
- metas.size() > 1, "Number of ManifestFileMeta <= 1. This is a
bug.");
-
- Map<ManifestEntry.Identifier, ManifestEntry> map = new
LinkedHashMap<>();
- for (ManifestFileMeta manifest : metas) {
- for (ManifestEntry entry : manifestFile.read(manifest.fileName)) {
- ManifestEntry.Identifier identifier = entry.identifier();
- switch (entry.kind()) {
- case ADD:
- Preconditions.checkState(
- !map.containsKey(identifier),
- "Trying to add file %s which is already added.
Manifest might be corrupted.",
- identifier);
+ private static void merge(
Review comment:
Minor: Can rename these three `merge` method? Like:
- `tryMergeManifestsAndEntries`
- `mergeManifestsAndEntries`
- `mergeEntries`
--
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]