JingsongLi commented on PR #1199:
URL:
https://github.com/apache/incubator-paimon/pull/1199#issuecomment-1558622147
Here is a draft:
```
public List<ManifestFileMeta> tryFullCompaction(List<ManifestFileMeta>
inputs, List<ManifestFileMeta> newMetas) {
List<ManifestFileMeta> base = new ArrayList<>();
int i;
for (i = 0; i < inputs.size(); i++) {
var file = inputs.get(i);
if (file no delete && file size >= targetFileSize) base.add(file);
else break;
}
List<ManifestFileMeta> delta = new ArrayList<>();
for (; i < inputs.size(); i++) {
delta.add(inputs.get(i));
}
if (total numDeletedFiles in delta < total numAddedFiles in delta) {
return inputs;
}
if (total file size of delta < delta-bytes-full-compaction-trigger) {
return inputs;
}
// do full-compaction
Map<ManifestEntry.Identifier, ManifestEntry> deltaMerged = new
LinkedHashMap<>();
for (ManifestFileMeta manifest : delta) {
ManifestEntry.mergeEntries(manifestFile.read(manifest.fileName),
deltaMerged);
}
Set<BinaryRow> deletePartitions = computeDeletePartitions(deltaMerged);
List<ManifestFileMeta> result = new ArrayList<>();
int j;
for (j = 0; j < base.size; j++) {
ManifestFileMeta file = base.get(i);
// TODO optimize this to use partitionStats
Set<BinaryRow> myPartitions = computePartitions(file);
if (deletePartitions.contains(myPartitions)) {
break;
} else {
result.add(file);
}
}
Map<ManifestEntry.Identifier, ManifestEntry> fullMerged = new
LinkedHashMap<>();
for (; j < base.size; j++) {
mergeEntries(file, fullMerged);
}
mergeEntries(fullMerged, deltaMerged);
if (!map.isEmpty()) {
List<ManifestFileMeta> merged = manifestFile.write(new
ArrayList<>(map.values()));
result.addAll(merged);
newMetas.addAll(merged);
}
return result;
}
```
--
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]