diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-09-27 00:28:40 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-09-27 00:28:40 +0200 |
commit | fd532607ef29aac49b52c861e5aecda6dfa19e82 (patch) | |
tree | 3687ad63516a344f298c014c87a6f6209379a811 /common/datastorequery.cpp | |
parent | 47b9f2109f57c1121b760ea6d885ab08f12c46b3 (diff) | |
download | sink-fd532607ef29aac49b52c861e5aecda6dfa19e82.tar.gz sink-fd532607ef29aac49b52c861e5aecda6dfa19e82.zip |
New query api
Diffstat (limited to 'common/datastorequery.cpp')
-rw-r--r-- | common/datastorequery.cpp | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/common/datastorequery.cpp b/common/datastorequery.cpp index f352b74..0fc9234 100644 --- a/common/datastorequery.cpp +++ b/common/datastorequery.cpp | |||
@@ -148,14 +148,9 @@ public: | |||
148 | QHash<QByteArray, QVariant> mAggregateValues; | 148 | QHash<QByteArray, QVariant> mAggregateValues; |
149 | QByteArray mReductionProperty; | 149 | QByteArray mReductionProperty; |
150 | QByteArray mSelectionProperty; | 150 | QByteArray mSelectionProperty; |
151 | enum SelectionComparator { | 151 | Query::Reduce::Selector::Comparator mSelectionComparator; |
152 | Max | ||
153 | /* Min, */ | ||
154 | /* First */ | ||
155 | }; | ||
156 | SelectionComparator mSelectionComparator; | ||
157 | 152 | ||
158 | Reduce(const QByteArray &reductionProperty, const QByteArray &selectionProperty, SelectionComparator comparator, FilterBase::Ptr source, DataStoreQuery *store) | 153 | Reduce(const QByteArray &reductionProperty, const QByteArray &selectionProperty, Query::Reduce::Selector::Comparator comparator, FilterBase::Ptr source, DataStoreQuery *store) |
159 | : FilterBase(source, store), | 154 | : FilterBase(source, store), |
160 | mReductionProperty(reductionProperty), | 155 | mReductionProperty(reductionProperty), |
161 | mSelectionProperty(selectionProperty), | 156 | mSelectionProperty(selectionProperty), |
@@ -177,9 +172,9 @@ public: | |||
177 | return QByteArray(); | 172 | return QByteArray(); |
178 | } | 173 | } |
179 | 174 | ||
180 | static bool compare(const QVariant &left, const QVariant &right, SelectionComparator comparator) | 175 | static bool compare(const QVariant &left, const QVariant &right, Query::Reduce::Selector::Comparator comparator) |
181 | { | 176 | { |
182 | if (comparator == Max) { | 177 | if (comparator == Query::Reduce::Selector::Max) { |
183 | return left > right; | 178 | return left > right; |
184 | } | 179 | } |
185 | return false; | 180 | return false; |
@@ -412,13 +407,16 @@ void DataStoreQuery::setupQuery() | |||
412 | /* baseSet = Sort::Ptr::create(baseSet, mQuery.sortProperty); */ | 407 | /* baseSet = Sort::Ptr::create(baseSet, mQuery.sortProperty); */ |
413 | /* } */ | 408 | /* } */ |
414 | 409 | ||
415 | if (mQuery.threadLeaderOnly) { | 410 | for (const auto &stage : mQuery.filterStages) { |
416 | auto reduce = Reduce::Ptr::create("threadId", "date", Reduce::Max, baseSet, this); | 411 | if (auto filter = stage.dynamicCast<Query::Filter>()) { |
417 | baseSet = reduce; | 412 | |
418 | } | 413 | } else if (auto filter = stage.dynamicCast<Query::Reduce>()) { |
419 | if (mQuery.bloomThread) { | 414 | auto reduce = Reduce::Ptr::create(filter->property, filter->selector.property, filter->selector.comparator, baseSet, this); |
420 | auto reduce = Bloom::Ptr::create("threadId", baseSet, this); | 415 | baseSet = reduce; |
421 | baseSet = reduce; | 416 | } else if (auto filter = stage.dynamicCast<Query::Bloom>()) { |
417 | auto reduce = Bloom::Ptr::create(filter->property, baseSet, this); | ||
418 | baseSet = reduce; | ||
419 | } | ||
422 | } | 420 | } |
423 | 421 | ||
424 | mCollector = Collector::Ptr::create(baseSet, this); | 422 | mCollector = Collector::Ptr::create(baseSet, this); |