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/index.cpp | |
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/index.cpp')
-rw-r--r-- | common/index.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/common/index.cpp b/common/index.cpp index ff87ae2..94b2eea 100644 --- a/common/index.cpp +++ b/common/index.cpp | |||
@@ -59,3 +59,17 @@ QByteArray Index::lookup(const QByteArray &key) | |||
59 | lookup(key, [&](const QByteArray &value) { result = QByteArray(value.constData(), value.size()); }, [](const Index::Error &) { }); | 59 | lookup(key, [&](const QByteArray &value) { result = QByteArray(value.constData(), value.size()); }, [](const Index::Error &) { }); |
60 | return result; | 60 | return result; |
61 | } | 61 | } |
62 | |||
63 | void Index::rangeLookup(const QByteArray &lowerBound, const QByteArray &upperBound, | ||
64 | const std::function<void(const QByteArray &value)> &resultHandler, | ||
65 | const std::function<void(const Error &error)> &errorHandler) | ||
66 | { | ||
67 | mDb.findAllInRange(lowerBound, upperBound, | ||
68 | [&](const QByteArray &key, const QByteArray &value) { | ||
69 | resultHandler(value); | ||
70 | }, | ||
71 | [&](const Sink::Storage::DataStore::Error &error) { | ||
72 | SinkWarningCtx(mLogCtx) << "Error while retrieving value:" << error << mName; | ||
73 | errorHandler(Error(error.store, error.code, error.message)); | ||
74 | }); | ||
75 | } | ||