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/domain | |
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/domain')
-rw-r--r-- | common/domain/typeimplementations.cpp | 3 | ||||
-rw-r--r-- | common/domain/typeimplementations_p.h | 20 |
2 files changed, 22 insertions, 1 deletions
diff --git a/common/domain/typeimplementations.cpp b/common/domain/typeimplementations.cpp index a8f4baf..2b2d2ac 100644 --- a/common/domain/typeimplementations.cpp +++ b/common/domain/typeimplementations.cpp | |||
@@ -65,7 +65,8 @@ typedef IndexConfig<Addressbook, | |||
65 | 65 | ||
66 | typedef IndexConfig<Event, | 66 | typedef IndexConfig<Event, |
67 | ValueIndex<Event::Uid>, | 67 | ValueIndex<Event::Uid>, |
68 | SortedIndex<Event::StartTime> | 68 | SortedIndex<Event::StartTime>, |
69 | SampledPeriodIndex<Event::StartTime, Event::EndTime> | ||
69 | > EventIndexConfig; | 70 | > EventIndexConfig; |
70 | 71 | ||
71 | typedef IndexConfig<Todo, | 72 | typedef IndexConfig<Todo, |
diff --git a/common/domain/typeimplementations_p.h b/common/domain/typeimplementations_p.h index fc08048..51af113 100644 --- a/common/domain/typeimplementations_p.h +++ b/common/domain/typeimplementations_p.h | |||
@@ -126,6 +126,26 @@ public: | |||
126 | } | 126 | } |
127 | }; | 127 | }; |
128 | 128 | ||
129 | template <typename RangeBeginProperty, typename RangeEndProperty> | ||
130 | class SampledPeriodIndex | ||
131 | { | ||
132 | static_assert(std::is_same<typename RangeBeginProperty::Type, QDateTime>::value && | ||
133 | std::is_same<typename RangeEndProperty::Type, QDateTime>::value, | ||
134 | "Date range index is not supported for types other than 'QDateTime's"); | ||
135 | |||
136 | public: | ||
137 | static void configure(TypeIndex &index) | ||
138 | { | ||
139 | index.addSampledPeriodIndex<RangeBeginProperty, RangeEndProperty>(); | ||
140 | } | ||
141 | |||
142 | template <typename EntityType> | ||
143 | static QMap<QByteArray, int> databases() | ||
144 | { | ||
145 | return {{QByteArray{EntityType::name} +".index." + RangeBeginProperty::name + ".range." + RangeEndProperty::name, 1}}; | ||
146 | } | ||
147 | }; | ||
148 | |||
129 | template <typename EntityType, typename ... Indexes> | 149 | template <typename EntityType, typename ... Indexes> |
130 | class IndexConfig | 150 | class IndexConfig |
131 | { | 151 | { |