diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-12-22 10:42:37 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-12-22 10:42:37 +0100 |
commit | 31dbc0cba9e5acfaeca41679873b17e11ceab811 (patch) | |
tree | ceabdf4f92666d92c72e9382c8c0c80bed23b837 /common | |
parent | e5125013a2661b30f21323f1a3f925103e8d589f (diff) | |
download | sink-31dbc0cba9e5acfaeca41679873b17e11ceab811.tar.gz sink-31dbc0cba9e5acfaeca41679873b17e11ceab811.zip |
Only load the properties we need.
...and adjust the test accordingly with what we expect.
Diffstat (limited to 'common')
-rw-r--r-- | common/bufferadaptor.h | 12 | ||||
-rw-r--r-- | common/domain/applicationdomaintype.h | 5 | ||||
-rw-r--r-- | common/queryrunner.cpp | 12 | ||||
-rw-r--r-- | common/queryrunner.h | 2 |
4 files changed, 18 insertions, 13 deletions
diff --git a/common/bufferadaptor.h b/common/bufferadaptor.h index 121ef9d..aaff1c2 100644 --- a/common/bufferadaptor.h +++ b/common/bufferadaptor.h | |||
@@ -45,11 +45,17 @@ public: | |||
45 | { | 45 | { |
46 | } | 46 | } |
47 | 47 | ||
48 | MemoryBufferAdaptor(const BufferAdaptor &buffer) | 48 | MemoryBufferAdaptor(const BufferAdaptor &buffer, const QList<QByteArray> &properties) |
49 | : BufferAdaptor() | 49 | : BufferAdaptor() |
50 | { | 50 | { |
51 | for(const auto &property : buffer.availableProperties()) { | 51 | if (properties.isEmpty()) { |
52 | mValues.insert(property, buffer.getProperty(property)); | 52 | for(const auto &property : buffer.availableProperties()) { |
53 | mValues.insert(property, buffer.getProperty(property)); | ||
54 | } | ||
55 | } else { | ||
56 | for(const auto &property : properties) { | ||
57 | mValues.insert(property, buffer.getProperty(property)); | ||
58 | } | ||
53 | } | 59 | } |
54 | } | 60 | } |
55 | 61 | ||
diff --git a/common/domain/applicationdomaintype.h b/common/domain/applicationdomaintype.h index 227ab4d..cff0172 100644 --- a/common/domain/applicationdomaintype.h +++ b/common/domain/applicationdomaintype.h | |||
@@ -46,10 +46,9 @@ public: | |||
46 | ApplicationDomainType& operator=(const ApplicationDomainType &other); | 46 | ApplicationDomainType& operator=(const ApplicationDomainType &other); |
47 | 47 | ||
48 | template <typename DomainType> | 48 | template <typename DomainType> |
49 | static typename DomainType::Ptr getInMemoryRepresentation(const ApplicationDomainType &domainType) | 49 | static typename DomainType::Ptr getInMemoryRepresentation(const ApplicationDomainType &domainType, const QList<QByteArray> properties = QList<QByteArray>()) |
50 | { | 50 | { |
51 | //TODO only copy requested properties | 51 | auto memoryAdaptor = QSharedPointer<Akonadi2::ApplicationDomain::MemoryBufferAdaptor>::create(*(domainType.mAdaptor), properties); |
52 | auto memoryAdaptor = QSharedPointer<Akonadi2::ApplicationDomain::MemoryBufferAdaptor>::create(*(domainType.mAdaptor)); | ||
53 | //The identifier still internal refers to the memory-mapped pointer, we need to copy the memory or it will become invalid | 52 | //The identifier still internal refers to the memory-mapped pointer, we need to copy the memory or it will become invalid |
54 | return QSharedPointer<DomainType>::create(domainType.mResourceInstanceIdentifier, QByteArray(domainType.mIdentifier.constData(), domainType.mIdentifier.size()), domainType.mRevision, memoryAdaptor); | 53 | return QSharedPointer<DomainType>::create(domainType.mResourceInstanceIdentifier, QByteArray(domainType.mIdentifier.constData(), domainType.mIdentifier.size()), domainType.mRevision, memoryAdaptor); |
55 | } | 54 | } |
diff --git a/common/queryrunner.cpp b/common/queryrunner.cpp index 2de3c10..d3f5254 100644 --- a/common/queryrunner.cpp +++ b/common/queryrunner.cpp | |||
@@ -103,23 +103,23 @@ typename Akonadi2::ResultEmitter<typename DomainType::Ptr>::Ptr QueryRunner<Doma | |||
103 | } | 103 | } |
104 | 104 | ||
105 | template<class DomainType> | 105 | template<class DomainType> |
106 | void QueryRunner<DomainType>::replaySet(ResultSet &resultSet, Akonadi2::ResultProviderInterface<typename DomainType::Ptr> &resultProvider) | 106 | void QueryRunner<DomainType>::replaySet(ResultSet &resultSet, Akonadi2::ResultProviderInterface<typename DomainType::Ptr> &resultProvider, const QList<QByteArray> &properties) |
107 | { | 107 | { |
108 | int counter = 0; | 108 | int counter = 0; |
109 | while (resultSet.next([&resultProvider, &counter](const Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr &value, Akonadi2::Operation operation) -> bool { | 109 | while (resultSet.next([&resultProvider, &counter, &properties](const Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr &value, Akonadi2::Operation operation) -> bool { |
110 | counter++; | 110 | counter++; |
111 | switch (operation) { | 111 | switch (operation) { |
112 | case Akonadi2::Operation_Creation: | 112 | case Akonadi2::Operation_Creation: |
113 | // Trace() << "Got creation"; | 113 | // Trace() << "Got creation"; |
114 | resultProvider.add(Akonadi2::ApplicationDomain::ApplicationDomainType::getInMemoryRepresentation<DomainType>(*value).template staticCast<DomainType>()); | 114 | resultProvider.add(Akonadi2::ApplicationDomain::ApplicationDomainType::getInMemoryRepresentation<DomainType>(*value, properties).template staticCast<DomainType>()); |
115 | break; | 115 | break; |
116 | case Akonadi2::Operation_Modification: | 116 | case Akonadi2::Operation_Modification: |
117 | // Trace() << "Got modification"; | 117 | // Trace() << "Got modification"; |
118 | resultProvider.modify(Akonadi2::ApplicationDomain::ApplicationDomainType::getInMemoryRepresentation<DomainType>(*value).template staticCast<DomainType>()); | 118 | resultProvider.modify(Akonadi2::ApplicationDomain::ApplicationDomainType::getInMemoryRepresentation<DomainType>(*value, properties).template staticCast<DomainType>()); |
119 | break; | 119 | break; |
120 | case Akonadi2::Operation_Removal: | 120 | case Akonadi2::Operation_Removal: |
121 | // Trace() << "Got removal"; | 121 | // Trace() << "Got removal"; |
122 | resultProvider.remove(Akonadi2::ApplicationDomain::ApplicationDomainType::getInMemoryRepresentation<DomainType>(*value).template staticCast<DomainType>()); | 122 | resultProvider.remove(Akonadi2::ApplicationDomain::ApplicationDomainType::getInMemoryRepresentation<DomainType>(*value, properties).template staticCast<DomainType>()); |
123 | break; | 123 | break; |
124 | } | 124 | } |
125 | return true; | 125 | return true; |
@@ -263,7 +263,7 @@ qint64 QueryRunner<DomainType>::load(const Akonadi2::Query &query, const std::fu | |||
263 | QSet<QByteArray> remainingFilters; | 263 | QSet<QByteArray> remainingFilters; |
264 | auto resultSet = baseSetRetriever(transaction, remainingFilters); | 264 | auto resultSet = baseSetRetriever(transaction, remainingFilters); |
265 | auto filteredSet = filterSet(resultSet, getFilter(remainingFilters, query), db, initialQuery); | 265 | auto filteredSet = filterSet(resultSet, getFilter(remainingFilters, query), db, initialQuery); |
266 | replaySet(filteredSet, resultProvider); | 266 | replaySet(filteredSet, resultProvider, query.requestedProperties); |
267 | resultProvider.setRevision(Akonadi2::Storage::maxRevision(transaction)); | 267 | resultProvider.setRevision(Akonadi2::Storage::maxRevision(transaction)); |
268 | return Akonadi2::Storage::maxRevision(transaction); | 268 | return Akonadi2::Storage::maxRevision(transaction); |
269 | } | 269 | } |
diff --git a/common/queryrunner.h b/common/queryrunner.h index c918dcb..8df0ecd 100644 --- a/common/queryrunner.h +++ b/common/queryrunner.h | |||
@@ -84,7 +84,7 @@ public: | |||
84 | typename Akonadi2::ResultEmitter<typename DomainType::Ptr>::Ptr emitter(); | 84 | typename Akonadi2::ResultEmitter<typename DomainType::Ptr>::Ptr emitter(); |
85 | 85 | ||
86 | private: | 86 | private: |
87 | static void replaySet(ResultSet &resultSet, Akonadi2::ResultProviderInterface<typename DomainType::Ptr> &resultProvider); | 87 | static void replaySet(ResultSet &resultSet, Akonadi2::ResultProviderInterface<typename DomainType::Ptr> &resultProvider, const QList<QByteArray> &properties); |
88 | 88 | ||
89 | void readEntity(const Akonadi2::Storage::NamedDatabase &db, const QByteArray &key, const std::function<void(const Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr &, Akonadi2::Operation)> &resultCallback); | 89 | void readEntity(const Akonadi2::Storage::NamedDatabase &db, const QByteArray &key, const std::function<void(const Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr &, Akonadi2::Operation)> &resultCallback); |
90 | 90 | ||