summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2016-10-16 14:55:20 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2016-10-21 09:02:21 +0200
commit237b9ae4113e7a9f489632296941becb71afdb45 (patch)
tree01cde58f495944f01cad9d282391d4efd2897141 /tests
parent95d11bf0be98a4e3c08502fe23417b800233ce14 (diff)
downloadsink-237b9ae4113e7a9f489632296941becb71afdb45.tar.gz
sink-237b9ae4113e7a9f489632296941becb71afdb45.zip
Refactor how the storage is used.
This is the initial refactoring to improve how we deal with the storage. It does a couple of things: * Rename Sink::Storage to Sink::Storage::DataStore to free up the Sink::Storage namespace * Introduce a Sink::ResourceContext to have a single object that can be passed around containing everything that is necessary to operate on a resource. This is a lot better than the multiple separate parameters that we used to pass around all over the place, while still allowing for dependency injection for tests. * Tie storage access together using the new EntityStore that directly works with ApplicationDomainTypes. This gives us a central place where main storage, indexes and buffer adaptors are tied together, which will also give us a place to implement external indexes, such as a fulltextindex using xapian. * Use ApplicationDomainTypes as the default way to pass around entities. Instead of using various ways to pass around entities (buffers, buffer adaptors, ApplicationDomainTypes), only use a single way. The old approach was confusing, and was only done as: * optimization; really shouldn't be necessary and otherwise I'm sure we can find better ways to optimize ApplicationDomainType itself. * a way to account for entities that have multiple buffers, a concept that I no longer deem relevant. While this commit does the bulk of the work to get there, the following commits will refactor more stuff to get things back to normal.
Diffstat (limited to 'tests')
-rw-r--r--tests/clientapitest.cpp6
-rw-r--r--tests/databasepopulationandfacadequerybenchmark.cpp22
-rw-r--r--tests/dummyresourcebenchmark.cpp4
-rw-r--r--tests/dummyresourcetest.cpp9
-rw-r--r--tests/dummyresourcewritebenchmark.cpp4
-rw-r--r--tests/hawd/dataset.cpp8
-rw-r--r--tests/hawd/dataset.h4
-rw-r--r--tests/indextest.cpp6
-rw-r--r--tests/mailquerybenchmark.cpp11
-rw-r--r--tests/messagequeuetest.cpp4
-rw-r--r--tests/pipelinebenchmark.cpp11
-rw-r--r--tests/pipelinetest.cpp49
-rw-r--r--tests/querytest.cpp2
-rw-r--r--tests/storagebenchmark.cpp24
-rw-r--r--tests/storagetest.cpp136
-rw-r--r--tests/testimplementations.h10
16 files changed, 155 insertions, 155 deletions
diff --git a/tests/clientapitest.cpp b/tests/clientapitest.cpp
index fd3d5f0..94c78a7 100644
--- a/tests/clientapitest.cpp
+++ b/tests/clientapitest.cpp
@@ -22,11 +22,13 @@ public:
22 auto facade = std::make_shared<TestDummyResourceFacade<T>>(); 22 auto facade = std::make_shared<TestDummyResourceFacade<T>>();
23 map.insert(instanceIdentifier, facade); 23 map.insert(instanceIdentifier, facade);
24 bool alwaysReturnFacade = instanceIdentifier.isEmpty(); 24 bool alwaysReturnFacade = instanceIdentifier.isEmpty();
25 Sink::FacadeFactory::instance().registerFacade<T, TestDummyResourceFacade<T>>("dummyresource", [alwaysReturnFacade](const QByteArray &instanceIdentifier) { 25 Sink::FacadeFactory::instance().registerFacade<T, TestDummyResourceFacade<T>>("dummyresource", [alwaysReturnFacade](const Sink::ResourceContext &context) {
26 if (alwaysReturnFacade) { 26 if (alwaysReturnFacade) {
27 Q_ASSERT(map.contains(QByteArray()));
27 return map.value(QByteArray()); 28 return map.value(QByteArray());
28 } 29 }
29 return map.value(instanceIdentifier); 30 Q_ASSERT(map.contains(context.instanceId()));
31 return map.value(context.instanceId());
30 }); 32 });
31 return facade; 33 return facade;
32 } 34 }
diff --git a/tests/databasepopulationandfacadequerybenchmark.cpp b/tests/databasepopulationandfacadequerybenchmark.cpp
index 5efe292..4e00bd4 100644
--- a/tests/databasepopulationandfacadequerybenchmark.cpp
+++ b/tests/databasepopulationandfacadequerybenchmark.cpp
@@ -38,13 +38,13 @@ class DatabasePopulationAndFacadeQueryBenchmark : public QObject
38 38
39 void populateDatabase(int count) 39 void populateDatabase(int count)
40 { 40 {
41 Sink::Storage(Sink::storageLocation(), "identifier", Sink::Storage::ReadWrite).removeFromDisk(); 41 Sink::Storage::DataStore(Sink::storageLocation(), "identifier", Sink::Storage::DataStore::ReadWrite).removeFromDisk();
42 // Setup 42 // Setup
43 auto domainTypeAdaptorFactory = QSharedPointer<TestEventAdaptorFactory>::create(); 43 auto domainTypeAdaptorFactory = QSharedPointer<TestEventAdaptorFactory>::create();
44 { 44 {
45 Sink::Storage storage(Sink::storageLocation(), identifier, Sink::Storage::ReadWrite); 45 Sink::Storage::DataStore storage(Sink::storageLocation(), identifier, Sink::Storage::DataStore::ReadWrite);
46 auto transaction = storage.createTransaction(Sink::Storage::ReadWrite); 46 auto transaction = storage.createTransaction(Sink::Storage::DataStore::ReadWrite);
47 auto db = Sink::Storage::mainDatabase(transaction, "event"); 47 auto db = Sink::Storage::DataStore::mainDatabase(transaction, "event");
48 48
49 int bufferSizeTotal = 0; 49 int bufferSizeTotal = 0;
50 int keysSizeTotal = 0; 50 int keysSizeTotal = 0;
@@ -58,15 +58,15 @@ class DatabasePopulationAndFacadeQueryBenchmark : public QObject
58 flatbuffers::FlatBufferBuilder fbb; 58 flatbuffers::FlatBufferBuilder fbb;
59 domainTypeAdaptorFactory->createBuffer(*domainObject, fbb); 59 domainTypeAdaptorFactory->createBuffer(*domainObject, fbb);
60 const auto buffer = QByteArray::fromRawData(reinterpret_cast<const char *>(fbb.GetBufferPointer()), fbb.GetSize()); 60 const auto buffer = QByteArray::fromRawData(reinterpret_cast<const char *>(fbb.GetBufferPointer()), fbb.GetSize());
61 const auto key = Sink::Storage::generateUid(); 61 const auto key = Sink::Storage::DataStore::generateUid();
62 db.write(key, buffer); 62 db.write(key, buffer);
63 bufferSizeTotal += buffer.size(); 63 bufferSizeTotal += buffer.size();
64 keysSizeTotal += key.size(); 64 keysSizeTotal += key.size();
65 } 65 }
66 transaction.commit(); 66 transaction.commit();
67 67
68 transaction = storage.createTransaction(Sink::Storage::ReadOnly); 68 transaction = storage.createTransaction(Sink::Storage::DataStore::ReadOnly);
69 db = Sink::Storage::mainDatabase(transaction, "event"); 69 db = Sink::Storage::DataStore::mainDatabase(transaction, "event");
70 70
71 auto dataSizeTotal = count * (QByteArray("uid").size() + QByteArray("summary").size() + attachment.size()); 71 auto dataSizeTotal = count * (QByteArray("uid").size() + QByteArray("summary").size() + attachment.size());
72 auto size = db.getSize(); 72 auto size = db.getSize();
@@ -100,7 +100,11 @@ class DatabasePopulationAndFacadeQueryBenchmark : public QObject
100 100
101 auto resultSet = QSharedPointer<Sink::ResultProvider<Sink::ApplicationDomain::Event::Ptr>>::create(); 101 auto resultSet = QSharedPointer<Sink::ResultProvider<Sink::ApplicationDomain::Event::Ptr>>::create();
102 auto resourceAccess = QSharedPointer<TestResourceAccess>::create(); 102 auto resourceAccess = QSharedPointer<TestResourceAccess>::create();
103 TestResourceFacade facade(identifier, resourceAccess); 103
104 QMap<QByteArray, DomainTypeAdaptorFactoryInterface::Ptr> factories;
105 Sink::ResourceContext context{identifier, "test", factories};
106 context.mResourceAccess = resourceAccess;
107 TestResourceFacade facade(context);
104 108
105 auto ret = facade.load(query); 109 auto ret = facade.load(query);
106 ret.first.exec().waitForFinished(); 110 ret.first.exec().waitForFinished();
@@ -118,7 +122,7 @@ class DatabasePopulationAndFacadeQueryBenchmark : public QObject
118 const auto finalRss = getCurrentRSS(); 122 const auto finalRss = getCurrentRSS();
119 const auto rssGrowth = finalRss - startingRss; 123 const auto rssGrowth = finalRss - startingRss;
120 // Since the database is memory mapped it is attributted to the resident set size. 124 // Since the database is memory mapped it is attributted to the resident set size.
121 const auto rssWithoutDb = finalRss - Sink::Storage(Sink::storageLocation(), identifier, Sink::Storage::ReadWrite).diskUsage(); 125 const auto rssWithoutDb = finalRss - Sink::Storage::DataStore(Sink::storageLocation(), identifier, Sink::Storage::DataStore::ReadWrite).diskUsage();
122 const auto peakRss = getPeakRSS(); 126 const auto peakRss = getPeakRSS();
123 // How much peak deviates from final rss in percent (should be around 0) 127 // How much peak deviates from final rss in percent (should be around 0)
124 const auto percentageRssError = static_cast<double>(peakRss - finalRss) * 100.0 / static_cast<double>(finalRss); 128 const auto percentageRssError = static_cast<double>(peakRss - finalRss) * 100.0 / static_cast<double>(finalRss);
diff --git a/tests/dummyresourcebenchmark.cpp b/tests/dummyresourcebenchmark.cpp
index d0ecef7..a2de316 100644
--- a/tests/dummyresourcebenchmark.cpp
+++ b/tests/dummyresourcebenchmark.cpp
@@ -9,7 +9,6 @@
9#include "resourcecontrol.h" 9#include "resourcecontrol.h"
10#include "commands.h" 10#include "commands.h"
11#include "entitybuffer.h" 11#include "entitybuffer.h"
12#include "pipeline.h"
13#include "log.h" 12#include "log.h"
14#include "resourceconfig.h" 13#include "resourceconfig.h"
15#include "notification_generated.h" 14#include "notification_generated.h"
@@ -151,8 +150,7 @@ private slots:
151 QTime time; 150 QTime time;
152 time.start(); 151 time.start();
153 152
154 auto pipeline = QSharedPointer<Sink::Pipeline>::create("sink.dummy.instance1"); 153 DummyResource resource(Sink::ResourceContext{"sink.dummy.instance1", "test"});
155 DummyResource resource("sink.dummy.instance1", pipeline);
156 154
157 flatbuffers::FlatBufferBuilder eventFbb; 155 flatbuffers::FlatBufferBuilder eventFbb;
158 eventFbb.Clear(); 156 eventFbb.Clear();
diff --git a/tests/dummyresourcetest.cpp b/tests/dummyresourcetest.cpp
index be6e3a5..0883a13 100644
--- a/tests/dummyresourcetest.cpp
+++ b/tests/dummyresourcetest.cpp
@@ -13,6 +13,7 @@
13#include "log.h" 13#include "log.h"
14#include "test.h" 14#include "test.h"
15#include "testutils.h" 15#include "testutils.h"
16#include "adaptorfactoryregistry.h"
16 17
17using namespace Sink; 18using namespace Sink;
18using namespace Sink::ApplicationDomain; 19using namespace Sink::ApplicationDomain;
@@ -28,6 +29,11 @@ class DummyResourceTest : public QObject
28 29
29 QTime time; 30 QTime time;
30 31
32 Sink::ResourceContext getContext()
33 {
34 return Sink::ResourceContext{"sink.dummy.instance1", "sink.dummy", Sink::AdaptorFactoryRegistry::instance().getFactories("sink.dummy")};
35 }
36
31private slots: 37private slots:
32 void initTestCase() 38 void initTestCase()
33 { 39 {
@@ -129,8 +135,7 @@ private slots:
129 135
130 void testResourceSync() 136 void testResourceSync()
131 { 137 {
132 auto pipeline = QSharedPointer<Sink::Pipeline>::create("sink.dummy.instance1"); 138 ::DummyResource resource(getContext());
133 ::DummyResource resource("sink.dummy.instance1", pipeline);
134 auto job = resource.synchronizeWithSource(); 139 auto job = resource.synchronizeWithSource();
135 // TODO pass in optional timeout? 140 // TODO pass in optional timeout?
136 auto future = job.exec(); 141 auto future = job.exec();
diff --git a/tests/dummyresourcewritebenchmark.cpp b/tests/dummyresourcewritebenchmark.cpp
index 5cd7007..facd60c 100644
--- a/tests/dummyresourcewritebenchmark.cpp
+++ b/tests/dummyresourcewritebenchmark.cpp
@@ -9,7 +9,6 @@
9#include "store.h" 9#include "store.h"
10#include "commands.h" 10#include "commands.h"
11#include "entitybuffer.h" 11#include "entitybuffer.h"
12#include "pipeline.h"
13#include "log.h" 12#include "log.h"
14#include "resourceconfig.h" 13#include "resourceconfig.h"
15#include "definitions.h" 14#include "definitions.h"
@@ -109,8 +108,7 @@ class DummyResourceWriteBenchmark : public QObject
109 QTime time; 108 QTime time;
110 time.start(); 109 time.start();
111 110
112 auto pipeline = QSharedPointer<Sink::Pipeline>::create("sink.dummy.instance1"); 111 ::DummyResource resource(Sink::ResourceContext{"sink.dummy.instance1", "dummy"});
113 DummyResource resource("sink.dummy.instance1", pipeline);
114 112
115 int bufferSize = 0; 113 int bufferSize = 0;
116 auto command = createEntityBuffer(bufferSize); 114 auto command = createEntityBuffer(bufferSize);
diff --git a/tests/hawd/dataset.cpp b/tests/hawd/dataset.cpp
index c023f31..fb2d7e6 100644
--- a/tests/hawd/dataset.cpp
+++ b/tests/hawd/dataset.cpp
@@ -215,7 +215,7 @@ QString Dataset::Row::toString(const QStringList &cols, int standardCols, const
215 215
216Dataset::Dataset(const QString &name, const State &state) 216Dataset::Dataset(const QString &name, const State &state)
217 : m_definition(state.datasetDefinition(name)), 217 : m_definition(state.datasetDefinition(name)),
218 m_storage(state.resultsPath(), name, Sink::Storage::ReadWrite), 218 m_storage(state.resultsPath(), name, Sink::Storage::DataStore::ReadWrite),
219 m_transaction(m_storage.createTransaction()), 219 m_transaction(m_storage.createTransaction()),
220 m_commitHash(state.commitHash()) 220 m_commitHash(state.commitHash())
221{ 221{
@@ -270,13 +270,13 @@ void Dataset::eachRow(const std::function<void(const Row &row)> &resultHandler)
270 resultHandler(row); 270 resultHandler(row);
271 return true; 271 return true;
272 }, 272 },
273 Sink::Storage::basicErrorHandler()); 273 Sink::Storage::DataStore::basicErrorHandler());
274} 274}
275 275
276Dataset::Row Dataset::row(qint64 key) 276Dataset::Row Dataset::row(qint64 key)
277{ 277{
278 if (key < 1) { 278 if (key < 1) {
279 Row row(*this, Sink::Storage::maxRevision(m_transaction)); 279 Row row(*this, Sink::Storage::DataStore::maxRevision(m_transaction));
280 row.setCommitHash(m_commitHash); 280 row.setCommitHash(m_commitHash);
281 return row; 281 return row;
282 } 282 }
@@ -287,7 +287,7 @@ Dataset::Row Dataset::row(qint64 key)
287 row.fromBinary(value); 287 row.fromBinary(value);
288 return true; 288 return true;
289 }, 289 },
290 Sink::Storage::basicErrorHandler() 290 Sink::Storage::DataStore::basicErrorHandler()
291 ); 291 );
292 return row; 292 return row;
293} 293}
diff --git a/tests/hawd/dataset.h b/tests/hawd/dataset.h
index 0fca8f0..bb2aae5 100644
--- a/tests/hawd/dataset.h
+++ b/tests/hawd/dataset.h
@@ -84,8 +84,8 @@ public:
84 84
85private: 85private:
86 DatasetDefinition m_definition; 86 DatasetDefinition m_definition;
87 Sink::Storage m_storage; 87 Sink::Storage::DataStore m_storage;
88 Sink::Storage::Transaction m_transaction; 88 Sink::Storage::DataStore::Transaction m_transaction;
89 QString m_commitHash; 89 QString m_commitHash;
90}; 90};
91 91
diff --git a/tests/indextest.cpp b/tests/indextest.cpp
index 8566803..d6a28d6 100644
--- a/tests/indextest.cpp
+++ b/tests/indextest.cpp
@@ -16,19 +16,19 @@ class IndexTest : public QObject
16private slots: 16private slots:
17 void initTestCase() 17 void initTestCase()
18 { 18 {
19 Sink::Storage store("./testindex", "sink.dummy.testindex", Sink::Storage::ReadWrite); 19 Sink::Storage::DataStore store("./testindex", "sink.dummy.testindex", Sink::Storage::DataStore::ReadWrite);
20 store.removeFromDisk(); 20 store.removeFromDisk();
21 } 21 }
22 22
23 void cleanup() 23 void cleanup()
24 { 24 {
25 Sink::Storage store("./testindex", "sink.dummy.testindex", Sink::Storage::ReadWrite); 25 Sink::Storage::DataStore store("./testindex", "sink.dummy.testindex", Sink::Storage::DataStore::ReadWrite);
26 store.removeFromDisk(); 26 store.removeFromDisk();
27 } 27 }
28 28
29 void testIndex() 29 void testIndex()
30 { 30 {
31 Index index("./testindex", "sink.dummy.testindex", Sink::Storage::ReadWrite); 31 Index index("./testindex", "sink.dummy.testindex", Sink::Storage::DataStore::ReadWrite);
32 // The first key is specifically a substring of the second key 32 // The first key is specifically a substring of the second key
33 index.add("key", "value1"); 33 index.add("key", "value1");
34 index.add("keyFoo", "value2"); 34 index.add("keyFoo", "value2");
diff --git a/tests/mailquerybenchmark.cpp b/tests/mailquerybenchmark.cpp
index 1d96819..c44b9f6 100644
--- a/tests/mailquerybenchmark.cpp
+++ b/tests/mailquerybenchmark.cpp
@@ -62,8 +62,7 @@ class MailQueryBenchmark : public QObject
62 { 62 {
63 TestResource::removeFromDisk(resourceIdentifier); 63 TestResource::removeFromDisk(resourceIdentifier);
64 64
65 auto pipeline = QSharedPointer<Sink::Pipeline>::create(resourceIdentifier); 65 auto pipeline = QSharedPointer<Sink::Pipeline>::create(Sink::ResourceContext{resourceIdentifier, "test"});
66 pipeline->setResourceType("test");
67 66
68 auto indexer = QSharedPointer<DefaultIndexUpdater<Mail>>::create(); 67 auto indexer = QSharedPointer<DefaultIndexUpdater<Mail>>::create();
69 68
@@ -94,10 +93,10 @@ class MailQueryBenchmark : public QObject
94 // Benchmark 93 // Benchmark
95 QTime time; 94 QTime time;
96 time.start(); 95 time.start();
97
98 auto resultSet = QSharedPointer<Sink::ResultProvider<Mail::Ptr>>::create(); 96 auto resultSet = QSharedPointer<Sink::ResultProvider<Mail::Ptr>>::create();
99 auto resourceAccess = QSharedPointer<TestResourceAccess>::create(); 97 Sink::ResourceContext context{resourceIdentifier, "test"};
100 TestMailResourceFacade facade(resourceIdentifier, resourceAccess); 98 context.mResourceAccess = QSharedPointer<TestResourceAccess>::create();
99 TestMailResourceFacade facade(context);
101 100
102 auto ret = facade.load(query); 101 auto ret = facade.load(query);
103 ret.first.exec().waitForFinished(); 102 ret.first.exec().waitForFinished();
@@ -115,7 +114,7 @@ class MailQueryBenchmark : public QObject
115 const auto finalRss = getCurrentRSS(); 114 const auto finalRss = getCurrentRSS();
116 const auto rssGrowth = finalRss - startingRss; 115 const auto rssGrowth = finalRss - startingRss;
117 // Since the database is memory mapped it is attributted to the resident set size. 116 // Since the database is memory mapped it is attributted to the resident set size.
118 const auto rssWithoutDb = finalRss - Sink::Storage(Sink::storageLocation(), resourceIdentifier, Sink::Storage::ReadWrite).diskUsage(); 117 const auto rssWithoutDb = finalRss - Sink::Storage::DataStore(Sink::storageLocation(), resourceIdentifier, Sink::Storage::DataStore::ReadWrite).diskUsage();
119 const auto peakRss = getPeakRSS(); 118 const auto peakRss = getPeakRSS();
120 // How much peak deviates from final rss in percent (should be around 0) 119 // How much peak deviates from final rss in percent (should be around 0)
121 const auto percentageRssError = static_cast<double>(peakRss - finalRss) * 100.0 / static_cast<double>(finalRss); 120 const auto percentageRssError = static_cast<double>(peakRss - finalRss) * 100.0 / static_cast<double>(finalRss);
diff --git a/tests/messagequeuetest.cpp b/tests/messagequeuetest.cpp
index e79bba2..83fa23f 100644
--- a/tests/messagequeuetest.cpp
+++ b/tests/messagequeuetest.cpp
@@ -21,7 +21,7 @@ private slots:
21 void initTestCase() 21 void initTestCase()
22 { 22 {
23 Sink::Test::initTest(); 23 Sink::Test::initTest();
24 Sink::Storage store(Sink::Store::storageLocation(), "sink.dummy.testqueue", Sink::Storage::ReadWrite); 24 Sink::Storage::DataStore store(Sink::Store::storageLocation(), "sink.dummy.testqueue", Sink::Storage::DataStore::ReadWrite);
25 store.removeFromDisk(); 25 store.removeFromDisk();
26 } 26 }
27 27
@@ -31,7 +31,7 @@ private slots:
31 31
32 void cleanup() 32 void cleanup()
33 { 33 {
34 Sink::Storage store(Sink::Store::storageLocation(), "sink.dummy.testqueue", Sink::Storage::ReadWrite); 34 Sink::Storage::DataStore store(Sink::Store::storageLocation(), "sink.dummy.testqueue", Sink::Storage::DataStore::ReadWrite);
35 store.removeFromDisk(); 35 store.removeFromDisk();
36 } 36 }
37 37
diff --git a/tests/pipelinebenchmark.cpp b/tests/pipelinebenchmark.cpp
index 0c0b9e6..16806c7 100644
--- a/tests/pipelinebenchmark.cpp
+++ b/tests/pipelinebenchmark.cpp
@@ -47,7 +47,7 @@
47 47
48// class IndexUpdater : public Sink::Preprocessor { 48// class IndexUpdater : public Sink::Preprocessor {
49// public: 49// public:
50// void newEntity(const QByteArray &uid, qint64 revision, const Sink::ApplicationDomain::BufferAdaptor &newEntity, Sink::Storage::Transaction &transaction) Q_DECL_OVERRIDE 50// void newEntity(const QByteArray &uid, qint64 revision, const Sink::ApplicationDomain::BufferAdaptor &newEntity, Sink::Storage::DataStore::Transaction &transaction) Q_DECL_OVERRIDE
51// { 51// {
52// for (int i = 0; i < 10; i++) { 52// for (int i = 0; i < 10; i++) {
53// Index ridIndex(QString("index.index%1").arg(i).toLatin1(), transaction); 53// Index ridIndex(QString("index.index%1").arg(i).toLatin1(), transaction);
@@ -56,11 +56,11 @@
56// } 56// }
57// 57//
58// void modifiedEntity(const QByteArray &key, qint64 revision, const Sink::ApplicationDomain::BufferAdaptor &oldEntity, const Sink::ApplicationDomain::BufferAdaptor &newEntity, 58// void modifiedEntity(const QByteArray &key, qint64 revision, const Sink::ApplicationDomain::BufferAdaptor &oldEntity, const Sink::ApplicationDomain::BufferAdaptor &newEntity,
59// Sink::Storage::Transaction &transaction) Q_DECL_OVERRIDE 59// Sink::Storage::DataStore::Transaction &transaction) Q_DECL_OVERRIDE
60// { 60// {
61// } 61// }
62// 62//
63// void deletedEntity(const QByteArray &key, qint64 revision, const Sink::ApplicationDomain::BufferAdaptor &oldEntity, Sink::Storage::Transaction &transaction) Q_DECL_OVERRIDE 63// void deletedEntity(const QByteArray &key, qint64 revision, const Sink::ApplicationDomain::BufferAdaptor &oldEntity, Sink::Storage::DataStore::Transaction &transaction) Q_DECL_OVERRIDE
64// { 64// {
65// } 65// }
66// }; 66// };
@@ -83,9 +83,8 @@ class PipelineBenchmark : public QObject
83 { 83 {
84 TestResource::removeFromDisk(resourceIdentifier); 84 TestResource::removeFromDisk(resourceIdentifier);
85 85
86 auto pipeline = QSharedPointer<Sink::Pipeline>::create(resourceIdentifier); 86 auto pipeline = QSharedPointer<Sink::Pipeline>::create(Sink::ResourceContext{resourceIdentifier, "test"});
87 pipeline->setPreprocessors("mail", preprocessors); 87 pipeline->setPreprocessors("mail", preprocessors);
88 pipeline->setResourceType("test");
89 88
90 QTime time; 89 QTime time;
91 time.start(); 90 time.start();
@@ -112,7 +111,7 @@ class PipelineBenchmark : public QObject
112 // Print memory layout, RSS is what is in memory 111 // Print memory layout, RSS is what is in memory
113 // std::system("exec pmap -x \"$PPID\""); 112 // std::system("exec pmap -x \"$PPID\"");
114 // 113 //
115 std::cout << "Size: " << Sink::Storage(Sink::storageLocation(), resourceIdentifier, Sink::Storage::ReadOnly).diskUsage() / 1024 << " [kb]" << std::endl; 114 std::cout << "Size: " << Sink::Storage::DataStore(Sink::storageLocation(), resourceIdentifier, Sink::Storage::DataStore::ReadOnly).diskUsage() / 1024 << " [kb]" << std::endl;
116 std::cout << "Time: " << allProcessedTime << " [ms]" << std::endl; 115 std::cout << "Time: " << allProcessedTime << " [ms]" << std::endl;
117 116
118 HAWD::Dataset dataset("pipeline", mHawdState); 117 HAWD::Dataset dataset("pipeline", mHawdState);
diff --git a/tests/pipelinetest.cpp b/tests/pipelinetest.cpp
index 7216f62..112453e 100644
--- a/tests/pipelinetest.cpp
+++ b/tests/pipelinetest.cpp
@@ -23,14 +23,14 @@
23 23
24static void removeFromDisk(const QString &name) 24static void removeFromDisk(const QString &name)
25{ 25{
26 Sink::Storage store(Sink::Store::storageLocation(), name, Sink::Storage::ReadWrite); 26 Sink::Storage::DataStore store(Sink::Store::storageLocation(), name, Sink::Storage::DataStore::ReadWrite);
27 store.removeFromDisk(); 27 store.removeFromDisk();
28} 28}
29 29
30static QList<QByteArray> getKeys(const QByteArray &dbEnv, const QByteArray &name) 30static QList<QByteArray> getKeys(const QByteArray &dbEnv, const QByteArray &name)
31{ 31{
32 Sink::Storage store(Sink::storageLocation(), dbEnv, Sink::Storage::ReadOnly); 32 Sink::Storage::DataStore store(Sink::storageLocation(), dbEnv, Sink::Storage::DataStore::ReadOnly);
33 auto transaction = store.createTransaction(Sink::Storage::ReadOnly); 33 auto transaction = store.createTransaction(Sink::Storage::DataStore::ReadOnly);
34 auto db = transaction.openDatabase(name, nullptr, false); 34 auto db = transaction.openDatabase(name, nullptr, false);
35 QList<QByteArray> result; 35 QList<QByteArray> result;
36 db.scan("", [&](const QByteArray &key, const QByteArray &value) { 36 db.scan("", [&](const QByteArray &key, const QByteArray &value) {
@@ -42,8 +42,8 @@ static QList<QByteArray> getKeys(const QByteArray &dbEnv, const QByteArray &name
42 42
43static QByteArray getEntity(const QByteArray &dbEnv, const QByteArray &name, const QByteArray &uid) 43static QByteArray getEntity(const QByteArray &dbEnv, const QByteArray &name, const QByteArray &uid)
44{ 44{
45 Sink::Storage store(Sink::storageLocation(), dbEnv, Sink::Storage::ReadOnly); 45 Sink::Storage::DataStore store(Sink::storageLocation(), dbEnv, Sink::Storage::DataStore::ReadOnly);
46 auto transaction = store.createTransaction(Sink::Storage::ReadOnly); 46 auto transaction = store.createTransaction(Sink::Storage::DataStore::ReadOnly);
47 auto db = transaction.openDatabase(name, nullptr, false); 47 auto db = transaction.openDatabase(name, nullptr, false);
48 QByteArray result; 48 QByteArray result;
49 db.scan(uid, [&](const QByteArray &key, const QByteArray &value) { 49 db.scan(uid, [&](const QByteArray &key, const QByteArray &value) {
@@ -152,20 +152,20 @@ QByteArray deleteEntityCommand(const QByteArray &uid, qint64 revision)
152class TestProcessor : public Sink::Preprocessor 152class TestProcessor : public Sink::Preprocessor
153{ 153{
154public: 154public:
155 void newEntity(const QByteArray &uid, qint64 revision, Sink::ApplicationDomain::BufferAdaptor &newEntity, Sink::Storage::Transaction &transaction) Q_DECL_OVERRIDE 155 void newEntity(const QByteArray &uid, qint64 revision, Sink::ApplicationDomain::BufferAdaptor &newEntity, Sink::Storage::DataStore::Transaction &transaction) Q_DECL_OVERRIDE
156 { 156 {
157 newUids << uid; 157 newUids << uid;
158 newRevisions << revision; 158 newRevisions << revision;
159 } 159 }
160 160
161 void modifiedEntity(const QByteArray &uid, qint64 revision, const Sink::ApplicationDomain::BufferAdaptor &oldEntity, Sink::ApplicationDomain::BufferAdaptor &newEntity, 161 void modifiedEntity(const QByteArray &uid, qint64 revision, const Sink::ApplicationDomain::BufferAdaptor &oldEntity, Sink::ApplicationDomain::BufferAdaptor &newEntity,
162 Sink::Storage::Transaction &transaction) Q_DECL_OVERRIDE 162 Sink::Storage::DataStore::Transaction &transaction) Q_DECL_OVERRIDE
163 { 163 {
164 modifiedUids << uid; 164 modifiedUids << uid;
165 modifiedRevisions << revision; 165 modifiedRevisions << revision;
166 } 166 }
167 167
168 void deletedEntity(const QByteArray &uid, qint64 revision, const Sink::ApplicationDomain::BufferAdaptor &oldEntity, Sink::Storage::Transaction &transaction) Q_DECL_OVERRIDE 168 void deletedEntity(const QByteArray &uid, qint64 revision, const Sink::ApplicationDomain::BufferAdaptor &oldEntity, Sink::Storage::DataStore::Transaction &transaction) Q_DECL_OVERRIDE
169 { 169 {
170 deletedUids << uid; 170 deletedUids << uid;
171 deletedRevisions << revision; 171 deletedRevisions << revision;
@@ -203,8 +203,7 @@ private slots:
203 flatbuffers::FlatBufferBuilder entityFbb; 203 flatbuffers::FlatBufferBuilder entityFbb;
204 auto command = createEntityCommand(createEvent(entityFbb)); 204 auto command = createEntityCommand(createEvent(entityFbb));
205 205
206 Sink::Pipeline pipeline("sink.pipelinetest.instance1"); 206 Sink::Pipeline pipeline(Sink::ResourceContext{"sink.pipelinetest.instance1", "test"});
207 pipeline.setResourceType("test");
208 207
209 pipeline.startTransaction(); 208 pipeline.startTransaction();
210 pipeline.newEntity(command.constData(), command.size()); 209 pipeline.newEntity(command.constData(), command.size());
@@ -220,8 +219,7 @@ private slots:
220 flatbuffers::FlatBufferBuilder entityFbb; 219 flatbuffers::FlatBufferBuilder entityFbb;
221 auto command = createEntityCommand(createEvent(entityFbb, "summary", "description")); 220 auto command = createEntityCommand(createEvent(entityFbb, "summary", "description"));
222 221
223 Sink::Pipeline pipeline("sink.pipelinetest.instance1"); 222 Sink::Pipeline pipeline(Sink::ResourceContext{"sink.pipelinetest.instance1", "test"});
224 pipeline.setResourceType("test");
225 223
226 auto adaptorFactory = QSharedPointer<TestEventAdaptorFactory>::create(); 224 auto adaptorFactory = QSharedPointer<TestEventAdaptorFactory>::create();
227 225
@@ -234,7 +232,7 @@ private slots:
234 auto keys = getKeys("sink.pipelinetest.instance1", "event.main"); 232 auto keys = getKeys("sink.pipelinetest.instance1", "event.main");
235 QCOMPARE(keys.size(), 1); 233 QCOMPARE(keys.size(), 1);
236 const auto key = keys.first(); 234 const auto key = keys.first();
237 const auto uid = Sink::Storage::uidFromKey(key); 235 const auto uid = Sink::Storage::DataStore::uidFromKey(key);
238 236
239 // Execute the modification 237 // Execute the modification
240 entityFbb.Clear(); 238 entityFbb.Clear();
@@ -244,7 +242,7 @@ private slots:
244 pipeline.commit(); 242 pipeline.commit();
245 243
246 // Ensure we've got the new revision with the modification 244 // Ensure we've got the new revision with the modification
247 auto buffer = getEntity("sink.pipelinetest.instance1", "event.main", Sink::Storage::assembleKey(uid, 2)); 245 auto buffer = getEntity("sink.pipelinetest.instance1", "event.main", Sink::Storage::DataStore::assembleKey(uid, 2));
248 QVERIFY(!buffer.isEmpty()); 246 QVERIFY(!buffer.isEmpty());
249 Sink::EntityBuffer entityBuffer(buffer.data(), buffer.size()); 247 Sink::EntityBuffer entityBuffer(buffer.data(), buffer.size());
250 auto adaptor = adaptorFactory->createAdaptor(entityBuffer.entity()); 248 auto adaptor = adaptorFactory->createAdaptor(entityBuffer.entity());
@@ -269,8 +267,7 @@ private slots:
269 flatbuffers::FlatBufferBuilder entityFbb; 267 flatbuffers::FlatBufferBuilder entityFbb;
270 auto command = createEntityCommand(createEvent(entityFbb)); 268 auto command = createEntityCommand(createEvent(entityFbb));
271 269
272 Sink::Pipeline pipeline("sink.pipelinetest.instance1"); 270 Sink::Pipeline pipeline(Sink::ResourceContext{"sink.pipelinetest.instance1", "test"});
273 pipeline.setResourceType("test");
274 271
275 auto adaptorFactory = QSharedPointer<TestEventAdaptorFactory>::create(); 272 auto adaptorFactory = QSharedPointer<TestEventAdaptorFactory>::create();
276 273
@@ -282,7 +279,7 @@ private slots:
282 // Get uid of written entity 279 // Get uid of written entity
283 auto keys = getKeys("sink.pipelinetest.instance1", "event.main"); 280 auto keys = getKeys("sink.pipelinetest.instance1", "event.main");
284 QCOMPARE(keys.size(), 1); 281 QCOMPARE(keys.size(), 1);
285 const auto uid = Sink::Storage::uidFromKey(keys.first()); 282 const auto uid = Sink::Storage::DataStore::uidFromKey(keys.first());
286 283
287 284
288 // Create another operation inbetween 285 // Create another operation inbetween
@@ -302,7 +299,7 @@ private slots:
302 pipeline.commit(); 299 pipeline.commit();
303 300
304 // Ensure we've got the new revision with the modification 301 // Ensure we've got the new revision with the modification
305 auto buffer = getEntity("sink.pipelinetest.instance1", "event.main", Sink::Storage::assembleKey(uid, 3)); 302 auto buffer = getEntity("sink.pipelinetest.instance1", "event.main", Sink::Storage::DataStore::assembleKey(uid, 3));
306 QVERIFY(!buffer.isEmpty()); 303 QVERIFY(!buffer.isEmpty());
307 Sink::EntityBuffer entityBuffer(buffer.data(), buffer.size()); 304 Sink::EntityBuffer entityBuffer(buffer.data(), buffer.size());
308 auto adaptor = adaptorFactory->createAdaptor(entityBuffer.entity()); 305 auto adaptor = adaptorFactory->createAdaptor(entityBuffer.entity());
@@ -313,8 +310,7 @@ private slots:
313 { 310 {
314 flatbuffers::FlatBufferBuilder entityFbb; 311 flatbuffers::FlatBufferBuilder entityFbb;
315 auto command = createEntityCommand(createEvent(entityFbb)); 312 auto command = createEntityCommand(createEvent(entityFbb));
316 Sink::Pipeline pipeline("sink.pipelinetest.instance1"); 313 Sink::Pipeline pipeline(Sink::ResourceContext{"sink.pipelinetest.instance1", "test"});
317 pipeline.setResourceType("test");
318 314
319 // Create the initial revision 315 // Create the initial revision
320 pipeline.startTransaction(); 316 pipeline.startTransaction();
@@ -324,7 +320,7 @@ private slots:
324 auto result = getKeys("sink.pipelinetest.instance1", "event.main"); 320 auto result = getKeys("sink.pipelinetest.instance1", "event.main");
325 QCOMPARE(result.size(), 1); 321 QCOMPARE(result.size(), 1);
326 322
327 const auto uid = Sink::Storage::uidFromKey(result.first()); 323 const auto uid = Sink::Storage::DataStore::uidFromKey(result.first());
328 324
329 // Delete entity 325 // Delete entity
330 auto deleteCommand = deleteEntityCommand(uid, 1); 326 auto deleteCommand = deleteEntityCommand(uid, 1);
@@ -350,8 +346,7 @@ private slots:
350 346
351 auto testProcessor = new TestProcessor; 347 auto testProcessor = new TestProcessor;
352 348
353 Sink::Pipeline pipeline("sink.pipelinetest.instance1"); 349 Sink::Pipeline pipeline(Sink::ResourceContext{"sink.pipelinetest.instance1", "test"});
354 pipeline.setResourceType("test");
355 pipeline.setPreprocessors("event", QVector<Sink::Preprocessor *>() << testProcessor); 350 pipeline.setPreprocessors("event", QVector<Sink::Preprocessor *>() << testProcessor);
356 pipeline.startTransaction(); 351 pipeline.startTransaction();
357 // pipeline.setAdaptorFactory("event", QSharedPointer<TestEventAdaptorFactory>::create()); 352 // pipeline.setAdaptorFactory("event", QSharedPointer<TestEventAdaptorFactory>::create());
@@ -363,21 +358,21 @@ private slots:
363 QCOMPARE(testProcessor->newUids.size(), 1); 358 QCOMPARE(testProcessor->newUids.size(), 1);
364 QCOMPARE(testProcessor->newRevisions.size(), 1); 359 QCOMPARE(testProcessor->newRevisions.size(), 1);
365 // Key doesn't contain revision and is just the uid 360 // Key doesn't contain revision and is just the uid
366 QCOMPARE(testProcessor->newUids.at(0), Sink::Storage::uidFromKey(testProcessor->newUids.at(0))); 361 QCOMPARE(testProcessor->newUids.at(0), Sink::Storage::DataStore::uidFromKey(testProcessor->newUids.at(0)));
367 } 362 }
368 pipeline.commit(); 363 pipeline.commit();
369 entityFbb.Clear(); 364 entityFbb.Clear();
370 pipeline.startTransaction(); 365 pipeline.startTransaction();
371 auto keys = getKeys("sink.pipelinetest.instance1", "event.main"); 366 auto keys = getKeys("sink.pipelinetest.instance1", "event.main");
372 QCOMPARE(keys.size(), 1); 367 QCOMPARE(keys.size(), 1);
373 const auto uid = Sink::Storage::uidFromKey(keys.first()); 368 const auto uid = Sink::Storage::DataStore::uidFromKey(keys.first());
374 { 369 {
375 auto modifyCommand = modifyEntityCommand(createEvent(entityFbb, "summary2"), uid, 1); 370 auto modifyCommand = modifyEntityCommand(createEvent(entityFbb, "summary2"), uid, 1);
376 pipeline.modifiedEntity(modifyCommand.constData(), modifyCommand.size()); 371 pipeline.modifiedEntity(modifyCommand.constData(), modifyCommand.size());
377 QCOMPARE(testProcessor->modifiedUids.size(), 1); 372 QCOMPARE(testProcessor->modifiedUids.size(), 1);
378 QCOMPARE(testProcessor->modifiedRevisions.size(), 1); 373 QCOMPARE(testProcessor->modifiedRevisions.size(), 1);
379 // Key doesn't contain revision and is just the uid 374 // Key doesn't contain revision and is just the uid
380 QCOMPARE(testProcessor->modifiedUids.at(0), Sink::Storage::uidFromKey(testProcessor->modifiedUids.at(0))); 375 QCOMPARE(testProcessor->modifiedUids.at(0), Sink::Storage::DataStore::uidFromKey(testProcessor->modifiedUids.at(0)));
381 } 376 }
382 pipeline.commit(); 377 pipeline.commit();
383 entityFbb.Clear(); 378 entityFbb.Clear();
@@ -389,7 +384,7 @@ private slots:
389 QCOMPARE(testProcessor->deletedUids.size(), 1); 384 QCOMPARE(testProcessor->deletedUids.size(), 1);
390 QCOMPARE(testProcessor->deletedSummaries.size(), 1); 385 QCOMPARE(testProcessor->deletedSummaries.size(), 1);
391 // Key doesn't contain revision and is just the uid 386 // Key doesn't contain revision and is just the uid
392 QCOMPARE(testProcessor->deletedUids.at(0), Sink::Storage::uidFromKey(testProcessor->deletedUids.at(0))); 387 QCOMPARE(testProcessor->deletedUids.at(0), Sink::Storage::DataStore::uidFromKey(testProcessor->deletedUids.at(0)));
393 QCOMPARE(testProcessor->deletedSummaries.at(0), QByteArray("summary2")); 388 QCOMPARE(testProcessor->deletedSummaries.at(0), QByteArray("summary2"));
394 } 389 }
395 } 390 }
diff --git a/tests/querytest.cpp b/tests/querytest.cpp
index c5c251a..9ae3c74 100644
--- a/tests/querytest.cpp
+++ b/tests/querytest.cpp
@@ -64,7 +64,7 @@ private slots:
64 // Setup 64 // Setup
65 { 65 {
66 Mail mail("sink.dummy.instance1"); 66 Mail mail("sink.dummy.instance1");
67 Sink::Store::create<Mail>(mail).exec().waitForFinished(); 67 VERIFYEXEC(Sink::Store::create<Mail>(mail));
68 } 68 }
69 69
70 // Test 70 // Test
diff --git a/tests/storagebenchmark.cpp b/tests/storagebenchmark.cpp
index a1ddcc9..906844e 100644
--- a/tests/storagebenchmark.cpp
+++ b/tests/storagebenchmark.cpp
@@ -62,7 +62,7 @@ private slots:
62 62
63 void cleanupTestCase() 63 void cleanupTestCase()
64 { 64 {
65 Sink::Storage store(testDataPath, dbName); 65 Sink::Storage::DataStore store(testDataPath, dbName);
66 store.removeFromDisk(); 66 store.removeFromDisk();
67 } 67 }
68 68
@@ -70,7 +70,7 @@ private slots:
70 { 70 {
71 auto event = createEvent(); 71 auto event = createEvent();
72 72
73 QScopedPointer<Sink::Storage> store(new Sink::Storage(testDataPath, dbName, Sink::Storage::ReadWrite)); 73 QScopedPointer<Sink::Storage::DataStore> store(new Sink::Storage::DataStore(testDataPath, dbName, Sink::Storage::DataStore::ReadWrite));
74 74
75 const char *keyPrefix = "key"; 75 const char *keyPrefix = "key";
76 76
@@ -78,12 +78,12 @@ private slots:
78 time.start(); 78 time.start();
79 // Test db write time 79 // Test db write time
80 { 80 {
81 auto transaction = store->createTransaction(Sink::Storage::ReadWrite); 81 auto transaction = store->createTransaction(Sink::Storage::DataStore::ReadWrite);
82 for (int i = 0; i < count; i++) { 82 for (int i = 0; i < count; i++) {
83 transaction.openDatabase().write(keyPrefix + QByteArray::number(i), event); 83 transaction.openDatabase().write(keyPrefix + QByteArray::number(i), event);
84 if ((i % 10000) == 0) { 84 if ((i % 10000) == 0) {
85 transaction.commit(); 85 transaction.commit();
86 transaction = store->createTransaction(Sink::Storage::ReadWrite); 86 transaction = store->createTransaction(Sink::Storage::DataStore::ReadWrite);
87 } 87 }
88 } 88 }
89 transaction.commit(); 89 transaction.commit();
@@ -105,7 +105,7 @@ private slots:
105 105
106 // Db read time 106 // Db read time
107 { 107 {
108 auto transaction = store->createTransaction(Sink::Storage::ReadOnly); 108 auto transaction = store->createTransaction(Sink::Storage::DataStore::ReadOnly);
109 auto db = transaction.openDatabase(); 109 auto db = transaction.openDatabase();
110 for (int i = 0; i < count; i++) { 110 for (int i = 0; i < count; i++) {
111 db.scan(keyPrefix + QByteArray::number(i), [](const QByteArray &key, const QByteArray &value) -> bool { return true; }); 111 db.scan(keyPrefix + QByteArray::number(i), [](const QByteArray &key, const QByteArray &value) -> bool { return true; });
@@ -126,7 +126,7 @@ private slots:
126 126
127 void testSizes() 127 void testSizes()
128 { 128 {
129 Sink::Storage store(testDataPath, dbName); 129 Sink::Storage::DataStore store(testDataPath, dbName);
130 qDebug() << "Database size [kb]: " << store.diskUsage() / 1024; 130 qDebug() << "Database size [kb]: " << store.diskUsage() / 1024;
131 131
132 QFileInfo fileInfo(filePath); 132 QFileInfo fileInfo(filePath);
@@ -135,11 +135,11 @@ private slots:
135 135
136 void testScan() 136 void testScan()
137 { 137 {
138 QScopedPointer<Sink::Storage> store(new Sink::Storage(testDataPath, dbName, Sink::Storage::ReadOnly)); 138 QScopedPointer<Sink::Storage::DataStore> store(new Sink::Storage::DataStore(testDataPath, dbName, Sink::Storage::DataStore::ReadOnly));
139 139
140 QBENCHMARK { 140 QBENCHMARK {
141 int hit = 0; 141 int hit = 0;
142 store->createTransaction(Sink::Storage::ReadOnly) 142 store->createTransaction(Sink::Storage::DataStore::ReadOnly)
143 .openDatabase() 143 .openDatabase()
144 .scan("", [&](const QByteArray &key, const QByteArray &value) -> bool { 144 .scan("", [&](const QByteArray &key, const QByteArray &value) -> bool {
145 if (key == "key10000") { 145 if (key == "key10000") {
@@ -154,8 +154,8 @@ private slots:
154 154
155 void testKeyLookup() 155 void testKeyLookup()
156 { 156 {
157 QScopedPointer<Sink::Storage> store(new Sink::Storage(testDataPath, dbName, Sink::Storage::ReadOnly)); 157 QScopedPointer<Sink::Storage::DataStore> store(new Sink::Storage::DataStore(testDataPath, dbName, Sink::Storage::DataStore::ReadOnly));
158 auto transaction = store->createTransaction(Sink::Storage::ReadOnly); 158 auto transaction = store->createTransaction(Sink::Storage::DataStore::ReadOnly);
159 auto db = transaction.openDatabase(); 159 auto db = transaction.openDatabase();
160 160
161 QBENCHMARK { 161 QBENCHMARK {
@@ -170,8 +170,8 @@ private slots:
170 170
171 void testFindLatest() 171 void testFindLatest()
172 { 172 {
173 QScopedPointer<Sink::Storage> store(new Sink::Storage(testDataPath, dbName, Sink::Storage::ReadOnly)); 173 QScopedPointer<Sink::Storage::DataStore> store(new Sink::Storage::DataStore(testDataPath, dbName, Sink::Storage::DataStore::ReadOnly));
174 auto transaction = store->createTransaction(Sink::Storage::ReadOnly); 174 auto transaction = store->createTransaction(Sink::Storage::DataStore::ReadOnly);
175 auto db = transaction.openDatabase(); 175 auto db = transaction.openDatabase();
176 176
177 QBENCHMARK { 177 QBENCHMARK {
diff --git a/tests/storagetest.cpp b/tests/storagetest.cpp
index aa12ec1..5a517c7 100644
--- a/tests/storagetest.cpp
+++ b/tests/storagetest.cpp
@@ -21,14 +21,14 @@ private:
21 21
22 void populate(int count) 22 void populate(int count)
23 { 23 {
24 Sink::Storage storage(testDataPath, dbName, Sink::Storage::ReadWrite); 24 Sink::Storage::DataStore storage(testDataPath, dbName, Sink::Storage::DataStore::ReadWrite);
25 auto transaction = storage.createTransaction(Sink::Storage::ReadWrite); 25 auto transaction = storage.createTransaction(Sink::Storage::DataStore::ReadWrite);
26 for (int i = 0; i < count; i++) { 26 for (int i = 0; i < count; i++) {
27 // This should perhaps become an implementation detail of the db? 27 // This should perhaps become an implementation detail of the db?
28 if (i % 10000 == 0) { 28 if (i % 10000 == 0) {
29 if (i > 0) { 29 if (i > 0) {
30 transaction.commit(); 30 transaction.commit();
31 transaction = storage.createTransaction(Sink::Storage::ReadWrite); 31 transaction = storage.createTransaction(Sink::Storage::DataStore::ReadWrite);
32 } 32 }
33 } 33 }
34 transaction.openDatabase().write(keyPrefix + QByteArray::number(i), keyPrefix + QByteArray::number(i)); 34 transaction.openDatabase().write(keyPrefix + QByteArray::number(i), keyPrefix + QByteArray::number(i));
@@ -36,12 +36,12 @@ private:
36 transaction.commit(); 36 transaction.commit();
37 } 37 }
38 38
39 bool verify(Sink::Storage &storage, int i) 39 bool verify(Sink::Storage::DataStore &storage, int i)
40 { 40 {
41 bool success = true; 41 bool success = true;
42 bool keyMatch = true; 42 bool keyMatch = true;
43 const auto reference = keyPrefix + QByteArray::number(i); 43 const auto reference = keyPrefix + QByteArray::number(i);
44 storage.createTransaction(Sink::Storage::ReadOnly) 44 storage.createTransaction(Sink::Storage::DataStore::ReadOnly)
45 .openDatabase() 45 .openDatabase()
46 .scan(keyPrefix + QByteArray::number(i), 46 .scan(keyPrefix + QByteArray::number(i),
47 [&keyMatch, &reference](const QByteArray &key, const QByteArray &value) -> bool { 47 [&keyMatch, &reference](const QByteArray &key, const QByteArray &value) -> bool {
@@ -51,7 +51,7 @@ private:
51 } 51 }
52 return keyMatch; 52 return keyMatch;
53 }, 53 },
54 [&success](const Sink::Storage::Error &error) { 54 [&success](const Sink::Storage::DataStore::Error &error) {
55 qDebug() << error.message; 55 qDebug() << error.message;
56 success = false; 56 success = false;
57 }); 57 });
@@ -63,20 +63,20 @@ private slots:
63 { 63 {
64 testDataPath = "./testdb"; 64 testDataPath = "./testdb";
65 dbName = "test"; 65 dbName = "test";
66 Sink::Storage storage(testDataPath, dbName); 66 Sink::Storage::DataStore storage(testDataPath, dbName);
67 storage.removeFromDisk(); 67 storage.removeFromDisk();
68 } 68 }
69 69
70 void cleanup() 70 void cleanup()
71 { 71 {
72 Sink::Storage storage(testDataPath, dbName); 72 Sink::Storage::DataStore storage(testDataPath, dbName);
73 storage.removeFromDisk(); 73 storage.removeFromDisk();
74 } 74 }
75 75
76 void testCleanup() 76 void testCleanup()
77 { 77 {
78 populate(1); 78 populate(1);
79 Sink::Storage storage(testDataPath, dbName); 79 Sink::Storage::DataStore storage(testDataPath, dbName);
80 storage.removeFromDisk(); 80 storage.removeFromDisk();
81 QFileInfo info(testDataPath + "/" + dbName); 81 QFileInfo info(testDataPath + "/" + dbName);
82 QVERIFY(!info.exists()); 82 QVERIFY(!info.exists());
@@ -90,7 +90,7 @@ private slots:
90 90
91 // ensure we can read everything back correctly 91 // ensure we can read everything back correctly
92 { 92 {
93 Sink::Storage storage(testDataPath, dbName); 93 Sink::Storage::DataStore storage(testDataPath, dbName);
94 for (int i = 0; i < count; i++) { 94 for (int i = 0; i < count; i++) {
95 QVERIFY(verify(storage, i)); 95 QVERIFY(verify(storage, i));
96 } 96 }
@@ -105,8 +105,8 @@ private slots:
105 // ensure we can scan for values 105 // ensure we can scan for values
106 { 106 {
107 int hit = 0; 107 int hit = 0;
108 Sink::Storage store(testDataPath, dbName); 108 Sink::Storage::DataStore store(testDataPath, dbName);
109 store.createTransaction(Sink::Storage::ReadOnly) 109 store.createTransaction(Sink::Storage::DataStore::ReadOnly)
110 .openDatabase() 110 .openDatabase()
111 .scan("", [&](const QByteArray &key, const QByteArray &value) -> bool { 111 .scan("", [&](const QByteArray &key, const QByteArray &value) -> bool {
112 if (key == "key50") { 112 if (key == "key50") {
@@ -121,8 +121,8 @@ private slots:
121 { 121 {
122 int hit = 0; 122 int hit = 0;
123 bool foundInvalidValue = false; 123 bool foundInvalidValue = false;
124 Sink::Storage store(testDataPath, dbName); 124 Sink::Storage::DataStore store(testDataPath, dbName);
125 store.createTransaction(Sink::Storage::ReadOnly) 125 store.createTransaction(Sink::Storage::DataStore::ReadOnly)
126 .openDatabase() 126 .openDatabase()
127 .scan("key50", [&](const QByteArray &key, const QByteArray &value) -> bool { 127 .scan("key50", [&](const QByteArray &key, const QByteArray &value) -> bool {
128 if (key != "key50") { 128 if (key != "key50") {
@@ -139,10 +139,10 @@ private slots:
139 void testNestedOperations() 139 void testNestedOperations()
140 { 140 {
141 populate(3); 141 populate(3);
142 Sink::Storage store(testDataPath, dbName, Sink::Storage::ReadWrite); 142 Sink::Storage::DataStore store(testDataPath, dbName, Sink::Storage::DataStore::ReadWrite);
143 auto transaction = store.createTransaction(Sink::Storage::ReadWrite); 143 auto transaction = store.createTransaction(Sink::Storage::DataStore::ReadWrite);
144 transaction.openDatabase().scan("key1", [&](const QByteArray &key, const QByteArray &value) -> bool { 144 transaction.openDatabase().scan("key1", [&](const QByteArray &key, const QByteArray &value) -> bool {
145 transaction.openDatabase().remove(key, [](const Sink::Storage::Error &) { QVERIFY(false); }); 145 transaction.openDatabase().remove(key, [](const Sink::Storage::DataStore::Error &) { QVERIFY(false); });
146 return false; 146 return false;
147 }); 147 });
148 } 148 }
@@ -150,11 +150,11 @@ private slots:
150 void testNestedTransactions() 150 void testNestedTransactions()
151 { 151 {
152 populate(3); 152 populate(3);
153 Sink::Storage store(testDataPath, dbName, Sink::Storage::ReadWrite); 153 Sink::Storage::DataStore store(testDataPath, dbName, Sink::Storage::DataStore::ReadWrite);
154 store.createTransaction(Sink::Storage::ReadOnly) 154 store.createTransaction(Sink::Storage::DataStore::ReadOnly)
155 .openDatabase() 155 .openDatabase()
156 .scan("key1", [&](const QByteArray &key, const QByteArray &value) -> bool { 156 .scan("key1", [&](const QByteArray &key, const QByteArray &value) -> bool {
157 store.createTransaction(Sink::Storage::ReadWrite).openDatabase().remove(key, [](const Sink::Storage::Error &) { QVERIFY(false); }); 157 store.createTransaction(Sink::Storage::DataStore::ReadWrite).openDatabase().remove(key, [](const Sink::Storage::DataStore::Error &) { QVERIFY(false); });
158 return false; 158 return false;
159 }); 159 });
160 } 160 }
@@ -163,9 +163,9 @@ private slots:
163 { 163 {
164 bool gotResult = false; 164 bool gotResult = false;
165 bool gotError = false; 165 bool gotError = false;
166 Sink::Storage store(testDataPath, dbName, Sink::Storage::ReadWrite); 166 Sink::Storage::DataStore store(testDataPath, dbName, Sink::Storage::DataStore::ReadWrite);
167 auto transaction = store.createTransaction(Sink::Storage::ReadOnly); 167 auto transaction = store.createTransaction(Sink::Storage::DataStore::ReadOnly);
168 auto db = transaction.openDatabase("default", [&](const Sink::Storage::Error &error) { 168 auto db = transaction.openDatabase("default", [&](const Sink::Storage::DataStore::Error &error) {
169 qDebug() << error.message; 169 qDebug() << error.message;
170 gotError = true; 170 gotError = true;
171 }); 171 });
@@ -174,7 +174,7 @@ private slots:
174 gotResult = true; 174 gotResult = true;
175 return false; 175 return false;
176 }, 176 },
177 [&](const Sink::Storage::Error &error) { 177 [&](const Sink::Storage::DataStore::Error &error) {
178 qDebug() << error.message; 178 qDebug() << error.message;
179 gotError = true; 179 gotError = true;
180 }); 180 });
@@ -199,8 +199,8 @@ private slots:
199 const int concurrencyLevel = 20; 199 const int concurrencyLevel = 20;
200 for (int num = 0; num < concurrencyLevel; num++) { 200 for (int num = 0; num < concurrencyLevel; num++) {
201 futures << QtConcurrent::run([this, count, &error]() { 201 futures << QtConcurrent::run([this, count, &error]() {
202 Sink::Storage storage(testDataPath, dbName, Sink::Storage::ReadOnly); 202 Sink::Storage::DataStore storage(testDataPath, dbName, Sink::Storage::DataStore::ReadOnly);
203 Sink::Storage storage2(testDataPath, dbName + "2", Sink::Storage::ReadOnly); 203 Sink::Storage::DataStore storage2(testDataPath, dbName + "2", Sink::Storage::DataStore::ReadOnly);
204 for (int i = 0; i < count; i++) { 204 for (int i = 0; i < count; i++) {
205 if (!verify(storage, i)) { 205 if (!verify(storage, i)) {
206 error = true; 206 error = true;
@@ -216,9 +216,9 @@ private slots:
216 } 216 }
217 217
218 { 218 {
219 Sink::Storage storage(testDataPath, dbName); 219 Sink::Storage::DataStore storage(testDataPath, dbName);
220 storage.removeFromDisk(); 220 storage.removeFromDisk();
221 Sink::Storage storage2(testDataPath, dbName + "2"); 221 Sink::Storage::DataStore storage2(testDataPath, dbName + "2");
222 storage2.removeFromDisk(); 222 storage2.removeFromDisk();
223 } 223 }
224 } 224 }
@@ -227,8 +227,8 @@ private slots:
227 { 227 {
228 bool gotResult = false; 228 bool gotResult = false;
229 bool gotError = false; 229 bool gotError = false;
230 Sink::Storage store(testDataPath, dbName, Sink::Storage::ReadWrite); 230 Sink::Storage::DataStore store(testDataPath, dbName, Sink::Storage::DataStore::ReadWrite);
231 auto transaction = store.createTransaction(Sink::Storage::ReadWrite); 231 auto transaction = store.createTransaction(Sink::Storage::DataStore::ReadWrite);
232 auto db = transaction.openDatabase("default", nullptr, false); 232 auto db = transaction.openDatabase("default", nullptr, false);
233 db.write("key", "value"); 233 db.write("key", "value");
234 db.write("key", "value"); 234 db.write("key", "value");
@@ -238,7 +238,7 @@ private slots:
238 gotResult = true; 238 gotResult = true;
239 return true; 239 return true;
240 }, 240 },
241 [&](const Sink::Storage::Error &error) { 241 [&](const Sink::Storage::DataStore::Error &error) {
242 qDebug() << error.message; 242 qDebug() << error.message;
243 gotError = true; 243 gotError = true;
244 }); 244 });
@@ -252,8 +252,8 @@ private slots:
252 { 252 {
253 bool gotResult = false; 253 bool gotResult = false;
254 bool gotError = false; 254 bool gotError = false;
255 Sink::Storage store(testDataPath, dbName, Sink::Storage::ReadWrite); 255 Sink::Storage::DataStore store(testDataPath, dbName, Sink::Storage::DataStore::ReadWrite);
256 auto transaction = store.createTransaction(Sink::Storage::ReadWrite); 256 auto transaction = store.createTransaction(Sink::Storage::DataStore::ReadWrite);
257 auto db = transaction.openDatabase("default", nullptr, true); 257 auto db = transaction.openDatabase("default", nullptr, true);
258 db.write("key", "value1"); 258 db.write("key", "value1");
259 db.write("key", "value2"); 259 db.write("key", "value2");
@@ -262,7 +262,7 @@ private slots:
262 gotResult = true; 262 gotResult = true;
263 return true; 263 return true;
264 }, 264 },
265 [&](const Sink::Storage::Error &error) { 265 [&](const Sink::Storage::DataStore::Error &error) {
266 qDebug() << error.message; 266 qDebug() << error.message;
267 gotError = true; 267 gotError = true;
268 }); 268 });
@@ -275,15 +275,15 @@ private slots:
275 { 275 {
276 bool gotResult = false; 276 bool gotResult = false;
277 bool gotError = false; 277 bool gotError = false;
278 Sink::Storage store(testDataPath, dbName, Sink::Storage::ReadOnly); 278 Sink::Storage::DataStore store(testDataPath, dbName, Sink::Storage::DataStore::ReadOnly);
279 int numValues = store.createTransaction(Sink::Storage::ReadOnly) 279 int numValues = store.createTransaction(Sink::Storage::DataStore::ReadOnly)
280 .openDatabase("test") 280 .openDatabase("test")
281 .scan("", 281 .scan("",
282 [&](const QByteArray &key, const QByteArray &value) -> bool { 282 [&](const QByteArray &key, const QByteArray &value) -> bool {
283 gotResult = true; 283 gotResult = true;
284 return false; 284 return false;
285 }, 285 },
286 [&](const Sink::Storage::Error &error) { 286 [&](const Sink::Storage::DataStore::Error &error) {
287 qDebug() << error.message; 287 qDebug() << error.message;
288 gotError = true; 288 gotError = true;
289 }); 289 });
@@ -295,10 +295,10 @@ private slots:
295 void testWriteToNamedDb() 295 void testWriteToNamedDb()
296 { 296 {
297 bool gotError = false; 297 bool gotError = false;
298 Sink::Storage store(testDataPath, dbName, Sink::Storage::ReadWrite); 298 Sink::Storage::DataStore store(testDataPath, dbName, Sink::Storage::DataStore::ReadWrite);
299 store.createTransaction(Sink::Storage::ReadWrite) 299 store.createTransaction(Sink::Storage::DataStore::ReadWrite)
300 .openDatabase("test") 300 .openDatabase("test")
301 .write("key1", "value1", [&](const Sink::Storage::Error &error) { 301 .write("key1", "value1", [&](const Sink::Storage::DataStore::Error &error) {
302 qDebug() << error.message; 302 qDebug() << error.message;
303 gotError = true; 303 gotError = true;
304 }); 304 });
@@ -308,10 +308,10 @@ private slots:
308 void testWriteDuplicatesToNamedDb() 308 void testWriteDuplicatesToNamedDb()
309 { 309 {
310 bool gotError = false; 310 bool gotError = false;
311 Sink::Storage store(testDataPath, dbName, Sink::Storage::ReadWrite); 311 Sink::Storage::DataStore store(testDataPath, dbName, Sink::Storage::DataStore::ReadWrite);
312 store.createTransaction(Sink::Storage::ReadWrite) 312 store.createTransaction(Sink::Storage::DataStore::ReadWrite)
313 .openDatabase("test", nullptr, true) 313 .openDatabase("test", nullptr, true)
314 .write("key1", "value1", [&](const Sink::Storage::Error &error) { 314 .write("key1", "value1", [&](const Sink::Storage::DataStore::Error &error) {
315 qDebug() << error.message; 315 qDebug() << error.message;
316 gotError = true; 316 gotError = true;
317 }); 317 });
@@ -321,8 +321,8 @@ private slots:
321 // By default we want only exact matches 321 // By default we want only exact matches
322 void testSubstringKeys() 322 void testSubstringKeys()
323 { 323 {
324 Sink::Storage store(testDataPath, dbName, Sink::Storage::ReadWrite); 324 Sink::Storage::DataStore store(testDataPath, dbName, Sink::Storage::DataStore::ReadWrite);
325 auto transaction = store.createTransaction(Sink::Storage::ReadWrite); 325 auto transaction = store.createTransaction(Sink::Storage::DataStore::ReadWrite);
326 auto db = transaction.openDatabase("test", nullptr, true); 326 auto db = transaction.openDatabase("test", nullptr, true);
327 db.write("sub", "value1"); 327 db.write("sub", "value1");
328 db.write("subsub", "value2"); 328 db.write("subsub", "value2");
@@ -333,8 +333,8 @@ private slots:
333 333
334 void testFindSubstringKeys() 334 void testFindSubstringKeys()
335 { 335 {
336 Sink::Storage store(testDataPath, dbName, Sink::Storage::ReadWrite); 336 Sink::Storage::DataStore store(testDataPath, dbName, Sink::Storage::DataStore::ReadWrite);
337 auto transaction = store.createTransaction(Sink::Storage::ReadWrite); 337 auto transaction = store.createTransaction(Sink::Storage::DataStore::ReadWrite);
338 auto db = transaction.openDatabase("test", nullptr, false); 338 auto db = transaction.openDatabase("test", nullptr, false);
339 db.write("sub", "value1"); 339 db.write("sub", "value1");
340 db.write("subsub", "value2"); 340 db.write("subsub", "value2");
@@ -346,8 +346,8 @@ private slots:
346 346
347 void testFindSubstringKeysWithDuplicatesEnabled() 347 void testFindSubstringKeysWithDuplicatesEnabled()
348 { 348 {
349 Sink::Storage store(testDataPath, dbName, Sink::Storage::ReadWrite); 349 Sink::Storage::DataStore store(testDataPath, dbName, Sink::Storage::DataStore::ReadWrite);
350 auto transaction = store.createTransaction(Sink::Storage::ReadWrite); 350 auto transaction = store.createTransaction(Sink::Storage::DataStore::ReadWrite);
351 auto db = transaction.openDatabase("test", nullptr, true); 351 auto db = transaction.openDatabase("test", nullptr, true);
352 db.write("sub", "value1"); 352 db.write("sub", "value1");
353 db.write("subsub", "value2"); 353 db.write("subsub", "value2");
@@ -359,8 +359,8 @@ private slots:
359 359
360 void testKeySorting() 360 void testKeySorting()
361 { 361 {
362 Sink::Storage store(testDataPath, dbName, Sink::Storage::ReadWrite); 362 Sink::Storage::DataStore store(testDataPath, dbName, Sink::Storage::DataStore::ReadWrite);
363 auto transaction = store.createTransaction(Sink::Storage::ReadWrite); 363 auto transaction = store.createTransaction(Sink::Storage::DataStore::ReadWrite);
364 auto db = transaction.openDatabase("test", nullptr, false); 364 auto db = transaction.openDatabase("test", nullptr, false);
365 db.write("sub_2", "value2"); 365 db.write("sub_2", "value2");
366 db.write("sub_1", "value1"); 366 db.write("sub_1", "value1");
@@ -380,8 +380,8 @@ private slots:
380 // Ensure we don't retrieve a key that is greater than the current key. We only want equal keys. 380 // Ensure we don't retrieve a key that is greater than the current key. We only want equal keys.
381 void testKeyRange() 381 void testKeyRange()
382 { 382 {
383 Sink::Storage store(testDataPath, dbName, Sink::Storage::ReadWrite); 383 Sink::Storage::DataStore store(testDataPath, dbName, Sink::Storage::DataStore::ReadWrite);
384 auto transaction = store.createTransaction(Sink::Storage::ReadWrite); 384 auto transaction = store.createTransaction(Sink::Storage::DataStore::ReadWrite);
385 auto db = transaction.openDatabase("test", nullptr, true); 385 auto db = transaction.openDatabase("test", nullptr, true);
386 db.write("sub1", "value1"); 386 db.write("sub1", "value1");
387 int numValues = db.scan("sub", [&](const QByteArray &key, const QByteArray &value) -> bool { return true; }); 387 int numValues = db.scan("sub", [&](const QByteArray &key, const QByteArray &value) -> bool { return true; });
@@ -391,8 +391,8 @@ private slots:
391 391
392 void testFindLatest() 392 void testFindLatest()
393 { 393 {
394 Sink::Storage store(testDataPath, dbName, Sink::Storage::ReadWrite); 394 Sink::Storage::DataStore store(testDataPath, dbName, Sink::Storage::DataStore::ReadWrite);
395 auto transaction = store.createTransaction(Sink::Storage::ReadWrite); 395 auto transaction = store.createTransaction(Sink::Storage::DataStore::ReadWrite);
396 auto db = transaction.openDatabase("test", nullptr, false); 396 auto db = transaction.openDatabase("test", nullptr, false);
397 db.write("sub1", "value1"); 397 db.write("sub1", "value1");
398 db.write("sub2", "value2"); 398 db.write("sub2", "value2");
@@ -406,8 +406,8 @@ private slots:
406 406
407 void testFindLatestInSingle() 407 void testFindLatestInSingle()
408 { 408 {
409 Sink::Storage store(testDataPath, dbName, Sink::Storage::ReadWrite); 409 Sink::Storage::DataStore store(testDataPath, dbName, Sink::Storage::DataStore::ReadWrite);
410 auto transaction = store.createTransaction(Sink::Storage::ReadWrite); 410 auto transaction = store.createTransaction(Sink::Storage::DataStore::ReadWrite);
411 auto db = transaction.openDatabase("test", nullptr, false); 411 auto db = transaction.openDatabase("test", nullptr, false);
412 db.write("sub2", "value2"); 412 db.write("sub2", "value2");
413 QByteArray result; 413 QByteArray result;
@@ -418,8 +418,8 @@ private slots:
418 418
419 void testFindLast() 419 void testFindLast()
420 { 420 {
421 Sink::Storage store(testDataPath, dbName, Sink::Storage::ReadWrite); 421 Sink::Storage::DataStore store(testDataPath, dbName, Sink::Storage::DataStore::ReadWrite);
422 auto transaction = store.createTransaction(Sink::Storage::ReadWrite); 422 auto transaction = store.createTransaction(Sink::Storage::DataStore::ReadWrite);
423 auto db = transaction.openDatabase("test", nullptr, false); 423 auto db = transaction.openDatabase("test", nullptr, false);
424 db.write("sub2", "value2"); 424 db.write("sub2", "value2");
425 db.write("wub3", "value3"); 425 db.write("wub3", "value3");
@@ -431,23 +431,23 @@ private slots:
431 431
432 void testRecordRevision() 432 void testRecordRevision()
433 { 433 {
434 Sink::Storage store(testDataPath, dbName, Sink::Storage::ReadWrite); 434 Sink::Storage::DataStore store(testDataPath, dbName, Sink::Storage::DataStore::ReadWrite);
435 auto transaction = store.createTransaction(Sink::Storage::ReadWrite); 435 auto transaction = store.createTransaction(Sink::Storage::DataStore::ReadWrite);
436 Sink::Storage::recordRevision(transaction, 1, "uid", "type"); 436 Sink::Storage::DataStore::recordRevision(transaction, 1, "uid", "type");
437 QCOMPARE(Sink::Storage::getTypeFromRevision(transaction, 1), QByteArray("type")); 437 QCOMPARE(Sink::Storage::DataStore::getTypeFromRevision(transaction, 1), QByteArray("type"));
438 QCOMPARE(Sink::Storage::getUidFromRevision(transaction, 1), QByteArray("uid")); 438 QCOMPARE(Sink::Storage::DataStore::getUidFromRevision(transaction, 1), QByteArray("uid"));
439 } 439 }
440 440
441 void testRecordRevisionSorting() 441 void testRecordRevisionSorting()
442 { 442 {
443 Sink::Storage store(testDataPath, dbName, Sink::Storage::ReadWrite); 443 Sink::Storage::DataStore store(testDataPath, dbName, Sink::Storage::DataStore::ReadWrite);
444 auto transaction = store.createTransaction(Sink::Storage::ReadWrite); 444 auto transaction = store.createTransaction(Sink::Storage::DataStore::ReadWrite);
445 QByteArray result; 445 QByteArray result;
446 auto db = transaction.openDatabase("test", nullptr, false); 446 auto db = transaction.openDatabase("test", nullptr, false);
447 const auto uid = "{c5d06a9f-1534-4c52-b8ea-415db68bdadf}"; 447 const auto uid = "{c5d06a9f-1534-4c52-b8ea-415db68bdadf}";
448 //Ensure we can sort 1 and 10 properly (by default string comparison 10 comes before 6) 448 //Ensure we can sort 1 and 10 properly (by default string comparison 10 comes before 6)
449 db.write(Sink::Storage::assembleKey(uid, 6), "value1"); 449 db.write(Sink::Storage::DataStore::assembleKey(uid, 6), "value1");
450 db.write(Sink::Storage::assembleKey(uid, 10), "value2"); 450 db.write(Sink::Storage::DataStore::assembleKey(uid, 10), "value2");
451 db.findLatest(uid, [&](const QByteArray &key, const QByteArray &value) { result = value; }); 451 db.findLatest(uid, [&](const QByteArray &key, const QByteArray &value) { result = value; });
452 QCOMPARE(result, QByteArray("value2")); 452 QCOMPARE(result, QByteArray("value2"));
453 } 453 }
diff --git a/tests/testimplementations.h b/tests/testimplementations.h
index d188c0c..cf7a3da 100644
--- a/tests/testimplementations.h
+++ b/tests/testimplementations.h
@@ -83,8 +83,8 @@ public slots:
83class TestResourceFacade : public Sink::GenericFacade<Sink::ApplicationDomain::Event> 83class TestResourceFacade : public Sink::GenericFacade<Sink::ApplicationDomain::Event>
84{ 84{
85public: 85public:
86 TestResourceFacade(const QByteArray &instanceIdentifier, const QSharedPointer<Sink::ResourceAccessInterface> resourceAccess) 86 TestResourceFacade(const Sink::ResourceContext &resourceContext)
87 : Sink::GenericFacade<Sink::ApplicationDomain::Event>(instanceIdentifier, QSharedPointer<TestEventAdaptorFactory>::create(), resourceAccess) 87 : Sink::GenericFacade<Sink::ApplicationDomain::Event>(resourceContext)
88 { 88 {
89 } 89 }
90 virtual ~TestResourceFacade() 90 virtual ~TestResourceFacade()
@@ -95,8 +95,8 @@ public:
95class TestMailResourceFacade : public Sink::GenericFacade<Sink::ApplicationDomain::Mail> 95class TestMailResourceFacade : public Sink::GenericFacade<Sink::ApplicationDomain::Mail>
96{ 96{
97public: 97public:
98 TestMailResourceFacade(const QByteArray &instanceIdentifier, const QSharedPointer<Sink::ResourceAccessInterface> resourceAccess) 98 TestMailResourceFacade(const Sink::ResourceContext &resourceContext)
99 : Sink::GenericFacade<Sink::ApplicationDomain::Mail>(instanceIdentifier, QSharedPointer<TestMailAdaptorFactory>::create(), resourceAccess) 99 : Sink::GenericFacade<Sink::ApplicationDomain::Mail>(resourceContext)
100 { 100 {
101 } 101 }
102 virtual ~TestMailResourceFacade() 102 virtual ~TestMailResourceFacade()
@@ -107,7 +107,7 @@ public:
107class TestResource : public Sink::GenericResource 107class TestResource : public Sink::GenericResource
108{ 108{
109public: 109public:
110 TestResource(const QByteArray &instanceIdentifier, QSharedPointer<Sink::Pipeline> pipeline) : Sink::GenericResource("test", instanceIdentifier, pipeline) 110 TestResource(const Sink::ResourceContext &resourceContext, QSharedPointer<Sink::Pipeline> pipeline) : Sink::GenericResource(resourceContext, pipeline)
111 { 111 {
112 } 112 }
113 113