diff options
author | Rémi Nicole <nicole@kolabsystems.com> | 2018-08-22 14:16:59 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2018-08-22 14:28:51 +0200 |
commit | 46313049ac01a3007ef60bdc937442945355a38d (patch) | |
tree | 56ce0cd679367a60ba3a706ac4d207bc9cc82230 /common/domain/typeimplementations.cpp | |
parent | af91a18748b91f4a4fc0d83247561371d376bec5 (diff) | |
download | sink-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/domain/typeimplementations.cpp')
-rw-r--r-- | common/domain/typeimplementations.cpp | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/common/domain/typeimplementations.cpp b/common/domain/typeimplementations.cpp index aedf889..6e14501 100644 --- a/common/domain/typeimplementations.cpp +++ b/common/domain/typeimplementations.cpp | |||
@@ -80,7 +80,11 @@ typedef IndexConfig<Calendar, | |||
80 | ValueIndex<Calendar::Name> | 80 | ValueIndex<Calendar::Name> |
81 | > CalendarIndexConfig; | 81 | > CalendarIndexConfig; |
82 | 82 | ||
83 | 83 | template <typename EntityType, typename EntityIndexConfig> | |
84 | QMap<QByteArray, int> defaultTypeDatabases() | ||
85 | { | ||
86 | return merge(QMap<QByteArray, int>{{QByteArray{EntityType::name} + ".main", Storage::IntegerKeys}}, EntityIndexConfig::databases()); | ||
87 | } | ||
84 | 88 | ||
85 | void TypeImplementation<Mail>::configure(TypeIndex &index) | 89 | void TypeImplementation<Mail>::configure(TypeIndex &index) |
86 | { | 90 | { |
@@ -89,7 +93,7 @@ void TypeImplementation<Mail>::configure(TypeIndex &index) | |||
89 | 93 | ||
90 | QMap<QByteArray, int> TypeImplementation<Mail>::typeDatabases() | 94 | QMap<QByteArray, int> TypeImplementation<Mail>::typeDatabases() |
91 | { | 95 | { |
92 | return merge(QMap<QByteArray, int>{{QByteArray{Mail::name} + ".main", 0}}, MailIndexConfig::databases()); | 96 | return defaultTypeDatabases<Mail, MailIndexConfig>(); |
93 | } | 97 | } |
94 | 98 | ||
95 | void TypeImplementation<Mail>::configure(IndexPropertyMapper &indexPropertyMapper) | 99 | void TypeImplementation<Mail>::configure(IndexPropertyMapper &indexPropertyMapper) |
@@ -132,7 +136,7 @@ void TypeImplementation<Folder>::configure(TypeIndex &index) | |||
132 | 136 | ||
133 | QMap<QByteArray, int> TypeImplementation<Folder>::typeDatabases() | 137 | QMap<QByteArray, int> TypeImplementation<Folder>::typeDatabases() |
134 | { | 138 | { |
135 | return merge(QMap<QByteArray, int>{{QByteArray{Folder::name} + ".main", 0}}, FolderIndexConfig::databases()); | 139 | return defaultTypeDatabases<Folder, FolderIndexConfig>(); |
136 | } | 140 | } |
137 | 141 | ||
138 | void TypeImplementation<Folder>::configure(PropertyMapper &propertyMapper) | 142 | void TypeImplementation<Folder>::configure(PropertyMapper &propertyMapper) |
@@ -157,7 +161,7 @@ void TypeImplementation<Contact>::configure(TypeIndex &index) | |||
157 | 161 | ||
158 | QMap<QByteArray, int> TypeImplementation<Contact>::typeDatabases() | 162 | QMap<QByteArray, int> TypeImplementation<Contact>::typeDatabases() |
159 | { | 163 | { |
160 | return merge(QMap<QByteArray, int>{{QByteArray{Contact::name} + ".main", 0}}, ContactIndexConfig::databases()); | 164 | return defaultTypeDatabases<Contact, ContactIndexConfig>(); |
161 | } | 165 | } |
162 | 166 | ||
163 | void TypeImplementation<Contact>::configure(PropertyMapper &propertyMapper) | 167 | void TypeImplementation<Contact>::configure(PropertyMapper &propertyMapper) |
@@ -185,7 +189,7 @@ void TypeImplementation<Addressbook>::configure(TypeIndex &index) | |||
185 | 189 | ||
186 | QMap<QByteArray, int> TypeImplementation<Addressbook>::typeDatabases() | 190 | QMap<QByteArray, int> TypeImplementation<Addressbook>::typeDatabases() |
187 | { | 191 | { |
188 | return merge(QMap<QByteArray, int>{{QByteArray{Addressbook::name} + ".main", 0}}, AddressbookIndexConfig::databases()); | 192 | return defaultTypeDatabases<Addressbook, AddressbookIndexConfig>(); |
189 | } | 193 | } |
190 | 194 | ||
191 | void TypeImplementation<Addressbook>::configure(PropertyMapper &propertyMapper) | 195 | void TypeImplementation<Addressbook>::configure(PropertyMapper &propertyMapper) |
@@ -207,7 +211,7 @@ void TypeImplementation<Event>::configure(TypeIndex &index) | |||
207 | 211 | ||
208 | QMap<QByteArray, int> TypeImplementation<Event>::typeDatabases() | 212 | QMap<QByteArray, int> TypeImplementation<Event>::typeDatabases() |
209 | { | 213 | { |
210 | return merge(QMap<QByteArray, int>{{QByteArray{Event::name} + ".main", 0}}, EventIndexConfig::databases()); | 214 | return defaultTypeDatabases<Event, EventIndexConfig>(); |
211 | } | 215 | } |
212 | 216 | ||
213 | void TypeImplementation<Event>::configure(PropertyMapper &propertyMapper) | 217 | void TypeImplementation<Event>::configure(PropertyMapper &propertyMapper) |
@@ -235,7 +239,7 @@ void TypeImplementation<Todo>::configure(TypeIndex &index) | |||
235 | 239 | ||
236 | QMap<QByteArray, int> TypeImplementation<Todo>::typeDatabases() | 240 | QMap<QByteArray, int> TypeImplementation<Todo>::typeDatabases() |
237 | { | 241 | { |
238 | return merge(QMap<QByteArray, int>{{QByteArray{Todo::name} + ".main", 0}}, TodoIndexConfig::databases()); | 242 | return defaultTypeDatabases<Todo, TodoIndexConfig>(); |
239 | } | 243 | } |
240 | 244 | ||
241 | void TypeImplementation<Todo>::configure(PropertyMapper &propertyMapper) | 245 | void TypeImplementation<Todo>::configure(PropertyMapper &propertyMapper) |
@@ -266,7 +270,7 @@ void TypeImplementation<Calendar>::configure(TypeIndex &index) | |||
266 | 270 | ||
267 | QMap<QByteArray, int> TypeImplementation<Calendar>::typeDatabases() | 271 | QMap<QByteArray, int> TypeImplementation<Calendar>::typeDatabases() |
268 | { | 272 | { |
269 | return merge(QMap<QByteArray, int>{{QByteArray{Calendar::name} + ".main", 0}}, CalendarIndexConfig::databases()); | 273 | return defaultTypeDatabases<Calendar, CalendarIndexConfig>(); |
270 | } | 274 | } |
271 | 275 | ||
272 | void TypeImplementation<Calendar>::configure(PropertyMapper &propertyMapper) | 276 | void TypeImplementation<Calendar>::configure(PropertyMapper &propertyMapper) |