summaryrefslogtreecommitdiffstats
path: root/common/queryrunner.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'common/queryrunner.cpp')
-rw-r--r--common/queryrunner.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/common/queryrunner.cpp b/common/queryrunner.cpp
index d86d26e..bbaae7b 100644
--- a/common/queryrunner.cpp
+++ b/common/queryrunner.cpp
@@ -77,7 +77,7 @@ private:
77template <class DomainType> 77template <class DomainType>
78QueryRunner<DomainType>::QueryRunner(const Sink::Query &query, const Sink::ResourceAccessInterface::Ptr &resourceAccess, const QByteArray &instanceIdentifier, 78QueryRunner<DomainType>::QueryRunner(const Sink::Query &query, const Sink::ResourceAccessInterface::Ptr &resourceAccess, const QByteArray &instanceIdentifier,
79 const DomainTypeAdaptorFactoryInterface::Ptr &factory, const QByteArray &bufferType) 79 const DomainTypeAdaptorFactoryInterface::Ptr &factory, const QByteArray &bufferType)
80 : QueryRunnerBase(), mResourceAccess(resourceAccess), mResultProvider(new ResultProvider<typename DomainType::Ptr>), mOffset(0), mBatchSize(query.limit) 80 : QueryRunnerBase(), mResourceAccess(resourceAccess), mResultProvider(new ResultProvider<typename DomainType::Ptr>), mBatchSize(query.limit)
81{ 81{
82 Trace() << "Starting query"; 82 Trace() << "Starting query";
83 if (query.limit && query.sortProperty.isEmpty()) { 83 if (query.limit && query.sortProperty.isEmpty()) {
@@ -85,15 +85,16 @@ QueryRunner<DomainType>::QueryRunner(const Sink::Query &query, const Sink::Resou
85 } 85 }
86 // We delegate loading of initial data to the result provider, so it can decide for itself what it needs to load. 86 // We delegate loading of initial data to the result provider, so it can decide for itself what it needs to load.
87 mResultProvider->setFetcher([=](const typename DomainType::Ptr &parent) { 87 mResultProvider->setFetcher([=](const typename DomainType::Ptr &parent) {
88 Trace() << "Running fetcher. Offset: " << mOffset << " Batchsize: " << mBatchSize; 88 const QByteArray parentId = parent ? parent->identifier() : QByteArray();
89 Trace() << "Running fetcher. Offset: " << mOffset[parentId] << " Batchsize: " << mBatchSize;
89 auto resultProvider = mResultProvider; 90 auto resultProvider = mResultProvider;
90 async::run<QPair<qint64, qint64> >([=]() { 91 async::run<QPair<qint64, qint64> >([=]() {
91 QueryWorker<DomainType> worker(query, instanceIdentifier, factory, bufferType, mResultTransformation); 92 QueryWorker<DomainType> worker(query, instanceIdentifier, factory, bufferType, mResultTransformation);
92 const auto newRevisionAndReplayedEntities = worker.executeInitialQuery(query, parent, *resultProvider, mOffset, mBatchSize); 93 const auto newRevisionAndReplayedEntities = worker.executeInitialQuery(query, parent, *resultProvider, mOffset[parentId], mBatchSize);
93 return newRevisionAndReplayedEntities; 94 return newRevisionAndReplayedEntities;
94 }) 95 })
95 .template then<void, QPair<qint64, qint64>>([query, this](const QPair<qint64, qint64> &newRevisionAndReplayedEntities) { 96 .template then<void, QPair<qint64, qint64>>([=](const QPair<qint64, qint64> &newRevisionAndReplayedEntities) {
96 mOffset += newRevisionAndReplayedEntities.second; 97 mOffset[parentId] += newRevisionAndReplayedEntities.second;
97 // Only send the revision replayed information if we're connected to the resource, there's no need to start the resource otherwise. 98 // Only send the revision replayed information if we're connected to the resource, there's no need to start the resource otherwise.
98 if (query.liveQuery) { 99 if (query.liveQuery) {
99 mResourceAccess->sendRevisionReplayedCommand(newRevisionAndReplayedEntities.first); 100 mResourceAccess->sendRevisionReplayedCommand(newRevisionAndReplayedEntities.first);