diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-02-03 16:54:56 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-02-03 16:54:56 +0100 |
commit | b11b8a774e83aa7de65758e814c3fabea87f6160 (patch) | |
tree | de1cc1e43d40afb0bf01f59f15071ceb426d3eaa /common/resultprovider.h | |
parent | 0acdfd2ac2dd3ebfb05c96e065c896fb2ed4734f (diff) | |
download | sink-b11b8a774e83aa7de65758e814c3fabea87f6160.tar.gz sink-b11b8a774e83aa7de65758e814c3fabea87f6160.zip |
Fixed incremental fetching
Diffstat (limited to 'common/resultprovider.h')
-rw-r--r-- | common/resultprovider.h | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/common/resultprovider.h b/common/resultprovider.h index 86138db..a2ed0b5 100644 --- a/common/resultprovider.h +++ b/common/resultprovider.h | |||
@@ -344,22 +344,25 @@ public: | |||
344 | auto ptr = emitter.data(); | 344 | auto ptr = emitter.data(); |
345 | emitter->onInitialResultSetComplete([this, ptr](const DomainType &parent, bool replayedAll) { | 345 | emitter->onInitialResultSetComplete([this, ptr](const DomainType &parent, bool replayedAll) { |
346 | auto hashValue = qHash(parent); | 346 | auto hashValue = qHash(parent); |
347 | if (replayedAll) { | ||
348 | mAllResultsReplayed.remove(hashValue, ptr); | ||
349 | } | ||
347 | mInitialResultSetInProgress.remove(hashValue, ptr); | 350 | mInitialResultSetInProgress.remove(hashValue, ptr); |
348 | callInitialResultCompleteIfDone(parent, replayedAll); | 351 | callInitialResultCompleteIfDone(parent); |
349 | }); | 352 | }); |
350 | emitter->onComplete([this]() { this->complete(); }); | 353 | emitter->onComplete([this]() { this->complete(); }); |
351 | emitter->onClear([this]() { this->clear(); }); | 354 | emitter->onClear([this]() { this->clear(); }); |
352 | mEmitter << emitter; | 355 | mEmitter << emitter; |
353 | } | 356 | } |
354 | 357 | ||
355 | void callInitialResultCompleteIfDone(const DomainType &parent, bool replayedAll) | 358 | void callInitialResultCompleteIfDone(const DomainType &parent) |
356 | { | 359 | { |
357 | auto hashValue = qHash(parent); | 360 | auto hashValue = qHash(parent); |
358 | // Normally a parent is only in a single resource, except the toplevel (invalid) parent | 361 | // Normally a parent is only in a single resource, except the toplevel (invalid) parent |
359 | if (!mInitialResultSetInProgress.contains(hashValue) && mAllResultsFetched && !mResultEmitted) { | 362 | if (!mInitialResultSetInProgress.contains(hashValue) && mAllResultsFetched && !mResultEmitted) { |
363 | bool allResourcesReplayedAll = mAllResultsReplayed.isEmpty(); | ||
360 | mResultEmitted = true; | 364 | mResultEmitted = true; |
361 | //FIXME set replayed all only to true if all had set it to true | 365 | this->initialResultSetComplete(parent, allResourcesReplayedAll); |
362 | this->initialResultSetComplete(parent, true); | ||
363 | } | 366 | } |
364 | } | 367 | } |
365 | 368 | ||
@@ -370,18 +373,22 @@ public: | |||
370 | } else { | 373 | } else { |
371 | mResultEmitted = false; | 374 | mResultEmitted = false; |
372 | mAllResultsFetched = false; | 375 | mAllResultsFetched = false; |
376 | mAllResultsReplayed.clear(); | ||
377 | const auto hashValue = qHash(parent); | ||
373 | for (const auto &emitter : mEmitter) { | 378 | for (const auto &emitter : mEmitter) { |
374 | mInitialResultSetInProgress.insert(qHash(parent), emitter.data()); | 379 | mInitialResultSetInProgress.insert(hashValue, emitter.data()); |
380 | mAllResultsReplayed.insert(hashValue, emitter.data()); | ||
375 | emitter->fetch(parent); | 381 | emitter->fetch(parent); |
376 | } | 382 | } |
377 | mAllResultsFetched = true; | 383 | mAllResultsFetched = true; |
378 | callInitialResultCompleteIfDone(parent, true); | 384 | callInitialResultCompleteIfDone(parent); |
379 | } | 385 | } |
380 | } | 386 | } |
381 | 387 | ||
382 | private: | 388 | private: |
383 | QList<typename ResultEmitter<DomainType>::Ptr> mEmitter; | 389 | QList<typename ResultEmitter<DomainType>::Ptr> mEmitter; |
384 | QMultiMap<qint64, ResultEmitter<DomainType> *> mInitialResultSetInProgress; | 390 | QMultiMap<qint64, ResultEmitter<DomainType> *> mInitialResultSetInProgress; |
391 | QMultiMap<qint64, ResultEmitter<DomainType> *> mAllResultsReplayed; | ||
385 | bool mAllResultsFetched; | 392 | bool mAllResultsFetched; |
386 | bool mResultEmitted; | 393 | bool mResultEmitted; |
387 | }; | 394 | }; |