diff options
author | Rémi Nicole <nicole@kolabsystems.com> | 2018-06-19 11:04:17 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2018-06-19 11:10:47 +0200 |
commit | 077e3cb30ace5f6ee20ee15e0d32d2bfb197fde0 (patch) | |
tree | 3cfdaf0912ef22dba71755b4332354d579f6e7cf /common/datastorequery.cpp | |
parent | 1ff4456e5dc2b9a9dfa80047f9e5a4a9e1395cdf (diff) | |
download | sink-077e3cb30ace5f6ee20ee15e0d32d2bfb197fde0.tar.gz sink-077e3cb30ace5f6ee20ee15e0d32d2bfb197fde0.zip |
Implement Overlap queries
Summary:
Notes:
- Introduces the concept of queries on multiple properties (which meant changing query's internals a bit)
- Dates are stored as well as the "reference" in the index to allow quick filtering without fetching the whole entity
- Buckets are weeks starting on Monday (guaranteed by the use of the Julian calendar)
- Some size improvements are definitely possible (dates are padded numbers again, not using integer databases, Julian calendar starts at a very old date, etc.)
Test Plan: Tested in querytest
Reviewers: cmollekopf
Reviewed By: cmollekopf
Tags: #sink
Differential Revision: https://phabricator.kde.org/D13477
Diffstat (limited to 'common/datastorequery.cpp')
-rw-r--r-- | common/datastorequery.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/common/datastorequery.cpp b/common/datastorequery.cpp index 12c0ae1..263d3ea 100644 --- a/common/datastorequery.cpp +++ b/common/datastorequery.cpp | |||
@@ -119,7 +119,7 @@ class Filter : public FilterBase { | |||
119 | public: | 119 | public: |
120 | typedef QSharedPointer<Filter> Ptr; | 120 | typedef QSharedPointer<Filter> Ptr; |
121 | 121 | ||
122 | QHash<QByteArray, Sink::QueryBase::Comparator> propertyFilter; | 122 | QHash<QByteArrayList, Sink::QueryBase::Comparator> propertyFilter; |
123 | 123 | ||
124 | Filter(FilterBase::Ptr source, DataStoreQuery *store) | 124 | Filter(FilterBase::Ptr source, DataStoreQuery *store) |
125 | : FilterBase(source, store) | 125 | : FilterBase(source, store) |
@@ -158,7 +158,16 @@ public: | |||
158 | 158 | ||
159 | bool matchesFilter(const ApplicationDomain::ApplicationDomainType &entity) { | 159 | bool matchesFilter(const ApplicationDomain::ApplicationDomainType &entity) { |
160 | for (const auto &filterProperty : propertyFilter.keys()) { | 160 | for (const auto &filterProperty : propertyFilter.keys()) { |
161 | const auto property = entity.getProperty(filterProperty); | 161 | QVariant property; |
162 | if (filterProperty.size() == 1) { | ||
163 | property = entity.getProperty(filterProperty[0]); | ||
164 | } else { | ||
165 | QVariantList propList; | ||
166 | for (const auto &propName : filterProperty) { | ||
167 | propList.push_back(entity.getProperty(propName)); | ||
168 | } | ||
169 | property = propList; | ||
170 | } | ||
162 | const auto comparator = propertyFilter.value(filterProperty); | 171 | const auto comparator = propertyFilter.value(filterProperty); |
163 | //We can't deal with a fulltext filter | 172 | //We can't deal with a fulltext filter |
164 | if (comparator.comparator == QueryBase::Comparator::Fulltext) { | 173 | if (comparator.comparator == QueryBase::Comparator::Fulltext) { |
@@ -420,7 +429,7 @@ public: | |||
420 | })) | 429 | })) |
421 | {} | 430 | {} |
422 | mBloomed = true; | 431 | mBloomed = true; |
423 | propertyFilter.insert(mBloomProperty, mBloomValue); | 432 | propertyFilter.insert({mBloomProperty}, mBloomValue); |
424 | return foundValue; | 433 | return foundValue; |
425 | } else { | 434 | } else { |
426 | //Filter on bloom value | 435 | //Filter on bloom value |
@@ -598,7 +607,7 @@ void DataStoreQuery::setupQuery(const Sink::QueryBase &query_) | |||
598 | //We have a set of ids as a starting point | 607 | //We have a set of ids as a starting point |
599 | return Source::Ptr::create(query.ids().toVector(), this); | 608 | return Source::Ptr::create(query.ids().toVector(), this); |
600 | } else { | 609 | } else { |
601 | QSet<QByteArray> appliedFilters; | 610 | QSet<QByteArrayList> appliedFilters; |
602 | auto resultSet = mStore.indexLookup(mType, query, appliedFilters, appliedSorting); | 611 | auto resultSet = mStore.indexLookup(mType, query, appliedFilters, appliedSorting); |
603 | if (!appliedFilters.isEmpty()) { | 612 | if (!appliedFilters.isEmpty()) { |
604 | //We have an index lookup as starting point | 613 | //We have an index lookup as starting point |