summaryrefslogtreecommitdiffstats
path: root/common/storage/entitystore.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2016-10-13 18:38:35 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2018-02-11 23:03:17 +0100
commit6051c1247cde61bcc8e483eb4166e5a297c0ecc6 (patch)
treedf3aba1ef4011f2640b17c8cf7a9b106933231ab /common/storage/entitystore.cpp
parent8740a007515dcf1b315d69ab5c64fcfd40ec980c (diff)
downloadsink-6051c1247cde61bcc8e483eb4166e5a297c0ecc6.tar.gz
sink-6051c1247cde61bcc8e483eb4166e5a297c0ecc6.zip
Xapian based fulltext indexing
This cuts into the sync performance by about 40%, but gives us fast fulltext searching for all local content.
Diffstat (limited to 'common/storage/entitystore.cpp')
-rw-r--r--common/storage/entitystore.cpp22
1 files changed, 13 insertions, 9 deletions
diff --git a/common/storage/entitystore.cpp b/common/storage/entitystore.cpp
index 4ad3eaf..8fbc2ad 100644
--- a/common/storage/entitystore.cpp
+++ b/common/storage/entitystore.cpp
@@ -162,23 +162,27 @@ void EntityStore::startTransaction(Sink::Storage::DataStore::AccessMode accessMo
162{ 162{
163 SinkTraceCtx(d->logCtx) << "Starting transaction: " << accessMode; 163 SinkTraceCtx(d->logCtx) << "Starting transaction: " << accessMode;
164 Q_ASSERT(!d->transaction); 164 Q_ASSERT(!d->transaction);
165 Sink::Storage::DataStore store(Sink::storageLocation(), dbLayout(d->resourceContext.instanceId()), accessMode); 165 d->transaction = Sink::Storage::DataStore(Sink::storageLocation(), dbLayout(d->resourceContext.instanceId()), accessMode).createTransaction(accessMode);
166 d->transaction = store.createTransaction(accessMode);
167} 166}
168 167
169void EntityStore::commitTransaction() 168void EntityStore::commitTransaction()
170{ 169{
171 SinkTraceCtx(d->logCtx) << "Committing transaction"; 170 SinkTraceCtx(d->logCtx) << "Committing transaction";
171
172 for (const auto &type : d->indexByType.keys()) {
173 d->typeIndex(type).commitTransaction();
174 }
175
172 Q_ASSERT(d->transaction); 176 Q_ASSERT(d->transaction);
173 d->transaction.commit(); 177 d->transaction.commit();
174 d->transaction = Storage::DataStore::Transaction(); 178 d->transaction = {};
175} 179}
176 180
177void EntityStore::abortTransaction() 181void EntityStore::abortTransaction()
178{ 182{
179 SinkTraceCtx(d->logCtx) << "Aborting transaction"; 183 SinkTraceCtx(d->logCtx) << "Aborting transaction";
180 d->transaction.abort(); 184 d->transaction.abort();
181 d->transaction = Storage::DataStore::Transaction(); 185 d->transaction = {};
182} 186}
183 187
184bool EntityStore::hasTransaction() const 188bool EntityStore::hasTransaction() const
@@ -195,7 +199,7 @@ bool EntityStore::add(const QByteArray &type, ApplicationDomain::ApplicationDoma
195 199
196 SinkTraceCtx(d->logCtx) << "New entity " << entity; 200 SinkTraceCtx(d->logCtx) << "New entity " << entity;
197 201
198 d->typeIndex(type).add(entity.identifier(), entity, d->transaction); 202 d->typeIndex(type).add(entity.identifier(), entity, d->transaction, d->resourceContext.instanceId());
199 203
200 //The maxRevision may have changed meanwhile if the entity created sub-entities 204 //The maxRevision may have changed meanwhile if the entity created sub-entities
201 const qint64 newRevision = maxRevision() + 1; 205 const qint64 newRevision = maxRevision() + 1;
@@ -262,8 +266,8 @@ bool EntityStore::modify(const QByteArray &type, const ApplicationDomain::Applic
262{ 266{
263 SinkTraceCtx(d->logCtx) << "Modified entity: " << newEntity; 267 SinkTraceCtx(d->logCtx) << "Modified entity: " << newEntity;
264 268
265 d->typeIndex(type).remove(current.identifier(), current, d->transaction); 269 d->typeIndex(type).remove(current.identifier(), current, d->transaction, d->resourceContext.instanceId());
266 d->typeIndex(type).add(newEntity.identifier(), newEntity, d->transaction); 270 d->typeIndex(type).add(newEntity.identifier(), newEntity, d->transaction, d->resourceContext.instanceId());
267 271
268 const qint64 newRevision = DataStore::maxRevision(d->transaction) + 1; 272 const qint64 newRevision = DataStore::maxRevision(d->transaction) + 1;
269 273
@@ -304,7 +308,7 @@ bool EntityStore::remove(const QByteArray &type, const Sink::ApplicationDomain::
304 return false; 308 return false;
305 } 309 }
306 310
307 d->typeIndex(type).remove(current.identifier(), current, d->transaction); 311 d->typeIndex(type).remove(current.identifier(), current, d->transaction, d->resourceContext.instanceId());
308 312
309 SinkTraceCtx(d->logCtx) << "Removed entity " << current; 313 SinkTraceCtx(d->logCtx) << "Removed entity " << current;
310 314
@@ -422,7 +426,7 @@ QVector<QByteArray> EntityStore::indexLookup(const QByteArray &type, const Query
422 SinkTraceCtx(d->logCtx) << "Database is not existing: " << type; 426 SinkTraceCtx(d->logCtx) << "Database is not existing: " << type;
423 return QVector<QByteArray>(); 427 return QVector<QByteArray>();
424 } 428 }
425 return d->typeIndex(type).query(query, appliedFilters, appliedSorting, d->getTransaction()); 429 return d->typeIndex(type).query(query, appliedFilters, appliedSorting, d->getTransaction(), d->resourceContext.instanceId());
426} 430}
427 431
428QVector<QByteArray> EntityStore::indexLookup(const QByteArray &type, const QByteArray &property, const QVariant &value) 432QVector<QByteArray> EntityStore::indexLookup(const QByteArray &type, const QByteArray &property, const QVariant &value)