From 1acf9f3c486813df807ff6931e56cc13eb26eeaf Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Sun, 23 Aug 2015 18:56:43 +0200 Subject: 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. --- common/domain/event.cpp | 8 ++++---- common/domain/event.h | 6 ++++-- 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'common/domain') diff --git a/common/domain/event.cpp b/common/domain/event.cpp index 15f5d11..e107441 100644 --- a/common/domain/event.cpp +++ b/common/domain/event.cpp @@ -34,11 +34,11 @@ using namespace Akonadi2::ApplicationDomain; -ResultSet TypeImplementation::queryIndexes(const Akonadi2::Query &query, const QByteArray &resourceInstanceIdentifier, QSet &appliedFilters) +ResultSet TypeImplementation::queryIndexes(const Akonadi2::Query &query, const QByteArray &resourceInstanceIdentifier, QSet &appliedFilters, Akonadi2::Storage::Transaction &transaction) { QVector keys; if (query.propertyFilter.contains("uid")) { - Index uidIndex(Akonadi2::storageLocation(), resourceInstanceIdentifier + ".index.uid", Akonadi2::Storage::ReadOnly); + Index uidIndex("index.uid", transaction); uidIndex.lookup(query.propertyFilter.value("uid").toByteArray(), [&](const QByteArray &value) { keys << value; }, @@ -50,11 +50,11 @@ ResultSet TypeImplementation::queryIndexes(const Akonadi2::Query &query, return ResultSet(keys); } -void TypeImplementation::index(const Event &type) +void TypeImplementation::index(const Event &type, Akonadi2::Storage::Transaction &transaction) { - Index uidIndex(Akonadi2::storageLocation(), type.resourceInstanceIdentifier() + ".index.uid", Akonadi2::Storage::ReadWrite); const auto uid = type.getProperty("uid"); if (uid.isValid()) { + Index uidIndex("index.uid", transaction); uidIndex.add(uid.toByteArray(), type.identifier()); } } diff --git a/common/domain/event.h b/common/domain/event.h index 13cfc6e..f21cd34 100644 --- a/common/domain/event.h +++ b/common/domain/event.h @@ -20,6 +20,8 @@ #include "applicationdomaintype.h" +#include "storage.h" + class ResultSet; class QByteArray; @@ -53,8 +55,8 @@ public: * * An empty result set indicates that a full scan is required. */ - static ResultSet queryIndexes(const Akonadi2::Query &query, const QByteArray &resourceInstanceIdentifier, QSet &appliedFilters); - static void index(const Event &type); + static ResultSet queryIndexes(const Akonadi2::Query &query, const QByteArray &resourceInstanceIdentifier, QSet &appliedFilters, Akonadi2::Storage::Transaction &transaction); + static void index(const Event &type, Akonadi2::Storage::Transaction &transaction); static QSharedPointer > initializeReadPropertyMapper(); static QSharedPointer > initializeWritePropertyMapper(); }; -- cgit v1.2.3