summaryrefslogtreecommitdiffstats
path: root/sinksh
diff options
context:
space:
mode:
authorRémi Nicole <nicole@kolabsystems.com>2018-08-22 14:16:59 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2018-08-22 14:28:51 +0200
commit46313049ac01a3007ef60bdc937442945355a38d (patch)
tree56ce0cd679367a60ba3a706ac4d207bc9cc82230 /sinksh
parentaf91a18748b91f4a4fc0d83247561371d376bec5 (diff)
downloadsink-46313049ac01a3007ef60bdc937442945355a38d.tar.gz
sink-46313049ac01a3007ef60bdc937442945355a38d.zip
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
Diffstat (limited to 'sinksh')
-rw-r--r--sinksh/syntax_modules/sink_inspect.cpp9
1 files changed, 5 insertions, 4 deletions
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)
87 [&] (const Sink::Storage::DataStore::Error &e) { 87 [&] (const Sink::Storage::DataStore::Error &e) {
88 Q_ASSERT(false); 88 Q_ASSERT(false);
89 state.printError(e.message); 89 state.printError(e.message);
90 }, false); 90 }, Sink::Storage::IntegerKeys);
91 91
92 auto ridMap = syncTransaction.openDatabase("localid.mapping." + type, 92 auto ridMap = syncTransaction.openDatabase("localid.mapping." + type,
93 [&] (const Sink::Storage::DataStore::Error &e) { 93 [&] (const Sink::Storage::DataStore::Error &e) {
94 Q_ASSERT(false); 94 Q_ASSERT(false);
95 state.printError(e.message); 95 state.printError(e.message);
96 }, false); 96 });
97 97
98 QHash<QByteArray, QByteArray> hash; 98 QHash<QByteArray, QByteArray> hash;
99 99
@@ -108,7 +108,8 @@ bool inspect(const QStringList &args, State &state)
108 108
109 QSet<QByteArray> uids; 109 QSet<QByteArray> uids;
110 db.scan("", [&] (const QByteArray &key, const QByteArray &data) { 110 db.scan("", [&] (const QByteArray &key, const QByteArray &data) {
111 uids.insert(Key::fromInternalByteArray(key).identifier().toDisplayByteArray()); 111 size_t revision = Sink::byteArrayToSizeT(key);
112 uids.insert(Sink::Storage::DataStore::getUidFromRevision(transaction, revision));
112 return true; 113 return true;
113 }, 114 },
114 [&](const Sink::Storage::DataStore::Error &e) { 115 [&](const Sink::Storage::DataStore::Error &e) {
@@ -180,7 +181,7 @@ bool inspect(const QStringList &args, State &state)
180 [&] (const Sink::Storage::DataStore::Error &e) { 181 [&] (const Sink::Storage::DataStore::Error &e) {
181 Q_ASSERT(false); 182 Q_ASSERT(false);
182 state.printError(e.message); 183 state.printError(e.message);
183 }, false); 184 });
184 185
185 if (showInternal) { 186 if (showInternal) {
186 //Print internal keys 187 //Print internal keys