diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-02-19 10:08:27 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-02-19 10:08:27 +0100 |
commit | a4cf8be92253d1696a8907da85b1b6a8f5d4ad05 (patch) | |
tree | 215d0063cbd034febcca4d4143e88f049f1317a2 /common/queryrunner.cpp | |
parent | 38f13f5ce6e66a6f3c57e2e2bf8e945a57813ff4 (diff) | |
download | sink-a4cf8be92253d1696a8907da85b1b6a8f5d4ad05.tar.gz sink-a4cf8be92253d1696a8907da85b1b6a8f5d4ad05.zip |
Actually avoid superfluous readEntity calls.
We still read all values, but just reported the ones before the limit.
With this we query 1000 out of 50k values in 63ms.
Diffstat (limited to 'common/queryrunner.cpp')
-rw-r--r-- | common/queryrunner.cpp | 52 |
1 files changed, 27 insertions, 25 deletions
diff --git a/common/queryrunner.cpp b/common/queryrunner.cpp index 4fab68d..1ef076e 100644 --- a/common/queryrunner.cpp +++ b/common/queryrunner.cpp | |||
@@ -180,34 +180,36 @@ QueryWorker<DomainType>::~QueryWorker() | |||
180 | template<class DomainType> | 180 | template<class DomainType> |
181 | void QueryWorker<DomainType>::replaySet(ResultSet &resultSet, Sink::ResultProviderInterface<typename DomainType::Ptr> &resultProvider, const QList<QByteArray> &properties, int offset, int batchSize) | 181 | void QueryWorker<DomainType>::replaySet(ResultSet &resultSet, Sink::ResultProviderInterface<typename DomainType::Ptr> &resultProvider, const QList<QByteArray> &properties, int offset, int batchSize) |
182 | { | 182 | { |
183 | int counter = 0; | 183 | Trace() << "Skipping over " << offset << " results"; |
184 | resultSet.skip(offset); | 184 | resultSet.skip(offset); |
185 | while (resultSet.next([this, &resultProvider, &counter, &properties, batchSize](const Sink::ApplicationDomain::ApplicationDomainType::Ptr &value, Sink::Operation operation) -> bool { | 185 | int counter; |
186 | //FIXME allow maildir resource to set the mimeMessage property | 186 | for (counter = 0; !batchSize || (counter < batchSize); counter++) { |
187 | auto valueCopy = Sink::ApplicationDomain::ApplicationDomainType::getInMemoryRepresentation<DomainType>(*value, properties).template staticCast<DomainType>(); | 187 | const bool ret = resultSet.next([this, &resultProvider, &counter, &properties, batchSize](const Sink::ApplicationDomain::ApplicationDomainType::Ptr &value, Sink::Operation operation) -> bool { |
188 | if (mResultTransformation) { | 188 | //FIXME allow maildir resource to set the mimeMessage property |
189 | mResultTransformation(*valueCopy); | 189 | auto valueCopy = Sink::ApplicationDomain::ApplicationDomainType::getInMemoryRepresentation<DomainType>(*value, properties).template staticCast<DomainType>(); |
190 | } | 190 | if (mResultTransformation) { |
191 | if (batchSize && counter >= batchSize) { | 191 | mResultTransformation(*valueCopy); |
192 | return false; | 192 | } |
193 | } | 193 | switch (operation) { |
194 | counter++; | 194 | case Sink::Operation_Creation: |
195 | switch (operation) { | 195 | // Trace() << "Got creation"; |
196 | case Sink::Operation_Creation: | 196 | resultProvider.add(valueCopy); |
197 | // Trace() << "Got creation"; | 197 | break; |
198 | resultProvider.add(valueCopy); | 198 | case Sink::Operation_Modification: |
199 | break; | 199 | // Trace() << "Got modification"; |
200 | case Sink::Operation_Modification: | 200 | resultProvider.modify(valueCopy); |
201 | // Trace() << "Got modification"; | 201 | break; |
202 | resultProvider.modify(valueCopy); | 202 | case Sink::Operation_Removal: |
203 | break; | 203 | // Trace() << "Got removal"; |
204 | case Sink::Operation_Removal: | 204 | resultProvider.remove(valueCopy); |
205 | // Trace() << "Got removal"; | 205 | break; |
206 | resultProvider.remove(valueCopy); | 206 | } |
207 | return true; | ||
208 | }); | ||
209 | if (!ret) { | ||
207 | break; | 210 | break; |
208 | } | 211 | } |
209 | return true; | 212 | }; |
210 | })){}; | ||
211 | Trace() << "Replayed " << counter << " results." << "Limit " << batchSize; | 213 | Trace() << "Replayed " << counter << " results." << "Limit " << batchSize; |
212 | } | 214 | } |
213 | 215 | ||