From c16b34c3612049d41edf18cb533dbfc3b9b427a2 Mon Sep 17 00:00:00 2001 From: Minijackson Date: Mon, 23 Jul 2018 10:37:56 +0200 Subject: Convert selection in Reduce filter in datastorequery --- common/datastorequery.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'common/datastorequery.cpp') diff --git a/common/datastorequery.cpp b/common/datastorequery.cpp index 51b6230..0ba62eb 100644 --- a/common/datastorequery.cpp +++ b/common/datastorequery.cpp @@ -229,7 +229,7 @@ public: QSet mReducedValues; QSet mIncrementallyReducedValues; - QHash mSelectedValues; + QHash mSelectedValues; QByteArray mReductionProperty; QByteArray mSelectionProperty; QueryBase::Reduce::Selector::Comparator mSelectionComparator; @@ -270,7 +270,7 @@ public: } struct ReductionResult { - QByteArray selection; + Identifier selection; QVector aggregateIds; QMap aggregateValues; }; @@ -279,7 +279,7 @@ public: { QMap aggregateValues; QVariant selectionResultValue; - QByteArray selectionResult; + Identifier selectionResult; const auto results = indexLookup(mReductionProperty, reductionValue); for (auto &aggregator : mAggregators) { aggregator.reset(); @@ -303,7 +303,7 @@ public: auto selectionValue = entity.getProperty(mSelectionProperty); if (!selectionResultValue.isValid() || compare(selectionValue, selectionResultValue, mSelectionComparator)) { selectionResultValue = selectionValue; - selectionResult = entity.identifier(); + selectionResult = Identifier::fromDisplayByteArray(entity.identifier()); } }); } @@ -349,11 +349,11 @@ public: auto reductionResult = reduceOnValue(reductionValue); //This can happen if we get a removal message from a filtered entity and all entites of the reduction are filtered. - if (reductionResult.selection.isEmpty()) { + if (reductionResult.selection.isNull()) { return; } mSelectedValues.insert(reductionValueBa, reductionResult.selection); - readEntity(Identifier::fromDisplayByteArray(reductionResult.selection), [&](const Sink::ApplicationDomain::ApplicationDomainType &entity, Sink::Operation operation) { + readEntity(reductionResult.selection, [&](const Sink::ApplicationDomain::ApplicationDomainType &entity, Sink::Operation operation) { callback({entity, operation, reductionResult.aggregateValues, reductionResult.aggregateIds}); foundValue = true; }); @@ -370,28 +370,28 @@ public: auto oldSelectionResult = mSelectedValues.take(reductionValueBa); SinkTraceCtx(mDatastore->mLogCtx) << "Old selection result: " << oldSelectionResult << " New selection result: " << selectionResult.selection; //If mSelectedValues did not containthe value, oldSelectionResult will be empty.(Happens if entites have been filtered) - if (oldSelectionResult.isEmpty()) { + if (oldSelectionResult.isNull()) { return; } if (oldSelectionResult == selectionResult.selection) { mSelectedValues.insert(reductionValueBa, selectionResult.selection); - Q_ASSERT(!selectionResult.selection.isEmpty()); - readEntity(Identifier::fromDisplayByteArray(selectionResult.selection), [&](const Sink::ApplicationDomain::ApplicationDomainType &entity, Sink::Operation) { + Q_ASSERT(!selectionResult.selection.isNull()); + readEntity(selectionResult.selection, [&](const Sink::ApplicationDomain::ApplicationDomainType &entity, Sink::Operation) { callback({entity, Sink::Operation_Modification, selectionResult.aggregateValues, selectionResult.aggregateIds}); }); } else { //remove old result - Q_ASSERT(!oldSelectionResult.isEmpty()); - readEntity(Identifier::fromDisplayByteArray(oldSelectionResult), [&](const Sink::ApplicationDomain::ApplicationDomainType &entity, Sink::Operation) { + Q_ASSERT(!oldSelectionResult.isNull()); + readEntity(oldSelectionResult, [&](const Sink::ApplicationDomain::ApplicationDomainType &entity, Sink::Operation) { callback({entity, Sink::Operation_Removal}); }); //If the last item has been removed, then there's nothing to add - if (!selectionResult.selection.isEmpty()) { + if (!selectionResult.selection.isNull()) { //add new result mSelectedValues.insert(reductionValueBa, selectionResult.selection); - Q_ASSERT(!selectionResult.selection.isEmpty()); - readEntity(Identifier::fromDisplayByteArray(selectionResult.selection), [&](const Sink::ApplicationDomain::ApplicationDomainType &entity, Sink::Operation) { + Q_ASSERT(!selectionResult.selection.isNull()); + readEntity(selectionResult.selection, [&](const Sink::ApplicationDomain::ApplicationDomainType &entity, Sink::Operation) { callback({entity, Sink::Operation_Creation, selectionResult.aggregateValues, selectionResult.aggregateIds}); }); } -- cgit v1.2.3