summaryrefslogtreecommitdiffstats
path: root/common/storage/key.h
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 /common/storage/key.h
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 'common/storage/key.h')
-rw-r--r--common/storage/key.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/common/storage/key.h b/common/storage/key.h
index baabe38..da90ddd 100644
--- a/common/storage/key.h
+++ b/common/storage/key.h
@@ -67,7 +67,7 @@ public:
67 static const constexpr size_t INTERNAL_REPR_SIZE = 19; 67 static const constexpr size_t INTERNAL_REPR_SIZE = 19;
68 static const constexpr size_t DISPLAY_REPR_SIZE = 19; 68 static const constexpr size_t DISPLAY_REPR_SIZE = 19;
69 69
70 Revision(qint64 rev) : rev(rev) {} 70 Revision(size_t rev) : rev(rev) {}
71 71
72 QByteArray toInternalByteArray() const; 72 QByteArray toInternalByteArray() const;
73 static Revision fromInternalByteArray(const QByteArray &bytes); 73 static Revision fromInternalByteArray(const QByteArray &bytes);
@@ -75,6 +75,7 @@ public:
75 QByteArray toDisplayByteArray() const; 75 QByteArray toDisplayByteArray() const;
76 static Revision fromDisplayByteArray(const QByteArray &bytes); 76 static Revision fromDisplayByteArray(const QByteArray &bytes);
77 qint64 toQint64() const; 77 qint64 toQint64() const;
78 size_t toSizeT() const;
78 79
79 static bool isValidInternal(const QByteArray &); 80 static bool isValidInternal(const QByteArray &);
80 static bool isValidDisplay(const QByteArray &); 81 static bool isValidDisplay(const QByteArray &);
@@ -84,7 +85,7 @@ public:
84 bool operator!=(const Revision &other) const; 85 bool operator!=(const Revision &other) const;
85 86
86private: 87private:
87 qint64 rev; 88 size_t rev;
88}; 89};
89 90
90class Key 91class Key