compact method
Compact the commit log. The Hive impl prunes duplicate entries
(same atKey, older commitId) — the same algorithm
HiveCompactionStrategy used to drive externally.
Implementation
@override
Stream<int> compact(bool dryRun) async* {
final List<int> keysToDelete =
await _commitLogKeyStore.getDuplicateEntries();
if (dryRun) {
for (final id in keysToDelete) {
yield id;
}
return;
}
try {
await _commitLogKeyStore.removeAll(keysToDelete);
} on Exception catch (e) {
throw DataStoreException(
'DataStoreException while deleting for compaction:${e.toString()}');
} on HiveError catch (e) {
throw DataStoreException(
'Hive error while deleting for compaction:${e.toString()}');
}
for (final id in keysToDelete) {
yield id;
}
}