From 46313049ac01a3007ef60bdc937442945355a38d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Nicole?= Date: Wed, 22 Aug 2018 14:16:59 +0200 Subject: Separate UIDs and Revisions in main databases Summary: - Change revision type from `qint64` to `size_t` for LMDB in a couple of places (LMDB supports `unsigned int` or `size_t` which are `long unsigned int` on my machine) - Better support for database flags (duplicate, integer keys, integer values for now but is extensible) - Main databases' keys are now revisions - Some databases switched to integer keys databases: - Main databases - the revision to uid mapping database - the revision to entity type mapping database - Refactor the entity type's `typeDatabases` method (if in the future we need to change the main databases' flags again) - New uid to revision mapping database (`uidsToRevisions`): - Stores all revisions (not uid to latest revision) because we need it for cleaning old revisions - Flags are: duplicates + integer values (so findLatest finds the latest revision for the given uid) ~~Problems to fix before merging:~~ All Fixed! - ~~Sometimes Sink can't read what has just been written to the database (maybe because of transactions race conditions)~~ - ~~Most of the times, this results in Sink not able to find the uid for a given revision by reading the `revisions` database~~ - ~~`pipelinetest`'s `testModifyWithConflict` fails because the local changes are overridden~~ ~~The first problem prevents me from running benchmarks~~ Reviewers: cmollekopf Tags: #sink Differential Revision: https://phabricator.kde.org/D14974 --- sinksh/syntax_modules/sink_inspect.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'sinksh') diff --git a/sinksh/syntax_modules/sink_inspect.cpp b/sinksh/syntax_modules/sink_inspect.cpp index 1d2d90f..52a9e0f 100644 --- a/sinksh/syntax_modules/sink_inspect.cpp +++ b/sinksh/syntax_modules/sink_inspect.cpp @@ -87,13 +87,13 @@ bool inspect(const QStringList &args, State &state) [&] (const Sink::Storage::DataStore::Error &e) { Q_ASSERT(false); state.printError(e.message); - }, false); + }, Sink::Storage::IntegerKeys); auto ridMap = syncTransaction.openDatabase("localid.mapping." + type, [&] (const Sink::Storage::DataStore::Error &e) { Q_ASSERT(false); state.printError(e.message); - }, false); + }); QHash hash; @@ -108,7 +108,8 @@ bool inspect(const QStringList &args, State &state) QSet uids; db.scan("", [&] (const QByteArray &key, const QByteArray &data) { - uids.insert(Key::fromInternalByteArray(key).identifier().toDisplayByteArray()); + size_t revision = Sink::byteArrayToSizeT(key); + uids.insert(Sink::Storage::DataStore::getUidFromRevision(transaction, revision)); return true; }, [&](const Sink::Storage::DataStore::Error &e) { @@ -180,7 +181,7 @@ bool inspect(const QStringList &args, State &state) [&] (const Sink::Storage::DataStore::Error &e) { Q_ASSERT(false); state.printError(e.message); - }, false); + }); if (showInternal) { //Print internal keys -- cgit v1.2.3