Return unordered_map from prefix_get.
This commit is contained in:
parent
fab24473ca
commit
81d14838c4
|
@ -26,6 +26,7 @@
|
||||||
#include "td/utils/tl_storers.h"
|
#include "td/utils/tl_storers.h"
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <unordered_map>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
namespace td {
|
namespace td {
|
||||||
|
@ -218,9 +219,9 @@ class BinlogKeyValue final : public KeyValueSyncInterface {
|
||||||
binlog_->lazy_sync(std::move(promise));
|
binlog_->lazy_sync(std::move(promise));
|
||||||
}
|
}
|
||||||
|
|
||||||
FlatHashMap<string, string> prefix_get(Slice prefix) final {
|
std::unordered_map<string, string> prefix_get(Slice prefix) final {
|
||||||
auto lock = rw_mutex_.lock_write().move_as_ok();
|
auto lock = rw_mutex_.lock_write().move_as_ok();
|
||||||
FlatHashMap<string, string> res;
|
std::unordered_map<string, string> res;
|
||||||
for (const auto &kv : map_) {
|
for (const auto &kv : map_) {
|
||||||
if (begins_with(kv.first, prefix)) {
|
if (begins_with(kv.first, prefix)) {
|
||||||
res.emplace(kv.first.substr(prefix.size()), kv.second.first);
|
res.emplace(kv.first.substr(prefix.size()), kv.second.first);
|
||||||
|
|
|
@ -11,6 +11,8 @@
|
||||||
#include "td/utils/Promise.h"
|
#include "td/utils/Promise.h"
|
||||||
#include "td/utils/Slice.h"
|
#include "td/utils/Slice.h"
|
||||||
|
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
namespace td {
|
namespace td {
|
||||||
|
|
||||||
class KeyValueSyncInterface {
|
class KeyValueSyncInterface {
|
||||||
|
@ -32,7 +34,7 @@ class KeyValueSyncInterface {
|
||||||
|
|
||||||
virtual string get(const string &key) = 0;
|
virtual string get(const string &key) = 0;
|
||||||
|
|
||||||
virtual FlatHashMap<string, string> prefix_get(Slice prefix) = 0;
|
virtual std::unordered_map<string, string> prefix_get(Slice prefix) = 0;
|
||||||
|
|
||||||
virtual FlatHashMap<string, string> get_all() = 0;
|
virtual FlatHashMap<string, string> get_all() = 0;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user