 |
SWC-DB
v0.5.12 C++ documentations
SWC-DB© (Super Wide Column Database) - High Performance Scalable Database (https://github.com/kashirin-alex/swc-db)
|
Go to the documentation of this file.
6 #ifndef swcdb_core_PageArena_h
7 #define swcdb_core_PageArena_h
11 #include <unordered_set>
14 namespace SWC {
namespace Core {
namespace Mem {
37 Item(
const uint8_t* ptr, uint32_t
size) noexcept
43 const uint8_t* dp =
data_;
44 for(uint32_t sz =
size_; sz; --sz, ++dp)
45 ret += (ret << 3) + *dp;
60 uint32_t
size() const noexcept {
64 const uint8_t*
data() const noexcept {
68 size_t hash() const noexcept {
84 return std::string_view(
reinterpret_cast<const char*
>(
data_),
size_);
88 return size_ < other.size_ ||
89 (
size_ == other.size() &&
99 return lhs->
equal(*rhs);
111 return lhs->
less(*rhs);
120 typedef std::unordered_set<Item::Ptr, Item::Hash, Item::Equal>
PageBase;
132 auto r = insert(tmp);
134 (*r.first)->allocate();
136 tmp->data_ =
nullptr;
139 return (*r.first)->use();
146 if(it != end() && !ptr->
count) {
264 return _pages[(sz > 1022 ? 1023 : (sz ? sz-1 : 0) ) >> 2];
291 namespace SWC {
namespace Env {
297 namespace SWC {
namespace Core {
namespace Mem {
319 :
ptr(other.ptr ? other.ptr->use() :
nullptr) {
389 #endif // swcdb_core_PageArena_h
void use(const uint8_t *buf, uint32_t size)
SWC::Core::Mem::Arena PageArena
Item::Ptr use(const uint8_t *buf, uint32_t size)
size_t _hash() const noexcept
Core::Atomic< uint64_t > count
bool operator()(const Ptr lhs, const Ptr rhs) const
bool operator()(const Ptr lhs, const Ptr rhs) const
Page & page_by_sz(uint32_t sz)
void use(const ItemPtr &other)
size_t hash() const noexcept
SWC_CAN_INLINE bool eq(const uint8_t *p1, uint32_t p1_len, const uint8_t *p2, uint32_t p2_len) noexcept
size_t operator()(const Ptr arr) const noexcept
Item & operator=(Item &&)=delete
int mem_cmp(const uint8_t *b1, const uint8_t *b2, size_t count) noexcept SWC_ATTRIBS((SWC_ATTRIB_O3))
static Item::Ptr make(const uint8_t *buf, uint32_t size)
ItemPtr & operator=(const ItemPtr &other)
ItemPtr & operator=(ItemPtr &&other)
The SWC-DB C++ namespace 'SWC'.
ItemPtr(ItemPtr &&other) noexcept
ItemPtr(const uint8_t *buf, uint32_t size)
std::unordered_set< Item::Ptr, Item::Hash, Item::Equal > PageBase
bool SWC_PURE_FUNC operator==(ItemPtr l, ItemPtr r)
Item::Ptr use(const uint8_t *buf, uint32_t size)
uint32_t size() const noexcept
const Page & page(uint8_t idx) const
bool equal(const Item &other) const noexcept
std::string_view to_string() const
Item(const uint8_t *ptr, uint32_t size) noexcept
Item & operator=(const Item &)=delete
const uint8_t * data() const noexcept
const uint8_t * data() const
bool less(const Item &other) const noexcept
Item(const Item &)=delete
constexpr SWC_CAN_INLINE T fetch_sub(T v) noexcept
constexpr SWC_CAN_INLINE T fetch_add(T v) noexcept
ItemPtr(const ItemPtr &other) noexcept
Item(Item &&other)=delete
std::string_view to_string() const noexcept