diff options
author | Rémi Nicole <nicole@kolabsystems.com> | 2018-05-28 10:08:49 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2018-05-28 10:09:31 +0200 |
commit | f400cee1d5896577c22626d0cf50478057989857 (patch) | |
tree | e24e77562e0e893f281965c512ca4b74f88b20d3 /common/typeindex.h | |
parent | 411c7cdad70c5c7902002545fd107ed1b2ac06ac (diff) | |
download | sink-f400cee1d5896577c22626d0cf50478057989857.tar.gz sink-f400cee1d5896577c22626d0cf50478057989857.zip |
Implement ranged queries
Summary:
Notes:
- For now, only for QDateTime indexes
- Invalid QDateTimes are stored in the index (subject to change)
- Should be a drop-in replacement from ValueIndexes (except for `In` and `Contains` queries)
Reviewers: cmollekopf
Tags: #sink
Differential Revision: https://phabricator.kde.org/D13105
Diffstat (limited to 'common/typeindex.h')
-rw-r--r-- | common/typeindex.h | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/common/typeindex.h b/common/typeindex.h index b8b4d52..793dc1e 100644 --- a/common/typeindex.h +++ b/common/typeindex.h | |||
@@ -38,6 +38,8 @@ public: | |||
38 | 38 | ||
39 | template <typename T> | 39 | template <typename T> |
40 | void addProperty(const QByteArray &property); | 40 | void addProperty(const QByteArray &property); |
41 | template <typename T> | ||
42 | void addSortedProperty(const QByteArray &property); | ||
41 | template <typename T, typename S> | 43 | template <typename T, typename S> |
42 | void addPropertyWithSorting(const QByteArray &property, const QByteArray &sortProperty); | 44 | void addPropertyWithSorting(const QByteArray &property, const QByteArray &sortProperty); |
43 | 45 | ||
@@ -54,9 +56,9 @@ public: | |||
54 | } | 56 | } |
55 | 57 | ||
56 | template <typename T> | 58 | template <typename T> |
57 | void addPropertyWithSorting() | 59 | void addSortedProperty() |
58 | { | 60 | { |
59 | addPropertyWithSorting<typename T::Type>(T::name); | 61 | addSortedProperty<typename T::Type>(T::name); |
60 | } | 62 | } |
61 | 63 | ||
62 | template <typename Left, typename Right> | 64 | template <typename Left, typename Right> |
@@ -112,14 +114,17 @@ private: | |||
112 | friend class Sink::Storage::EntityStore; | 114 | friend class Sink::Storage::EntityStore; |
113 | void updateIndex(bool add, const QByteArray &identifier, const Sink::ApplicationDomain::ApplicationDomainType &entity, Sink::Storage::DataStore::Transaction &transaction, const QByteArray &resourceInstanceId); | 115 | void updateIndex(bool add, const QByteArray &identifier, const Sink::ApplicationDomain::ApplicationDomainType &entity, Sink::Storage::DataStore::Transaction &transaction, const QByteArray &resourceInstanceId); |
114 | QByteArray indexName(const QByteArray &property, const QByteArray &sortProperty = QByteArray()) const; | 116 | QByteArray indexName(const QByteArray &property, const QByteArray &sortProperty = QByteArray()) const; |
117 | QByteArray sortedIndexName(const QByteArray &property) const; | ||
115 | Sink::Log::Context mLogCtx; | 118 | Sink::Log::Context mLogCtx; |
116 | QByteArray mType; | 119 | QByteArray mType; |
117 | QByteArrayList mProperties; | 120 | QByteArrayList mProperties; |
118 | QMap<QByteArray, QByteArray> mSortedProperties; | 121 | QByteArrayList mSortedProperties; |
122 | QMap<QByteArray, QByteArray> mGroupedSortedProperties; | ||
119 | //<Property, ResultProperty> | 123 | //<Property, ResultProperty> |
120 | QMap<QByteArray, QByteArray> mSecondaryProperties; | 124 | QMap<QByteArray, QByteArray> mSecondaryProperties; |
121 | QList<Sink::Indexer::Ptr> mCustomIndexer; | 125 | QList<Sink::Indexer::Ptr> mCustomIndexer; |
122 | Sink::Storage::DataStore::Transaction *mTransaction; | 126 | Sink::Storage::DataStore::Transaction *mTransaction; |
123 | QHash<QByteArray, std::function<void(bool, const QByteArray &identifier, const QVariant &value, Sink::Storage::DataStore::Transaction &transaction)>> mIndexer; | 127 | QHash<QByteArray, std::function<void(bool, const QByteArray &identifier, const QVariant &value, Sink::Storage::DataStore::Transaction &transaction)>> mIndexer; |
124 | QHash<QByteArray, std::function<void(bool, const QByteArray &identifier, const QVariant &value, const QVariant &sortValue, Sink::Storage::DataStore::Transaction &transaction)>> mSortIndexer; | 128 | QHash<QByteArray, std::function<void(bool, const QByteArray &identifier, const QVariant &value, Sink::Storage::DataStore::Transaction &transaction)>> mSortIndexer; |
129 | QHash<QByteArray, std::function<void(bool, const QByteArray &identifier, const QVariant &value, const QVariant &sortValue, Sink::Storage::DataStore::Transaction &transaction)>> mGroupedSortIndexer; | ||
125 | }; | 130 | }; |