This commit is contained in:
Roman Gershman 2022-10-02 08:51:21 +03:00
parent 08779b154b
commit 7919135f7f
No known key found for this signature in database
GPG Key ID: 6568CCAB9736B618
5 changed files with 63 additions and 6 deletions

View File

@ -1,6 +1,6 @@
add_library(dfly_core compact_object.cc dragonfly_core.cc extent_tree.cc
external_alloc.cc interpreter.cc mi_memory_resource.cc
segment_allocator.cc small_string.cc tx_queue.cc dense_set.cc string_set.cc)
segment_allocator.cc small_string.cc tx_queue.cc dense_set.cc string_set.cc string_map.cc)
cxx_link(dfly_core base absl::flat_hash_map absl::str_format redis_lib TRDP::lua lua_modules
Boost::fiber crypto)

25
src/core/string_map.cc Normal file
View File

@ -0,0 +1,25 @@
// Copyright 2022, DragonflyDB authors. All rights reserved.
// See LICENSE for licensing terms.
//
#include "core/string_map.h"
using namespace std;
namespace dfly {
bool StringMap::AddOrSet(string_view field, string_view value, uint32_t ttl_sec) {
}
bool StringMap::Erase(string_view field) {
}
bool StringMap::Contains(string_view field) const {
}
void StringMap::Clear() {
}
} // namespace dfly

33
src/core/string_map.h Normal file
View File

@ -0,0 +1,33 @@
// Copyright 2022, DragonflyDB authors. All rights reserved.
// See LICENSE for licensing terms.
//
#pragma once
#include "core/dense_set.h"
extern "C" {
#include "redis/sds.h"
}
namespace dfly {
class StringMap : public DenseSet {
public:
StringMap(std::pmr::memory_resource* res = std::pmr::get_default_resource()) : DenseSet(res) {
}
~StringMap() {
Clear();
}
bool AddOrSet(std::string_view field, std::string_view value, uint32_t ttl_sec = UINT32_MAX);
bool Erase(std::string_view s1);
bool Contains(std::string_view s1) const;
void Clear();
};
} // namespace dfly

View File

@ -158,10 +158,6 @@ std::optional<std::string> StringSet::Pop() {
return ret;
}
sds StringSet::PopRaw() {
return (sds)PopInternal();
}
uint32_t StringSet::Scan(uint32_t cursor, const std::function<void(const sds)>& func) const {
return DenseSet::Scan(cursor, [func](const void* ptr) { func((sds)ptr); });
}

View File

@ -1,3 +1,7 @@
// Copyright 2022, DragonflyDB authors. All rights reserved.
// See LICENSE for licensing terms.
//
#pragma once
#include <cstdint>
@ -26,7 +30,6 @@ class StringSet : public DenseSet {
void Clear();
std::optional<std::string> Pop();
sds PopRaw();
~StringSet() {
Clear();