use of io.datarouter.filesystem.snapshot.group.dto.SnapshotKeyAndNumRecords in project datarouter by hotpads.
the class SnapshotMerger method merge.
public void merge() {
Map<SnapshotKey, SnapshotKeyAndNumRecords> summaryByKey = mergeGroup.keyReadOps(false).scanSnapshotKeysAndRootBlocks(readExec, 10).map(SnapshotKeyAndNumRecords::new).toMap(summary -> summary.key);
while (summaryByKey.size() > 1) {
SnapshotGroup outputGroup = summaryByKey.size() <= mergeFactor ? destinationGroup : mergeGroup;
Scanner.of(summaryByKey.values()).minN(SnapshotKeyAndNumRecords.BY_NUM_RECORDS, mergeFactor).map(summary -> summary.key).flush(keys -> {
SnapshotWriteResult result = combineSnapshots(keys, outputGroup);
var newSummary = new SnapshotKeyAndNumRecords(result.toSnapshotKeyAndRoot());
summaryByKey.put(result.key, newSummary);
}).forEach(summaryByKey::remove);
}
}
Aggregations