diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-03-21 22:06:12 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-03-22 11:32:53 +0100 |
commit | 86045e308c10c60cd7c4339d305cee1acb084760 (patch) | |
tree | b8fd3e91ffbdeb8ad2e78a61fe1d3426eb5874be /common/datastorequery.cpp | |
parent | daf96f7efec0538e161eab8e906a291015842e1e (diff) | |
download | sink-86045e308c10c60cd7c4339d305cee1acb084760.tar.gz sink-86045e308c10c60cd7c4339d305cee1acb084760.zip |
Maintain the query state instead of using the offset.
Instead of using the offset to skip over old results requires
recalculating them, and resulted in some cases in results being added
multiple times to the model.
By just maintaining the state we can apply the offset directly to the
base-set, and maintain the state in reduction etc. which is necessary to
continue streaming results while making sure we don't report anything
twice.
Diffstat (limited to 'common/datastorequery.cpp')
-rw-r--r-- | common/datastorequery.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/common/datastorequery.cpp b/common/datastorequery.cpp index 0db59e1..2e0c348 100644 --- a/common/datastorequery.cpp +++ b/common/datastorequery.cpp | |||
@@ -144,7 +144,7 @@ public: | |||
144 | const auto property = entity.getProperty(filterProperty); | 144 | const auto property = entity.getProperty(filterProperty); |
145 | const auto comparator = propertyFilter.value(filterProperty); | 145 | const auto comparator = propertyFilter.value(filterProperty); |
146 | if (!comparator.matches(property)) { | 146 | if (!comparator.matches(property)) { |
147 | SinkTraceCtx(mDatastore->mLogCtx) << "Filtering entity due to property mismatch on filter: " << filterProperty << property << ":" << comparator.value; | 147 | SinkTraceCtx(mDatastore->mLogCtx) << "Filtering entity due to property mismatch on filter: " << entity.identifier() << "Property: " << filterProperty << property << " Filter:" << comparator.value; |
148 | return false; | 148 | return false; |
149 | } | 149 | } |
150 | } | 150 | } |
@@ -367,19 +367,22 @@ public: | |||
367 | DataStoreQuery::DataStoreQuery(const Sink::QueryBase &query, const QByteArray &type, EntityStore &store) | 367 | DataStoreQuery::DataStoreQuery(const Sink::QueryBase &query, const QByteArray &type, EntityStore &store) |
368 | : mType(type), mStore(store), mLogCtx(store.logContext().subContext("datastorequery")) | 368 | : mType(type), mStore(store), mLogCtx(store.logContext().subContext("datastorequery")) |
369 | { | 369 | { |
370 | //This is what we use during a new query | ||
370 | setupQuery(query); | 371 | setupQuery(query); |
371 | } | 372 | } |
372 | 373 | ||
373 | DataStoreQuery::DataStoreQuery(const DataStoreQuery::State &state, const QByteArray &type, Sink::Storage::EntityStore &store) | 374 | DataStoreQuery::DataStoreQuery(const DataStoreQuery::State &state, const QByteArray &type, Sink::Storage::EntityStore &store, bool incremental) |
374 | : mType(type), mStore(store), mLogCtx(store.logContext().subContext("datastorequery")) | 375 | : mType(type), mStore(store), mLogCtx(store.logContext().subContext("datastorequery")) |
375 | { | 376 | { |
377 | //This is what we use when fetching more data, without having a new revision with incremental=false | ||
378 | //And this is what we use when the data changed and we want to update with incremental = true | ||
376 | mCollector = state.mCollector; | 379 | mCollector = state.mCollector; |
377 | mSource = state.mSource; | 380 | mSource = state.mSource; |
378 | 381 | ||
379 | auto source = mCollector; | 382 | auto source = mCollector; |
380 | while (source) { | 383 | while (source) { |
381 | source->mDatastore = this; | 384 | source->mDatastore = this; |
382 | source->mIncremental = true; | 385 | source->mIncremental = incremental; |
383 | source = source->mSource; | 386 | source = source->mSource; |
384 | } | 387 | } |
385 | } | 388 | } |