From 00717f6c8b8a9c6dbd56a80d685c5082fc03f6a5 Mon Sep 17 00:00:00 2001 From: Minijackson Date: Fri, 25 May 2018 11:28:22 +0200 Subject: Implement range queries --- common/index.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'common/index.cpp') 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) lookup(key, [&](const QByteArray &value) { result = QByteArray(value.constData(), value.size()); }, [](const Index::Error &) { }); return result; } + +void Index::rangeLookup(const QByteArray &lowerBound, const QByteArray &upperBound, + const std::function &resultHandler, + const std::function &errorHandler) +{ + mDb.findAllInRange(lowerBound, upperBound, + [&](const QByteArray &key, const QByteArray &value) { + resultHandler(value); + }, + [&](const Sink::Storage::DataStore::Error &error) { + SinkWarningCtx(mLogCtx) << "Error while retrieving value:" << error << mName; + errorHandler(Error(error.store, error.code, error.message)); + }); +} -- cgit v1.2.3