diff options
author | Kae <80987908+Novaenia@users.noreply.github.com> | 2024-08-08 12:09:47 +1000 |
---|---|---|
committer | Kae <80987908+Novaenia@users.noreply.github.com> | 2024-08-08 12:09:47 +1000 |
commit | ffc1f95789a72a556dfba143b6d2169930771f7a (patch) | |
tree | b8fc022f3363503497fa3eca61058060d196a7d6 /source/utility | |
parent | b2afd6514413d95c083d60973a105e35da0b769a (diff) |
nicer error logging for BTree Repacker
recoverAll was really just sitting there
Diffstat (limited to 'source/utility')
-rw-r--r-- | source/utility/btree_repacker.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/source/utility/btree_repacker.cpp b/source/utility/btree_repacker.cpp index 4276571..d711a64 100644 --- a/source/utility/btree_repacker.cpp +++ b/source/utility/btree_repacker.cpp @@ -36,11 +36,16 @@ int main(int argc, char** argv) { newDb.open(); coutf("Repacking {}...\n", bTreePath); //copy the data over - unsigned count = 0; - db.forAll([&count, &newDb](ByteArray key, ByteArray data) { - newDb.insert(key, data); + unsigned count = 0, overwritten = 0; + auto visitor = [&](ByteArray key, ByteArray data) { + if (newDb.insert(key, data)) + ++overwritten; ++count; - }); + }; + auto errorHandler = [&](String const& error, std::exception const& e) { + coutf("{}: {}\n", error, e.what()); + }; + db.recoverAll(visitor, errorHandler); //close the old db db.close(); @@ -48,7 +53,7 @@ int main(int argc, char** argv) { newDb.commit(); newDb.close(); - coutf("Repacked BTree to {} in {}s\n", outputFilename, Time::monotonicTime() - startTime); + coutf("Repacked BTree to {} in {:.6f}s\n({} inserts, {} overwritten)\n", outputFilename, Time::monotonicTime() - startTime, count, overwritten); return 0; } catch (std::exception const& e) { |