summaryrefslogtreecommitdiffstats
path: root/common/datastorequery.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'common/datastorequery.cpp')
-rw-r--r--common/datastorequery.cpp22
1 files changed, 17 insertions, 5 deletions
diff --git a/common/datastorequery.cpp b/common/datastorequery.cpp
index 218796f..dacc8ab 100644
--- a/common/datastorequery.cpp
+++ b/common/datastorequery.cpp
@@ -300,11 +300,18 @@ public:
300 bool next(const std::function<void(const ResultSet::Result &)> &callback) Q_DECL_OVERRIDE { 300 bool next(const std::function<void(const ResultSet::Result &)> &callback) Q_DECL_OVERRIDE {
301 bool foundValue = false; 301 bool foundValue = false;
302 while(!foundValue && mSource->next([this, callback, &foundValue](const ResultSet::Result &result) { 302 while(!foundValue && mSource->next([this, callback, &foundValue](const ResultSet::Result &result) {
303 if (result.operation == Sink::Operation_Removal) { 303 const auto reductionValue = [&] {
304 callback(result); 304 if (result.operation == Sink::Operation_Removal) {
305 return false; 305 //For removals we have to read the last revision to get a value, and thus be able to find the correct thread.
306 } 306 QVariant reductionValue;
307 auto reductionValue = result.entity.getProperty(mReductionProperty); 307 readPrevious(result.entity.identifier(), [&] (const ApplicationDomain::ApplicationDomainType &prev) {
308 reductionValue = prev.getProperty(mReductionProperty);
309 });
310 return reductionValue;
311 } else {
312 return result.entity.getProperty(mReductionProperty);
313 }
314 }();
308 const auto &reductionValueBa = getByteArray(reductionValue); 315 const auto &reductionValueBa = getByteArray(reductionValue);
309 if (!mReducedValues.contains(reductionValueBa)) { 316 if (!mReducedValues.contains(reductionValueBa)) {
310 //Only reduce every value once. 317 //Only reduce every value once.
@@ -439,6 +446,11 @@ void DataStoreQuery::readEntity(const QByteArray &key, const BufferCallback &res
439 mStore.readLatest(mType, key, resultCallback); 446 mStore.readLatest(mType, key, resultCallback);
440} 447}
441 448
449void DataStoreQuery::readPrevious(const QByteArray &key, const std::function<void (const ApplicationDomain::ApplicationDomainType &)> &callback)
450{
451 mStore.readPrevious(mType, key, mStore.maxRevision(), callback);
452}
453
442QVector<QByteArray> DataStoreQuery::indexLookup(const QByteArray &property, const QVariant &value) 454QVector<QByteArray> DataStoreQuery::indexLookup(const QByteArray &property, const QVariant &value)
443{ 455{
444 return mStore.indexLookup(mType, property, value); 456 return mStore.indexLookup(mType, property, value);