diff --git a/common/datastorequery.cpp b/common/datastorequery.cpp --- a/common/datastorequery.cpp +++ b/common/datastorequery.cpp @@ -271,7 +271,7 @@ struct ReductionResult { Identifier selection; - QVector aggregateIds; + QVector aggregateIds; QMap aggregateValues; }; @@ -284,14 +284,14 @@ for (auto &aggregator : mAggregators) { aggregator.reset(); } - QVector reducedAndFilteredResults; + QVector reducedAndFilteredResults; for (const auto &r : results) { readEntity(r, [&, this](const Sink::ApplicationDomain::ApplicationDomainType &entity, Sink::Operation operation) { //We need to apply all property filters that we have until the reduction, because the index lookup was unfiltered. if (!matchesFilter(entity)) { return; } - reducedAndFilteredResults << r.toDisplayByteArray(); + reducedAndFilteredResults << r; Q_ASSERT(operation != Sink::Operation_Removal); for (auto &aggregator : mAggregators) { if (!aggregator.property.isEmpty()) { diff --git a/common/queryrunner.cpp b/common/queryrunner.cpp --- a/common/queryrunner.cpp +++ b/common/queryrunner.cpp @@ -271,7 +271,14 @@ for (auto it = result.aggregateValues.constBegin(); it != result.aggregateValues.constEnd(); it++) { valueCopy->setProperty(it.key(), it.value()); } - valueCopy->aggregatedIds() = result.aggregateIds; + valueCopy->aggregatedIds() = [&] { + QVector aggregateIdsBA; + aggregateIdsBA.reserve(result.aggregateIds.size()); + for (const auto &id : result.aggregateIds) { + aggregateIdsBA << id.toDisplayByteArray(); + } + return aggregateIdsBA; + }(); if (mResultTransformation) { mResultTransformation(*valueCopy); } diff --git a/common/resultset.h b/common/resultset.h --- a/common/resultset.h +++ b/common/resultset.h @@ -25,6 +25,7 @@ #include "metadata_generated.h" #include "entitybuffer.h" #include "applicationdomaintype.h" +#include "storage/key.h" /* * An iterator to a result set. @@ -35,21 +36,25 @@ { public: struct Result { - Result(const Sink::ApplicationDomain::ApplicationDomainType &e, Sink::Operation op, const QMap &v = {}, const QVector &a = {}) : entity(e), operation(op), aggregateValues(v), aggregateIds(a) {} + Result(const Sink::ApplicationDomain::ApplicationDomainType &e, Sink::Operation op, + const QMap &v = {}, const QVector &a = {}) + : entity(e), operation(op), aggregateValues(v), aggregateIds(a) + { + } Sink::ApplicationDomain::ApplicationDomainType entity; Sink::Operation operation; QMap aggregateValues; - QVector aggregateIds; + QVector aggregateIds; }; typedef std::function Callback; typedef std::function ValueGenerator; - typedef std::function IdGenerator; + typedef std::function IdGenerator; typedef std::function SkipValue; ResultSet(); ResultSet(const ValueGenerator &generator, const SkipValue &skip); ResultSet(const IdGenerator &generator); - ResultSet(const QVector &resultSet); + ResultSet(const QVector &resultSet); ResultSet(const ResultSet &other); bool next(); @@ -63,14 +68,14 @@ }; ReplayResult replaySet(int offset, int batchSize, const Callback &callback); - QByteArray id(); + Sink::Storage::Identifier id(); bool isEmpty(); private: - QVector mResultSet; - QVector::ConstIterator mIt; - QByteArray mCurrentValue; + QVector mResultSet; + QVector::ConstIterator mIt; + Sink::Storage::Identifier mCurrentValue; IdGenerator mGenerator; ValueGenerator mValueGenerator; SkipValue mSkip; diff --git a/common/resultset.cpp b/common/resultset.cpp --- a/common/resultset.cpp +++ b/common/resultset.cpp @@ -20,6 +20,8 @@ #include "log.h" +using Sink::Storage::Identifier; + ResultSet::ResultSet() : mIt(nullptr) { } @@ -32,7 +34,7 @@ { } -ResultSet::ResultSet(const QVector &resultSet) +ResultSet::ResultSet(const QVector &resultSet) : mResultSet(resultSet), mIt(mResultSet.constBegin()), mSkip([this]() { @@ -114,11 +116,11 @@ return {counter, false}; } -QByteArray ResultSet::id() +Identifier ResultSet::id() { if (mIt) { if (mIt == mResultSet.constEnd()) { - return QByteArray(); + return {}; } Q_ASSERT(mIt != mResultSet.constEnd()); return *mIt;