|
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.
7 #ifndef swcdb_db_Cells_Mutable_h
8 #define swcdb_db_Cells_Mutable_h
16 namespace SWC {
namespace DB {
namespace Cells {
66 typedef std::shared_ptr<Mutable>
Ptr;
79 const uint64_t ttl_ns=0,
87 const uint32_t a_max_revs=1,
const uint64_t ttl_ns=0,
96 const uint32_t a_max_revs,
const uint64_t ttl_ns,
147 void configure(
const uint32_t revs,
const uint64_t ttl_ns,
152 for(
auto it = get<ConstIterator>(); it; ++it)
158 for(
auto it = get<ConstIterator>(); it; ++it)
167 void reset(
const uint32_t revs=1,
const uint64_t ttl_ns=0,
237 T get(
size_t offset) noexcept {
243 T get(
size_t offset)
const noexcept {
259 return get<T>(key, offset);
271 if(1 < offset && offset <
_size) {
279 return it.at(offset = 0);
283 if(offset + (step >>= 1) >=
_size)
284 offset =
_size - (step >>= 1);
292 return it.at(offset = 0);
301 return get<T>(key, offset);
313 if(1 < offset && offset <
_size) {
321 return it.at(offset = 0);
325 if(offset + (step >>= 1) >=
_size)
326 offset =
_size - (step >>= 1);
334 return it.at(offset = 0);
342 return get<Iterator>();
347 return get<Iterator>(offset);
352 return get<ConstIterator>();
357 return get<ConstIterator>(offset);
363 auto it = get<Iterator>(pos);
364 return it ? it.item() :
nullptr;
369 if((pos < 0 &&
_size <
size_t(-pos)) ||
size_t(pos) >=
_size)
371 auto it = get<ConstIterator>(pos < 0 ?
_size + pos : pos);
373 key.
copy(it.item()->key);
380 for(
auto it = get<ConstIterator>(key); it; ++it) {
384 res.
copy(it.item()->key);
394 if(
Iterator it = get<Iterator>(pos)) {
396 cell = std::move(it.item());
437 size_t offset_hint = 0;
438 const uint8_t* ptr = cells.
base;
439 size_t remain = cells.
fill();
440 for(
Cell cell; remain; ) {
441 cell.read(&ptr, &remain,
false);
442 add_raw(cell, &offset_hint, finalized);
449 uint32_t skip,
bool malformed,
451 size_t offset_hint = 0;
452 const uint8_t* ptr = cells.
base;
453 size_t remain = cells.
fill();
454 for(
Cell cell; remain; ) {
455 cell.read(&ptr, &remain,
false);
456 if((malformed && !skip) || (
457 (!upto_key.
empty() &&
460 add_raw(cell, &offset_hint, finalized);
470 add_raw(e_cell, &offset, finalized);
474 void add_raw(
const Cell& e_cell,
size_t* offsetp,
bool finalized) {
476 add_raw(e_cell, offsetp, it, finalized);
505 Interval& intval, uint32_t threshold,
518 for(
auto it = get<ConstIterator>(); it; ++it) {
519 if(!it.item()->has_expired(
ttl))
520 it.item()->write(cells);
526 auto it = get<ConstIterator>();
527 for(
Cell* cell; it; ) {
557 size_t& count,
size_t& skips)
const;
561 Mutable& cells,
bool finalized)
const {
566 for(
auto it=get<ConstIterator>(after); it; ++it) {
576 cells.
add_raw(*cell, finalized);
590 auto it_nxt = it + 1;
591 if(!it->back()->key.equal(it_nxt->front()->key)) {
594 cells.
_add(*it_cell.item());
612 size_t chk_bytes = 0;
613 bool found_at =
false;
614 auto it = get<Iterator>();
616 for(
Cell* cell; it; ) {
621 chk_bytes += cell->encoded_length();
622 if((chk_size >= count || chk_bytes >= bytes) &&
623 !cell->key.equal(it.item()->key)) {
633 if(!loaded || it.item()->has_expired(
ttl)) {
639 it_at.remove(
_size - chk_size);
663 void print(std::ostream& out,
bool with_cells=
false)
const;
684 _bytes += cell.encoded_length();
690 _bytes -= cell.encoded_length();
719 for(
auto c = number; c && it_del; ++it_del,--c) {
721 delete it_del.item();
730 while(it && key.
equal(it.item()->key)) {
748 #ifdef SWC_IMPL_SOURCE
752 #endif // swcdb_db_Cells_Mutable_h
SWC_CAN_INLINE void add_raw(const DynamicBuffer &cells, bool finalized)
constexpr SWC_CAN_INLINE Cell & back() noexcept
constexpr SWC_CAN_INLINE ConstIterator GetConstIterator(size_t offset) const noexcept
constexpr SWC_CAN_INLINE bool removal() const noexcept
SWC_CAN_INLINE void add_raw(const Cell &e_cell, bool finalized)
void scan_test_use(const Specs::Interval &specs, DynamicBuffer &result, size_t &count, size_t &skips) const
constexpr SWC_CAN_INLINE size_t size() const noexcept
SWC_CAN_INLINE ~Mutable() noexcept
void write_and_free(DynamicBuffer &cells, uint32_t &cell_count, Interval &intval, uint32_t threshold, uint32_t max_cells)
constexpr SWC_CAN_INLINE value_type & front() noexcept
SWC_CAN_INLINE void clear() noexcept(_NoExceptDestructor)
#define SWC_LOG_OUT(pr, _code_)
constexpr T get(size_t offset) const noexcept
Mutable & operator=(const Mutable &other)=delete
constexpr SWC_CAN_INLINE Cell * operator[](size_t pos) noexcept
SWC_CAN_INLINE void expand(Interval &interval) const
void configure(const uint32_t revs, const uint64_t ttl_ns, const Types::Column typ, bool finalized)
SWC_CAN_INLINE void expand_end(const Cell &cell)
void scan_version_single(ReqScan *req) const
SWC_CAN_INLINE void ensure(size_t len)
constexpr SWC_CAN_INLINE bool equal(const Key &other) const noexcept
void scan_version_multi(ReqScan *req) const
SWC_CAN_INLINE bool get(const DB::Cell::Key &key, Condition::Comp comp, DB::Cell::Key &res) const
SWC_CAN_INLINE T get(const DB::Cell::Key &key) const
Mutable(const Mutable &)=delete
SWC_CAN_INLINE void takeout_begin(size_t pos, Cell *&cell)
SWC_CAN_INLINE void _remove_overhead(Iterator &it, const DB::Cell::Key &key, uint32_t revs)
T get(const DB::Cell::Key &key, size_t &offset) const
SWC_CAN_INLINE bool has_expired(const int64_t ttl) const noexcept
SWC_CAN_INLINE bool scan_after(const DB::Cell::Key &after, const DB::Cell::Key &to, Mutable &cells, bool finalized) const
SWC_CAN_INLINE void check_sequence(const char *msg, bool w_assert=true) const
SWC_CAN_INLINE void _remove(Iterator &it)
T get(const DB::Cell::Key &key, size_t &offset)
SWC_CAN_INLINE Mutable & operator=(Mutable &&other) noexcept
SWC_CAN_INLINE void split(size_t split_at, VectorsVector &to)
SWC_CAN_INLINE void add_sorted(const Cell &cell, bool no_value=false)
Core::Vector< Cell *, uint32_t > VectorT
SWC_CAN_INLINE Mutable(const Types::KeySeq a_key_seq, const uint32_t a_max_revs, const uint64_t ttl_ns, const Types::Column a_type, const StaticBuffer &buffer)
SWC_CAN_INLINE void _adjust_copy(Cell &cell, const Cell &other)
constexpr SWC_CAN_INLINE bool empty() const noexcept
SWC_CAN_INLINE void scan(ReqScan *req) const
SWC_CAN_INLINE void add_sorted(Cell *cell)
SWC_CAN_INLINE void takeout(size_t pos, Cell *&cell)
SWC_CAN_INLINE void _remove(Iterator &it, size_t number, bool wdel=true)
SWC_CAN_INLINE void add(VectorsVector &&other)
constexpr SWC_CAN_INLINE size_t size_of_internal() const noexcept
constexpr SWC_CAN_INLINE value_type & back() noexcept
The SWC-DB C++ namespace 'SWC'.
SWC_CAN_INLINE void expand_begin(Interval &interval) const
SWC_CAN_INLINE void free() noexcept
bool SWC_CONST_FUNC is_counter(const Column typ) noexcept
void _add_plain_version_single(const Cell &e_cell, Iterator &it, size_t &offset)
constexpr SWC_CAN_INLINE Cell & front() const noexcept
void copy(const Key &other)
void _add_unfinalized(const Cell &e_cell, Iterator &it, size_t &offset)
SWC_CAN_INLINE Mutable(const Types::KeySeq a_key_seq, const uint32_t a_max_revs=1, const uint64_t ttl_ns=0, const Types::Column a_type=Types::Column::PLAIN)
SWC_CAN_INLINE void takeout_end(size_t pos, Cell *&cell)
SWC_CAN_INLINE void push_back(const value_type &value)
constexpr SWC_CAN_INLINE bool empty() const noexcept
void _add_plain_version_multi(const Cell &e_cell, Iterator &it, size_t &offset)
constexpr SWC_CAN_INLINE void _remove(const Cell &cell) noexcept
SWC_CAN_INLINE void add_raw(const DynamicBuffer &cells, const DB::Cell::Key &upto_key, const DB::Cell::Key &from_key, uint32_t skip, bool malformed, bool finalized)
SWC_CAN_INLINE void add_raw(const Cell &e_cell, size_t *offsetp, bool finalized)
Container::ConstIterator ConstIterator
constexpr SWC_CAN_INLINE size_t size_of_internal() const noexcept
void print(std::ostream &out, bool with_cells=false) const
SWC_CAN_INLINE void shrink_to_fit(size_type sz=0)
const Types::KeySeq key_seq
Core::VectorsVector< Core::Vector< VectorT, uint32_t, 1 >, VectorT, 8192 > Container
constexpr SWC_CAN_INLINE size_t fill() const noexcept
constexpr SWC_CAN_INLINE bool has_one_key() const noexcept
constexpr SWC_CAN_INLINE size_t encoded_length(bool no_value=false) const noexcept
SWC_CAN_INLINE void expand_begin(const Cell &cell)
SWC_CAN_INLINE void reset(const uint32_t revs=1, const uint64_t ttl_ns=0, const Types::Column typ=Types::Column::PLAIN)
constexpr SWC_CAN_INLINE T get() noexcept
SWC_CAN_INLINE Mutable(Mutable &&other) noexcept
SWC_CAN_INLINE void write(DynamicBuffer &cells) const
constexpr SWC_CAN_INLINE Cell & back() const noexcept
constexpr SWC_CAN_INLINE ConstIterator GetConstIterator() const noexcept
SWC_CAN_INLINE void _insert(Iterator &it, const Cell &cell)
constexpr static const uint8_t NARROW_SIZE
std::shared_ptr< Mutable > Ptr
constexpr SWC_CAN_INLINE Iterator GetIterator() noexcept
SWC_CAN_INLINE void add_raw(const Cell &e_cell, size_t *offsetp, Iterator &it, bool finalized)
SWC_CAN_INLINE size_t add_sorted(const uint8_t *ptr, size_t remain)
Container::Iterator Iterator
void _add_remove(const Cell &e_cell, Iterator &it, size_t &offset)
SWC_CAN_INLINE void finalize_raw()
SWC_CAN_INLINE void take_sorted(Mutable &other)
SWC_CAN_INLINE void expand_end(Interval &interval) const
constexpr SWC_CAN_INLINE T get() noexcept
constexpr SWC_CAN_INLINE size_t size_bytes() const noexcept
static SWC_CAN_INLINE Ptr make(const Types::KeySeq key_seq, const uint32_t max_revs=1, const uint64_t ttl_ns=0, const Types::Column type=Types::Column::PLAIN)
void copy(const Cell &other, bool no_value=false)
SWC_CAN_INLINE void get(int32_t pos, DB::Cell::Key &key) const
constexpr SWC_CAN_INLINE const_iterator cbegin() const noexcept
constexpr SWC_CAN_INLINE size_type size() const noexcept
SWC_CAN_INLINE bool split(Mutable &cells, size_t count, size_t bytes, bool loaded)
constexpr SWC_CAN_INLINE void _add(const Cell &cell) noexcept
SWC_CAN_INLINE T get(const DB::Cell::Key &key)
constexpr SWC_CAN_INLINE Cell & front() noexcept
void _add_counter(const Cell &e_cell, Iterator &it, size_t &offset)
constexpr SWC_CAN_INLINE T get() const noexcept
constexpr T get(size_t offset) noexcept
Condition::Comp compare(const Types::KeySeq seq, const Cell::Key &key, const Cell::Key &other) SWC_ATTRIBS((SWC_ATTRIB_O3))
constexpr SWC_CAN_INLINE Iterator GetIterator(size_t offset) noexcept
SWC_CAN_INLINE T get(const Specs::Interval &specs) const