diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-04-29 15:32:12 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-04-29 15:32:12 +0200 |
commit | 9040c66f5fb617a057b9c362ac9a937fe9dd0739 (patch) | |
tree | 9b6e8651781e4c670efd21aaa8f01f9f32bb7113 /common/queryrunner.cpp | |
parent | 78d60438e8f1c962b6933431fe59ac44318d0352 (diff) | |
download | sink-9040c66f5fb617a057b9c362ac9a937fe9dd0739.tar.gz sink-9040c66f5fb617a057b9c362ac9a937fe9dd0739.zip |
The offset is per parent
Diffstat (limited to 'common/queryrunner.cpp')
-rw-r--r-- | common/queryrunner.cpp | 11 |
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: | |||
77 | template <class DomainType> | 77 | template <class DomainType> |
78 | QueryRunner<DomainType>::QueryRunner(const Sink::Query &query, const Sink::ResourceAccessInterface::Ptr &resourceAccess, const QByteArray &instanceIdentifier, | 78 | QueryRunner<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); |