diff options
author | Minijackson <minijackson@riseup.net> | 2018-05-25 11:28:22 +0200 |
---|---|---|
committer | Minijackson <minijackson@riseup.net> | 2018-05-25 11:29:30 +0200 |
commit | 00717f6c8b8a9c6dbd56a80d685c5082fc03f6a5 (patch) | |
tree | eb0871b7518234c3db3e2d647b0b7c020253accb /common/index.cpp | |
parent | c095e82143fd16c84263d990b96590b3b0d12a78 (diff) | |
download | sink-00717f6c8b8a9c6dbd56a80d685c5082fc03f6a5.tar.gz sink-00717f6c8b8a9c6dbd56a80d685c5082fc03f6a5.zip |
Implement range queries
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 | } | ||