From a4cf8be92253d1696a8907da85b1b6a8f5d4ad05 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Fri, 19 Feb 2016 10:08:27 +0100 Subject: 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. --- common/queryrunner.cpp | 52 ++++++++++++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 25 deletions(-) (limited to 'common/queryrunner.cpp') 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::~QueryWorker() template void QueryWorker::replaySet(ResultSet &resultSet, Sink::ResultProviderInterface &resultProvider, const QList &properties, int offset, int batchSize) { - int counter = 0; + Trace() << "Skipping over " << offset << " results"; resultSet.skip(offset); - while (resultSet.next([this, &resultProvider, &counter, &properties, batchSize](const Sink::ApplicationDomain::ApplicationDomainType::Ptr &value, Sink::Operation operation) -> bool { - //FIXME allow maildir resource to set the mimeMessage property - auto valueCopy = Sink::ApplicationDomain::ApplicationDomainType::getInMemoryRepresentation(*value, properties).template staticCast(); - if (mResultTransformation) { - mResultTransformation(*valueCopy); - } - if (batchSize && counter >= batchSize) { - return false; - } - counter++; - switch (operation) { - case Sink::Operation_Creation: - // Trace() << "Got creation"; - resultProvider.add(valueCopy); - break; - case Sink::Operation_Modification: - // Trace() << "Got modification"; - resultProvider.modify(valueCopy); - break; - case Sink::Operation_Removal: - // Trace() << "Got removal"; - resultProvider.remove(valueCopy); + int counter; + for (counter = 0; !batchSize || (counter < batchSize); counter++) { + const bool ret = resultSet.next([this, &resultProvider, &counter, &properties, batchSize](const Sink::ApplicationDomain::ApplicationDomainType::Ptr &value, Sink::Operation operation) -> bool { + //FIXME allow maildir resource to set the mimeMessage property + auto valueCopy = Sink::ApplicationDomain::ApplicationDomainType::getInMemoryRepresentation(*value, properties).template staticCast(); + if (mResultTransformation) { + mResultTransformation(*valueCopy); + } + switch (operation) { + case Sink::Operation_Creation: + // Trace() << "Got creation"; + resultProvider.add(valueCopy); + break; + case Sink::Operation_Modification: + // Trace() << "Got modification"; + resultProvider.modify(valueCopy); + break; + case Sink::Operation_Removal: + // Trace() << "Got removal"; + resultProvider.remove(valueCopy); + break; + } + return true; + }); + if (!ret) { break; } - return true; - })){}; + }; Trace() << "Replayed " << counter << " results." << "Limit " << batchSize; } -- cgit v1.2.3