diff options
Diffstat (limited to 'common/datastorequery.cpp')
-rw-r--r-- | common/datastorequery.cpp | 28 |
1 files changed, 14 insertions, 14 deletions
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: | |||
229 | 229 | ||
230 | QSet<QByteArray> mReducedValues; | 230 | QSet<QByteArray> mReducedValues; |
231 | QSet<QByteArray> mIncrementallyReducedValues; | 231 | QSet<QByteArray> mIncrementallyReducedValues; |
232 | QHash<QByteArray, QByteArray> mSelectedValues; | 232 | QHash<QByteArray, Identifier> mSelectedValues; |
233 | QByteArray mReductionProperty; | 233 | QByteArray mReductionProperty; |
234 | QByteArray mSelectionProperty; | 234 | QByteArray mSelectionProperty; |
235 | QueryBase::Reduce::Selector::Comparator mSelectionComparator; | 235 | QueryBase::Reduce::Selector::Comparator mSelectionComparator; |
@@ -270,7 +270,7 @@ public: | |||
270 | } | 270 | } |
271 | 271 | ||
272 | struct ReductionResult { | 272 | struct ReductionResult { |
273 | QByteArray selection; | 273 | Identifier selection; |
274 | QVector<QByteArray> aggregateIds; | 274 | QVector<QByteArray> aggregateIds; |
275 | QMap<QByteArray, QVariant> aggregateValues; | 275 | QMap<QByteArray, QVariant> aggregateValues; |
276 | }; | 276 | }; |
@@ -279,7 +279,7 @@ public: | |||
279 | { | 279 | { |
280 | QMap<QByteArray, QVariant> aggregateValues; | 280 | QMap<QByteArray, QVariant> aggregateValues; |
281 | QVariant selectionResultValue; | 281 | QVariant selectionResultValue; |
282 | QByteArray selectionResult; | 282 | Identifier selectionResult; |
283 | const auto results = indexLookup(mReductionProperty, reductionValue); | 283 | const auto results = indexLookup(mReductionProperty, reductionValue); |
284 | for (auto &aggregator : mAggregators) { | 284 | for (auto &aggregator : mAggregators) { |
285 | aggregator.reset(); | 285 | aggregator.reset(); |
@@ -303,7 +303,7 @@ public: | |||
303 | auto selectionValue = entity.getProperty(mSelectionProperty); | 303 | auto selectionValue = entity.getProperty(mSelectionProperty); |
304 | if (!selectionResultValue.isValid() || compare(selectionValue, selectionResultValue, mSelectionComparator)) { | 304 | if (!selectionResultValue.isValid() || compare(selectionValue, selectionResultValue, mSelectionComparator)) { |
305 | selectionResultValue = selectionValue; | 305 | selectionResultValue = selectionValue; |
306 | selectionResult = entity.identifier(); | 306 | selectionResult = Identifier::fromDisplayByteArray(entity.identifier()); |
307 | } | 307 | } |
308 | }); | 308 | }); |
309 | } | 309 | } |
@@ -349,11 +349,11 @@ public: | |||
349 | auto reductionResult = reduceOnValue(reductionValue); | 349 | auto reductionResult = reduceOnValue(reductionValue); |
350 | 350 | ||
351 | //This can happen if we get a removal message from a filtered entity and all entites of the reduction are filtered. | 351 | //This can happen if we get a removal message from a filtered entity and all entites of the reduction are filtered. |
352 | if (reductionResult.selection.isEmpty()) { | 352 | if (reductionResult.selection.isNull()) { |
353 | return; | 353 | return; |
354 | } | 354 | } |
355 | mSelectedValues.insert(reductionValueBa, reductionResult.selection); | 355 | mSelectedValues.insert(reductionValueBa, reductionResult.selection); |
356 | readEntity(Identifier::fromDisplayByteArray(reductionResult.selection), [&](const Sink::ApplicationDomain::ApplicationDomainType &entity, Sink::Operation operation) { | 356 | readEntity(reductionResult.selection, [&](const Sink::ApplicationDomain::ApplicationDomainType &entity, Sink::Operation operation) { |
357 | callback({entity, operation, reductionResult.aggregateValues, reductionResult.aggregateIds}); | 357 | callback({entity, operation, reductionResult.aggregateValues, reductionResult.aggregateIds}); |
358 | foundValue = true; | 358 | foundValue = true; |
359 | }); | 359 | }); |
@@ -370,28 +370,28 @@ public: | |||
370 | auto oldSelectionResult = mSelectedValues.take(reductionValueBa); | 370 | auto oldSelectionResult = mSelectedValues.take(reductionValueBa); |
371 | SinkTraceCtx(mDatastore->mLogCtx) << "Old selection result: " << oldSelectionResult << " New selection result: " << selectionResult.selection; | 371 | SinkTraceCtx(mDatastore->mLogCtx) << "Old selection result: " << oldSelectionResult << " New selection result: " << selectionResult.selection; |
372 | //If mSelectedValues did not containthe value, oldSelectionResult will be empty.(Happens if entites have been filtered) | 372 | //If mSelectedValues did not containthe value, oldSelectionResult will be empty.(Happens if entites have been filtered) |
373 | if (oldSelectionResult.isEmpty()) { | 373 | if (oldSelectionResult.isNull()) { |
374 | return; | 374 | return; |
375 | } | 375 | } |
376 | if (oldSelectionResult == selectionResult.selection) { | 376 | if (oldSelectionResult == selectionResult.selection) { |
377 | mSelectedValues.insert(reductionValueBa, selectionResult.selection); | 377 | mSelectedValues.insert(reductionValueBa, selectionResult.selection); |
378 | Q_ASSERT(!selectionResult.selection.isEmpty()); | 378 | Q_ASSERT(!selectionResult.selection.isNull()); |
379 | readEntity(Identifier::fromDisplayByteArray(selectionResult.selection), [&](const Sink::ApplicationDomain::ApplicationDomainType &entity, Sink::Operation) { | 379 | readEntity(selectionResult.selection, [&](const Sink::ApplicationDomain::ApplicationDomainType &entity, Sink::Operation) { |
380 | callback({entity, Sink::Operation_Modification, selectionResult.aggregateValues, selectionResult.aggregateIds}); | 380 | callback({entity, Sink::Operation_Modification, selectionResult.aggregateValues, selectionResult.aggregateIds}); |
381 | }); | 381 | }); |
382 | } else { | 382 | } else { |
383 | //remove old result | 383 | //remove old result |
384 | Q_ASSERT(!oldSelectionResult.isEmpty()); | 384 | Q_ASSERT(!oldSelectionResult.isNull()); |
385 | readEntity(Identifier::fromDisplayByteArray(oldSelectionResult), [&](const Sink::ApplicationDomain::ApplicationDomainType &entity, Sink::Operation) { | 385 | readEntity(oldSelectionResult, [&](const Sink::ApplicationDomain::ApplicationDomainType &entity, Sink::Operation) { |
386 | callback({entity, Sink::Operation_Removal}); | 386 | callback({entity, Sink::Operation_Removal}); |
387 | }); | 387 | }); |
388 | 388 | ||
389 | //If the last item has been removed, then there's nothing to add | 389 | //If the last item has been removed, then there's nothing to add |
390 | if (!selectionResult.selection.isEmpty()) { | 390 | if (!selectionResult.selection.isNull()) { |
391 | //add new result | 391 | //add new result |
392 | mSelectedValues.insert(reductionValueBa, selectionResult.selection); | 392 | mSelectedValues.insert(reductionValueBa, selectionResult.selection); |
393 | Q_ASSERT(!selectionResult.selection.isEmpty()); | 393 | Q_ASSERT(!selectionResult.selection.isNull()); |
394 | readEntity(Identifier::fromDisplayByteArray(selectionResult.selection), [&](const Sink::ApplicationDomain::ApplicationDomainType &entity, Sink::Operation) { | 394 | readEntity(selectionResult.selection, [&](const Sink::ApplicationDomain::ApplicationDomainType &entity, Sink::Operation) { |
395 | callback({entity, Sink::Operation_Creation, selectionResult.aggregateValues, selectionResult.aggregateIds}); | 395 | callback({entity, Sink::Operation_Creation, selectionResult.aggregateValues, selectionResult.aggregateIds}); |
396 | }); | 396 | }); |
397 | } | 397 | } |