summaryrefslogtreecommitdiffstats
path: root/examples/dummyresource/resourcefactory.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2015-08-23 18:56:43 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2015-08-23 18:56:43 +0200
commit1acf9f3c486813df807ff6931e56cc13eb26eeaf (patch)
tree559ead2e95986515b4a5f93b6f143b8f1d429bd3 /examples/dummyresource/resourcefactory.cpp
parent62e7084dcd6f53275fcb21ba17e880e41b40094d (diff)
downloadsink-1acf9f3c486813df807ff6931e56cc13eb26eeaf.tar.gz
sink-1acf9f3c486813df807ff6931e56cc13eb26eeaf.zip
Store indexes as named databases in the same db.
Because we also keep using the same transactions this finally makes the resource somewhat performant. On my system genericresourcebenchmark now processes ~4200 messages per second instead of ~280.
Diffstat (limited to 'examples/dummyresource/resourcefactory.cpp')
-rw-r--r--examples/dummyresource/resourcefactory.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/examples/dummyresource/resourcefactory.cpp b/examples/dummyresource/resourcefactory.cpp
index e029308..0e18282 100644
--- a/examples/dummyresource/resourcefactory.cpp
+++ b/examples/dummyresource/resourcefactory.cpp
@@ -42,13 +42,13 @@ DummyResource::DummyResource(const QByteArray &instanceIdentifier, const QShared
42{ 42{
43 auto eventFactory = QSharedPointer<DummyEventAdaptorFactory>::create(); 43 auto eventFactory = QSharedPointer<DummyEventAdaptorFactory>::create();
44 const auto resourceIdentifier = mResourceInstanceIdentifier; 44 const auto resourceIdentifier = mResourceInstanceIdentifier;
45 auto eventIndexer = new Akonadi2::SimpleProcessor("eventIndexer", [eventFactory, resourceIdentifier](const Akonadi2::PipelineState &state, const Akonadi2::Entity &entity) { 45 auto eventIndexer = new Akonadi2::SimpleProcessor("eventIndexer", [eventFactory, resourceIdentifier](const Akonadi2::PipelineState &state, const Akonadi2::Entity &entity, Akonadi2::Storage::Transaction &transaction) {
46 auto adaptor = eventFactory->createAdaptor(entity); 46 auto adaptor = eventFactory->createAdaptor(entity);
47 //FIXME set revision? 47 //FIXME set revision?
48 Akonadi2::ApplicationDomain::Event event(resourceIdentifier, state.key(), -1, adaptor); 48 Akonadi2::ApplicationDomain::Event event(resourceIdentifier, state.key(), -1, adaptor);
49 Akonadi2::ApplicationDomain::TypeImplementation<Akonadi2::ApplicationDomain::Event>::index(event); 49 Akonadi2::ApplicationDomain::TypeImplementation<Akonadi2::ApplicationDomain::Event>::index(event, transaction);
50 50
51 Index ridIndex(Akonadi2::storageLocation(), resourceIdentifier + ".index.rid", Akonadi2::Storage::ReadWrite); 51 Index ridIndex("index.rid", transaction);
52 const auto rid = event.getProperty("remoteId"); 52 const auto rid = event.getProperty("remoteId");
53 if (rid.isValid()) { 53 if (rid.isValid()) {
54 ridIndex.add(rid.toByteArray(), event.identifier()); 54 ridIndex.add(rid.toByteArray(), event.identifier());
@@ -63,8 +63,8 @@ DummyResource::DummyResource(const QByteArray &instanceIdentifier, const QShared
63KAsync::Job<void> DummyResource::synchronizeWithSource() 63KAsync::Job<void> DummyResource::synchronizeWithSource()
64{ 64{
65 return KAsync::start<void>([this](KAsync::Future<void> &f) { 65 return KAsync::start<void>([this](KAsync::Future<void> &f) {
66 //TODO start transaction on index 66 auto transaction = Akonadi2::Storage(Akonadi2::storageLocation(), mResourceInstanceIdentifier + ".index.uid", Akonadi2::Storage::ReadOnly).createTransaction(Akonadi2::Storage::ReadOnly);
67 Index uidIndex(Akonadi2::storageLocation(), mResourceInstanceIdentifier + ".index.uid", Akonadi2::Storage::ReadOnly); 67 Index uidIndex("index.uid", transaction);
68 68
69 const auto data = DummyStore::instance().data(); 69 const auto data = DummyStore::instance().data();
70 for (auto it = data.constBegin(); it != data.constEnd(); it++) { 70 for (auto it = data.constBegin(); it != data.constEnd(); it++) {