summaryrefslogtreecommitdiffstats
path: root/common/storage
diff options
context:
space:
mode:
Diffstat (limited to 'common/storage')
-rw-r--r--common/storage/entitystore.cpp12
-rw-r--r--common/storage/entitystore.h4
-rw-r--r--common/storage/key.cpp6
-rw-r--r--common/storage/key.h2
4 files changed, 16 insertions, 8 deletions
diff --git a/common/storage/entitystore.cpp b/common/storage/entitystore.cpp
index 71690fe..1ba7c6c 100644
--- a/common/storage/entitystore.cpp
+++ b/common/storage/entitystore.cpp
@@ -426,19 +426,19 @@ bool EntityStore::cleanupRevisions(qint64 revision)
426 return cleanupIsNecessary; 426 return cleanupIsNecessary;
427} 427}
428 428
429QVector<QByteArray> EntityStore::fullScan(const QByteArray &type) 429QVector<Identifier> EntityStore::fullScan(const QByteArray &type)
430{ 430{
431 SinkTraceCtx(d->logCtx) << "Looking for : " << type; 431 SinkTraceCtx(d->logCtx) << "Looking for : " << type;
432 if (!d->exists()) { 432 if (!d->exists()) {
433 SinkTraceCtx(d->logCtx) << "Database is not existing: " << type; 433 SinkTraceCtx(d->logCtx) << "Database is not existing: " << type;
434 return QVector<QByteArray>(); 434 return {};
435 } 435 }
436 //The scan can return duplicate results if we have multiple revisions, so we use a set to deduplicate. 436 //The scan can return duplicate results if we have multiple revisions, so we use a set to deduplicate.
437 QSet<QByteArray> keys; 437 QSet<Identifier> keys;
438 DataStore::mainDatabase(d->getTransaction(), type) 438 DataStore::mainDatabase(d->getTransaction(), type)
439 .scan(QByteArray(), 439 .scan(QByteArray(),
440 [&](const QByteArray &key, const QByteArray &value) -> bool { 440 [&](const QByteArray &key, const QByteArray &value) -> bool {
441 const auto uid = Sink::Storage::Key::fromInternalByteArray(key).identifier().toDisplayByteArray(); 441 const auto uid = Sink::Storage::Key::fromInternalByteArray(key).identifier();
442 if (keys.contains(uid)) { 442 if (keys.contains(uid)) {
443 //Not something that should persist if the replay works, so we keep a message for now. 443 //Not something that should persist if the replay works, so we keep a message for now.
444 SinkTraceCtx(d->logCtx) << "Multiple revisions for key: " << key; 444 SinkTraceCtx(d->logCtx) << "Multiple revisions for key: " << key;
@@ -452,11 +452,11 @@ QVector<QByteArray> EntityStore::fullScan(const QByteArray &type)
452 return keys.toList().toVector(); 452 return keys.toList().toVector();
453} 453}
454 454
455QVector<QByteArray> EntityStore::indexLookup(const QByteArray &type, const QueryBase &query, QSet<QByteArrayList> &appliedFilters, QByteArray &appliedSorting) 455QVector<Identifier> EntityStore::indexLookup(const QByteArray &type, const QueryBase &query, QSet<QByteArrayList> &appliedFilters, QByteArray &appliedSorting)
456{ 456{
457 if (!d->exists()) { 457 if (!d->exists()) {
458 SinkTraceCtx(d->logCtx) << "Database is not existing: " << type; 458 SinkTraceCtx(d->logCtx) << "Database is not existing: " << type;
459 return QVector<QByteArray>(); 459 return {};
460 } 460 }
461 return d->typeIndex(type).query(query, appliedFilters, appliedSorting, d->getTransaction(), d->resourceContext.instanceId()); 461 return d->typeIndex(type).query(query, appliedFilters, appliedSorting, d->getTransaction(), d->resourceContext.instanceId());
462} 462}
diff --git a/common/storage/entitystore.h b/common/storage/entitystore.h
index 619b884..7979798 100644
--- a/common/storage/entitystore.h
+++ b/common/storage/entitystore.h
@@ -57,8 +57,8 @@ public:
57 void abortTransaction(); 57 void abortTransaction();
58 bool hasTransaction() const; 58 bool hasTransaction() const;
59 59
60 QVector<QByteArray> fullScan(const QByteArray &type); 60 QVector<Sink::Storage::Identifier> fullScan(const QByteArray &type);
61 QVector<QByteArray> indexLookup(const QByteArray &type, const QueryBase &query, QSet<QByteArrayList> &appliedFilters, QByteArray &appliedSorting); 61 QVector<Sink::Storage::Identifier> indexLookup(const QByteArray &type, const QueryBase &query, QSet<QByteArrayList> &appliedFilters, QByteArray &appliedSorting);
62 QVector<Sink::Storage::Identifier> indexLookup(const QByteArray &type, const QByteArray &property, const QVariant &value); 62 QVector<Sink::Storage::Identifier> indexLookup(const QByteArray &type, const QByteArray &property, const QVariant &value);
63 void indexLookup(const QByteArray &type, const QByteArray &property, const QVariant &value, const std::function<void(const QByteArray &uid)> &callback); 63 void indexLookup(const QByteArray &type, const QByteArray &property, const QVariant &value, const std::function<void(const QByteArray &uid)> &callback);
64 template<typename EntityType, typename PropertyType> 64 template<typename EntityType, typename PropertyType>
diff --git a/common/storage/key.cpp b/common/storage/key.cpp
index 23d7a6a..2327061 100644
--- a/common/storage/key.cpp
+++ b/common/storage/key.cpp
@@ -26,6 +26,12 @@ using Sink::Storage::Identifier;
26using Sink::Storage::Key; 26using Sink::Storage::Key;
27using Sink::Storage::Revision; 27using Sink::Storage::Revision;
28 28
29
30uint Sink::Storage::qHash(const Sink::Storage::Identifier &identifier)
31{
32 return qHash(identifier.toInternalByteArray());
33}
34
29QDebug &operator<<(QDebug &dbg, const Identifier &id) 35QDebug &operator<<(QDebug &dbg, const Identifier &id)
30{ 36{
31 dbg << id.toDisplayString(); 37 dbg << id.toDisplayString();
diff --git a/common/storage/key.h b/common/storage/key.h
index 211aea7..baabe38 100644
--- a/common/storage/key.h
+++ b/common/storage/key.h
@@ -119,6 +119,8 @@ private:
119 Revision rev; 119 Revision rev;
120}; 120};
121 121
122SINK_EXPORT uint qHash(const Sink::Storage::Identifier &);
123
122} // namespace Storage 124} // namespace Storage
123} // namespace Sink 125} // namespace Sink
124 126