summaryrefslogtreecommitdiffstats
path: root/common/index.cpp
diff options
context:
space:
mode:
authorRémi Nicole <nicole@kolabsystems.com>2018-07-27 13:32:40 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2018-07-27 13:47:50 +0200
commit620c4f551d3de830a516475ad02965695cb25945 (patch)
tree5839f93daf4718113b8160248cb22db4f0810b15 /common/index.cpp
parentd1838e575baeb6cd08011645609516acbdabd6c8 (diff)
downloadsink-620c4f551d3de830a516475ad02965695cb25945.tar.gz
sink-620c4f551d3de830a516475ad02965695cb25945.zip
Use Key API in indexes
Summary: - Only in TypeIndex, not in Index (since we might want to store something other than identifiers as values) - We might want to do the same in the `SynchronizerStore` for localId ↔ remoteId indexes Depends on D13735 Some quick benchmarks (against develop and D13735): {F6022279} Reviewers: cmollekopf Reviewed By: cmollekopf Tags: #sink Differential Revision: https://phabricator.kde.org/D13902
Diffstat (limited to 'common/index.cpp')
-rw-r--r--common/index.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/common/index.cpp b/common/index.cpp
index 86a2dd5..238a745 100644
--- a/common/index.cpp
+++ b/common/index.cpp
@@ -2,6 +2,8 @@
2 2
3#include "log.h" 3#include "log.h"
4 4
5using Sink::Storage::Identifier;
6
5Index::Index(const QString &storageRoot, const QString &dbName, const QString &indexName, Sink::Storage::DataStore::AccessMode mode) 7Index::Index(const QString &storageRoot, const QString &dbName, const QString &indexName, Sink::Storage::DataStore::AccessMode mode)
6 : mTransaction(Sink::Storage::DataStore(storageRoot, dbName, mode).createTransaction(mode)), 8 : mTransaction(Sink::Storage::DataStore(storageRoot, dbName, mode).createTransaction(mode)),
7 mDb(mTransaction.openDatabase(indexName.toLatin1(), std::function<void(const Sink::Storage::DataStore::Error &)>(), true)), 9 mDb(mTransaction.openDatabase(indexName.toLatin1(), std::function<void(const Sink::Storage::DataStore::Error &)>(), true)),
@@ -32,6 +34,11 @@ Index::Index(const QByteArray &name, Sink::Storage::DataStore::Transaction &tran
32{ 34{
33} 35}
34 36
37void Index::add(const Identifier &key, const QByteArray &value)
38{
39 add(key.toInternalByteArray(), value);
40}
41
35void Index::add(const QByteArray &key, const QByteArray &value) 42void Index::add(const QByteArray &key, const QByteArray &value)
36{ 43{
37 Q_ASSERT(!key.isEmpty()); 44 Q_ASSERT(!key.isEmpty());
@@ -40,6 +47,11 @@ void Index::add(const QByteArray &key, const QByteArray &value)
40 }); 47 });
41} 48}
42 49
50void Index::remove(const Identifier &key, const QByteArray &value)
51{
52 remove(key.toInternalByteArray(), value);
53}
54
43void Index::remove(const QByteArray &key, const QByteArray &value) 55void Index::remove(const QByteArray &key, const QByteArray &value)
44{ 56{
45 mDb.remove(key, value, [&] (const Sink::Storage::DataStore::Error &error) { 57 mDb.remove(key, value, [&] (const Sink::Storage::DataStore::Error &error) {