diff options
Diffstat (limited to 'common/datastorequery.cpp')
-rw-r--r-- | common/datastorequery.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/common/datastorequery.cpp b/common/datastorequery.cpp index 34d2bae..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 | } |
@@ -152,7 +152,7 @@ public: | |||
152 | } | 152 | } |
153 | }; | 153 | }; |
154 | 154 | ||
155 | class Reduce : public FilterBase { | 155 | class Reduce : public Filter { |
156 | public: | 156 | public: |
157 | typedef QSharedPointer<Reduce> Ptr; | 157 | typedef QSharedPointer<Reduce> Ptr; |
158 | 158 | ||
@@ -198,7 +198,7 @@ public: | |||
198 | QList<Aggregator> mAggregators; | 198 | QList<Aggregator> mAggregators; |
199 | 199 | ||
200 | Reduce(const QByteArray &reductionProperty, const QByteArray &selectionProperty, QueryBase::Reduce::Selector::Comparator comparator, FilterBase::Ptr source, DataStoreQuery *store) | 200 | Reduce(const QByteArray &reductionProperty, const QByteArray &selectionProperty, QueryBase::Reduce::Selector::Comparator comparator, FilterBase::Ptr source, DataStoreQuery *store) |
201 | : FilterBase(source, store), | 201 | : Filter(source, store), |
202 | mReductionProperty(reductionProperty), | 202 | mReductionProperty(reductionProperty), |
203 | mSelectionProperty(selectionProperty), | 203 | mSelectionProperty(selectionProperty), |
204 | mSelectionComparator(comparator) | 204 | mSelectionComparator(comparator) |
@@ -236,6 +236,11 @@ public: | |||
236 | 236 | ||
237 | for (const auto &r : results) { | 237 | for (const auto &r : results) { |
238 | readEntity(r, [&, this](const Sink::ApplicationDomain::ApplicationDomainType &entity, Sink::Operation operation) { | 238 | readEntity(r, [&, this](const Sink::ApplicationDomain::ApplicationDomainType &entity, Sink::Operation operation) { |
239 | //We need to apply all property filters that we have until the reduction, because the index lookup was unfiltered. | ||
240 | if (!matchesFilter(entity)) { | ||
241 | return; | ||
242 | } | ||
243 | |||
239 | Q_ASSERT(operation != Sink::Operation_Removal); | 244 | Q_ASSERT(operation != Sink::Operation_Removal); |
240 | for (auto &aggregator : mAggregators) { | 245 | for (auto &aggregator : mAggregators) { |
241 | if (!aggregator.property.isEmpty()) { | 246 | if (!aggregator.property.isEmpty()) { |
@@ -362,19 +367,22 @@ public: | |||
362 | DataStoreQuery::DataStoreQuery(const Sink::QueryBase &query, const QByteArray &type, EntityStore &store) | 367 | DataStoreQuery::DataStoreQuery(const Sink::QueryBase &query, const QByteArray &type, EntityStore &store) |
363 | : mType(type), mStore(store), mLogCtx(store.logContext().subContext("datastorequery")) | 368 | : mType(type), mStore(store), mLogCtx(store.logContext().subContext("datastorequery")) |
364 | { | 369 | { |
370 | //This is what we use during a new query | ||
365 | setupQuery(query); | 371 | setupQuery(query); |
366 | } | 372 | } |
367 | 373 | ||
368 | 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) |
369 | : mType(type), mStore(store), mLogCtx(store.logContext().subContext("datastorequery")) | 375 | : mType(type), mStore(store), mLogCtx(store.logContext().subContext("datastorequery")) |
370 | { | 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 | ||
371 | mCollector = state.mCollector; | 379 | mCollector = state.mCollector; |
372 | mSource = state.mSource; | 380 | mSource = state.mSource; |
373 | 381 | ||
374 | auto source = mCollector; | 382 | auto source = mCollector; |
375 | while (source) { | 383 | while (source) { |
376 | source->mDatastore = this; | 384 | source->mDatastore = this; |
377 | source->mIncremental = true; | 385 | source->mIncremental = incremental; |
378 | source = source->mSource; | 386 | source = source->mSource; |
379 | } | 387 | } |
380 | } | 388 | } |
@@ -553,6 +561,7 @@ void DataStoreQuery::setupQuery(const Sink::QueryBase &query_) | |||
553 | for (const auto &aggregator : filter->aggregators) { | 561 | for (const auto &aggregator : filter->aggregators) { |
554 | reduction->mAggregators << Reduce::Aggregator(aggregator.operation, aggregator.propertyToCollect, aggregator.resultProperty); | 562 | reduction->mAggregators << Reduce::Aggregator(aggregator.operation, aggregator.propertyToCollect, aggregator.resultProperty); |
555 | } | 563 | } |
564 | reduction->propertyFilter = query.getBaseFilters(); | ||
556 | baseSet = reduction; | 565 | baseSet = reduction; |
557 | } else if (auto filter = stage.dynamicCast<Query::Bloom>()) { | 566 | } else if (auto filter = stage.dynamicCast<Query::Bloom>()) { |
558 | baseSet = Bloom::Ptr::create(filter->property, baseSet, this); | 567 | baseSet = Bloom::Ptr::create(filter->property, baseSet, this); |