SWC-DB  v0.5.12 C++ documentations
SWC-DB© (Super Wide Column Database) - High Performance Scalable Database (https://github.com/kashirin-alex/swc-db)
Mutable.h
Go to the documentation of this file.
1 /*
2  * SWC-DB© Copyright since 2019 Alex Kashirin <kashirin.alex@gmail.com>
3  * License details at <https://github.com/kashirin-alex/swc-db/#license>
4  */
5 
6 
7 #ifndef swcdb_db_Cells_Mutable_h
8 #define swcdb_db_Cells_Mutable_h
9 
10 
11 #include "swcdb/db/Cells/Cell.h"
14 
15 
16 namespace SWC { namespace DB { namespace Cells {
17 
18 class ReqScan;
19 
20 
21 class Mutable final {
22 
23  /*
24  using VectorT = std::vector<Cell*>;
25  typedef Core::VectorsVector<
26  std::vector<VectorT>,
27  VectorT,
28  8192
29  > Container;
30  */
31 
32 
34  typedef Core::VectorsVector<
36  VectorT,
37  8192
39 
40 
41  /*
42  #include "swcdb/core/ArraysArraysVector.h"
43  typedef Core::ArraysArraysVector<
44  Core::ArraysArray < Core::Array<Cell*, uint8_t, 127>, uint8_t, 127 >
45  > Container;
46  */
47  /*
48  > Vector: (no ptr Cell)
49  Array<Cell, uint8_t, 83> (83 x 48 bytes + 8 bytes) = 3992 bytes
50  ArraysArray<Array*, uint8_t, 100> (100 x 8 bytes + 8 bytes) = 808 bytes
51  ArraysArraysVector<ArraysArray*> (N x 8 bytes + 16 bytes) = 16 + 8xN
52  > Vector: (Pointer Cell)
53  Array<Cell*, uint8_t, 127> (127 x 8 bytes + 8 bytes) = 1024 bytes
54  ArraysArray<Array*, uint8_t, 100> (127 x 8 bytes + 8 bytes) = 1024 bytes
55  ArraysArraysVector<ArraysArray*> (N x 8 bytes + 16 bytes) = 16 + 8xN
56  */
57 
59  size_t _bytes;
60  size_t _size;
61  constexpr static const uint8_t NARROW_SIZE = 20;
62 
63 
64  public:
65 
66  typedef std::shared_ptr<Mutable> Ptr;
67 
68  using Iterator = Container::Iterator;
69  using ConstIterator = Container::ConstIterator;
70 
73  uint32_t max_revs;
74  uint64_t ttl;
75 
77  static Ptr make(const Types::KeySeq key_seq,
78  const uint32_t max_revs=1,
79  const uint64_t ttl_ns=0,
80  const Types::Column type=Types::Column::PLAIN) {
81  return Ptr(new Mutable(key_seq, max_revs, ttl_ns, type));
82  }
83 
84 
86  Mutable(const Types::KeySeq a_key_seq,
87  const uint32_t a_max_revs=1, const uint64_t ttl_ns=0,
88  const Types::Column a_type=Types::Column::PLAIN)
89  : _container(), _bytes(0), _size(0),
90  key_seq(a_key_seq), type(a_type), max_revs(a_max_revs),
91  ttl(ttl_ns) {
92  }
93 
95  Mutable(const Types::KeySeq a_key_seq,
96  const uint32_t a_max_revs, const uint64_t ttl_ns,
97  const Types::Column a_type,
98  const StaticBuffer& buffer)
99  : _container(), _bytes(0), _size(0),
100  key_seq(a_key_seq), type(a_type), max_revs(a_max_revs),
101  ttl(ttl_ns) {
102  add_sorted(buffer.base, buffer.size);
103  }
104 
106  Mutable(Mutable&& other) noexcept
107  : _container(std::move(other._container)),
108  _bytes(other._bytes), _size(other._size),
109  key_seq(other.key_seq),
110  type(other.type), max_revs(other.max_revs), ttl(other.ttl) {
111  other._bytes = 0;
112  other._size = 0;
113  }
114 
115  Mutable(const Mutable&) = delete;
116  Mutable& operator=(const Mutable& other) = delete;
117 
119  Mutable& operator=(Mutable&& other) noexcept {
120  free();
121  _container = std::move(other._container);
122  _bytes = other._bytes;
123  _size = other._size;
124  other._bytes = 0;
125  other._size = 0;
126  type = other.type;
127  max_revs = other.max_revs;
128  ttl = other.ttl;
129  return *this;
130  }
131 
133  void take_sorted(Mutable& other) {
134  if(!other.empty()) {
135  if(empty()) {
136  _container = std::move(other._container);
137  } else {
138  _container.add(std::move(other._container));
139  }
140  _bytes += other._bytes;
141  _size += other._size;
142  other._bytes = 0;
143  other._size = 0;
144  }
145  }
146 
147  void configure(const uint32_t revs, const uint64_t ttl_ns,
148  const Types::Column typ, bool finalized);
149 
151  ~Mutable() noexcept {
152  for(auto it = get<ConstIterator>(); it; ++it)
153  delete it.item();
154  }
155 
157  void free() noexcept {
158  for(auto it = get<ConstIterator>(); it; ++it)
159  delete it.item();
160  _container.clear();
162  _bytes = 0;
163  _size = 0;
164  }
165 
167  void reset(const uint32_t revs=1, const uint64_t ttl_ns=0,
168  const Types::Column typ=Types::Column::PLAIN) {
169  free();
170  configure(revs, ttl_ns, typ, false);
171  }
172 
173 
174  constexpr SWC_CAN_INLINE
175  size_t size() const noexcept {
176  return _size;
177  }
178 
179  constexpr SWC_CAN_INLINE
180  size_t size_bytes() const noexcept {
181  return _bytes;
182  }
183 
184  constexpr SWC_CAN_INLINE
185  bool empty() const noexcept {
186  return !_size;
187  }
188 
189  constexpr SWC_CAN_INLINE
190  size_t size_of_internal() const noexcept {
191  return _bytes
192  + _size * sizeof(Cell)
194  }
195 
196 
197  constexpr SWC_CAN_INLINE
198  Cell& front() noexcept {
199  return *_container.front();
200  }
201 
202  constexpr SWC_CAN_INLINE
203  Cell& back() noexcept {
204  return *_container.back();
205  }
206 
207  constexpr SWC_CAN_INLINE
208  Cell& front() const noexcept {
209  return *_container.front();
210  }
211 
212  constexpr SWC_CAN_INLINE
213  Cell& back() const noexcept {
214  return *_container.back();
215  }
216 
217  constexpr SWC_CAN_INLINE
218  bool has_one_key() const noexcept {
219  return front().key.equal(back().key);
220  }
221 
222 
223  template<typename T>
224  constexpr SWC_CAN_INLINE
225  T get() noexcept {
226  return _container.get<T>();
227  }
228 
229  template<typename T>
230  constexpr SWC_CAN_INLINE
231  T get() const noexcept {
232  return _container.get<T>();
233  }
234 
235  template<typename T>
236  constexpr// SWC_CAN_INLINE
237  T get(size_t offset) noexcept {
238  return _container.get<T>(offset);
239  }
240 
241  template<typename T>
242  constexpr// SWC_CAN_INLINE
243  T get(size_t offset) const noexcept {
244  return _container.get<T>(offset);
245  }
246 
247  template<typename T>
249  T get(const Specs::Interval& specs) const {
250  return specs.offset_key.empty()
251  ? (specs.range_begin.empty() ? get<T>() : get<T>(specs.range_begin))
252  : get<T>(specs.offset_key);
253  }
254 
255  template<typename T>
257  T get(const DB::Cell::Key& key) {
258  size_t offset = 0;
259  return get<T>(key, offset);
260  }
261 
262  template<typename T>
263  //SWC_CAN_INLINE
264  T get(const DB::Cell::Key& key, size_t& offset) {
265  T it = get<T>();
266  if(key.empty() || _size <= NARROW_SIZE) {
267  offset = 0;
268  return it;
269  }
270  size_t step = _size;
271  if(1 < offset && offset < _size) {
272  if((step -= offset) <= NARROW_SIZE)
273  step = NARROW_SIZE;
274  } else {
275  offset = step >>= 1;
276  }
277  try_get:
278  if(!(it.at(offset)))
279  return it.at(offset = 0);
280  if(DB::KeySeq::compare(key_seq, it.item()->key, key) == Condition::GT) {
281  if(step < NARROW_SIZE + max_revs)
282  return it;
283  if(offset + (step >>= 1) >= _size)
284  offset = _size - (step >>= 1);
285  else
286  offset += step;
287  goto try_get;
288  }
289  if((step >>= 1) <= NARROW_SIZE)
290  step += max_revs;
291  if(offset < step)
292  return it.at(offset = 0);
293  offset -= step;
294  goto try_get;
295  }
296 
297  template<typename T>
299  T get(const DB::Cell::Key& key) const {
300  size_t offset = 0;
301  return get<T>(key, offset);
302  }
303 
304  template<typename T>
305  //SWC_CAN_INLINE
306  T get(const DB::Cell::Key& key, size_t& offset) const {
307  T it = get<T>();
308  if(key.empty() || _size <= NARROW_SIZE) {
309  offset = 0;
310  return it;
311  }
312  size_t step = _size;
313  if(1 < offset && offset < _size) {
314  if((step -= offset) <= NARROW_SIZE)
315  step = NARROW_SIZE;
316  } else {
317  offset = step >>= 1;
318  }
319  try_get:
320  if(!(it.at(offset)))
321  return it.at(offset = 0);
322  if(DB::KeySeq::compare(key_seq, it.item()->key, key) == Condition::GT) {
323  if(step < NARROW_SIZE + max_revs)
324  return it;
325  if(offset + (step >>= 1) >= _size)
326  offset = _size - (step >>= 1);
327  else
328  offset += step;
329  goto try_get;
330  }
331  if((step >>= 1) <= NARROW_SIZE)
332  step += max_revs;
333  if(offset < step)
334  return it.at(offset = 0);
335  offset -= step;
336  goto try_get;
337  }
338 
339 
340  constexpr SWC_CAN_INLINE
341  Iterator GetIterator() noexcept {
342  return get<Iterator>();
343  }
344 
345  constexpr SWC_CAN_INLINE
346  Iterator GetIterator(size_t offset) noexcept {
347  return get<Iterator>(offset);
348  }
349 
350  constexpr SWC_CAN_INLINE
351  ConstIterator GetConstIterator() const noexcept {
352  return get<ConstIterator>();
353  }
354 
355  constexpr SWC_CAN_INLINE
356  ConstIterator GetConstIterator(size_t offset) const noexcept {
357  return get<ConstIterator>(offset);
358  }
359 
360 
361  constexpr SWC_CAN_INLINE
362  Cell* operator[](size_t pos) noexcept {
363  auto it = get<Iterator>(pos);
364  return it ? it.item() : nullptr;
365  }
366 
368  void get(int32_t pos, DB::Cell::Key& key) const {
369  if((pos < 0 && _size < size_t(-pos)) || size_t(pos) >= _size)
370  return;
371  auto it = get<ConstIterator>(pos < 0 ? _size + pos : pos);
372  if(it)
373  key.copy(it.item()->key);
374  }
375 
377  bool get(const DB::Cell::Key& key, Condition::Comp comp,
378  DB::Cell::Key& res) const {
379  Condition::Comp chk;
380  for(auto it = get<ConstIterator>(key); it; ++it) {
381  if((chk = DB::KeySeq::compare(key_seq, key, it.item()->key))
382  == Condition::GT
383  || (comp == Condition::GE && chk == Condition::EQ)){
384  res.copy(it.item()->key);
385  return true;
386  }
387  }
388  return false;
389  }
390 
391 
393  void takeout(size_t pos, Cell*& cell) {
394  if(Iterator it = get<Iterator>(pos)) {
395  _remove(*it.item());
396  cell = std::move(it.item());
397  it.remove();
398  }
399  }
400 
402  void takeout_begin(size_t pos, Cell*& cell) {
403  takeout(pos, cell);
404  }
405 
407  void takeout_end(size_t pos, Cell*& cell) {
408  takeout(_size - pos, cell);
409  }
410 
411 
413  void add_sorted(const Cell& cell, bool no_value=false) {
414  add_sorted(new Cell(cell, no_value));
415  }
416 
418  void add_sorted(Cell* cell) {
419  _add(*cell);
420  _container.push_back(cell);
421  }
422 
424  size_t add_sorted(const uint8_t* ptr, size_t remain) {
425  size_t count = 0;
426  _bytes += remain;
427  while(remain) {
428  _container.push_back(new Cell(&ptr, &remain, true));
429  ++count;
430  }
431  _size += count;
432  return count;
433  }
434 
436  void add_raw(const DynamicBuffer& cells, bool finalized) {
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);
443  }
444  }
445 
447  void add_raw(const DynamicBuffer& cells, const DB::Cell::Key& upto_key,
448  const DB::Cell::Key& from_key,
449  uint32_t skip, bool malformed,
450  bool finalized) {
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() &&
458  DB::KeySeq::compare(key_seq, upto_key, cell.key)!=Condition::GT) ||
459  DB::KeySeq::compare(key_seq, from_key, cell.key)==Condition::GT) ) {
460  add_raw(cell, &offset_hint, finalized);
461  } else {
462  --skip;
463  }
464  }
465  }
466 
468  void add_raw(const Cell& e_cell, bool finalized) {
469  size_t offset = 0;
470  add_raw(e_cell, &offset, finalized);
471  }
472 
474  void add_raw(const Cell& e_cell, size_t* offsetp, bool finalized) {
475  Iterator it = get<Iterator>(e_cell.key, *offsetp);
476  add_raw(e_cell, offsetp, it, finalized);
477  }
478 
480  void add_raw(const Cell& e_cell, size_t* offsetp, Iterator& it,
481  bool finalized) {
482  e_cell.removal()
483  ? _add_remove(e_cell, it, *offsetp)
485  ? (finalized
486  ? _add_counter(e_cell, it, *offsetp)
487  : _add_unfinalized(e_cell, it, *offsetp))
488  : (max_revs == 1
489  ? _add_plain_version_single(e_cell, it, *offsetp)
490  : _add_plain_version_multi(e_cell, it, *offsetp)
491  )
492  );
493  }
494 
496  void finalize_raw() {
497  if(size() > 1) {
498  if(Types::is_counter(type)) {
500  }
501  }
502  }
503 
504  void write_and_free(DynamicBuffer& cells, uint32_t& cell_count,
505  Interval& intval, uint32_t threshold,
506  uint32_t max_cells);
507 
508  bool write_and_free(const DB::Cell::Key& key_start,
509  const DB::Cell::Key& key_finish,
510  DynamicBuffer& cells, uint32_t threshold);
511 
512  bool write_and_free(DynamicBuffer& cells, uint32_t threshold);
513 
514 
516  void write(DynamicBuffer& cells) const {
517  cells.ensure(_bytes);
518  for(auto it = get<ConstIterator>(); it; ++it) {
519  if(!it.item()->has_expired(ttl))
520  it.item()->write(cells);
521  }
522  }
523 
525  void check_sequence(const char* msg, bool w_assert=true) const {
526  auto it = get<ConstIterator>();
527  for(Cell* cell; it; ) {
528  cell = it.item();
529  if(!it.next())
530  break;
531  if(DB::KeySeq::compare(key_seq, it.item()->key, cell->key) == Condition::GT) {
532  SWC_LOG_OUT(
533  LOG_ERROR,
534  SWC_LOG_OSTREAM << "BAD cells-sequence at " << msg;
535  cell->key.print(SWC_LOG_OSTREAM << "\n current-");
536  it.item()->key.print(SWC_LOG_OSTREAM << "\n next-");
537  );
538  SWC_ASSERT(!w_assert);
539  }
540  }
541  }
542 
544  void scan(ReqScan* req) const {
545  if(_size) {
546  max_revs == 1
547  ? scan_version_single(req)
548  : scan_version_multi(req);
549  }
550  }
551 
552  void scan_version_single(ReqScan* req) const;
553 
554  void scan_version_multi(ReqScan* req) const;
555 
556  void scan_test_use(const Specs::Interval& specs, DynamicBuffer& result,
557  size_t& count, size_t& skips) const;
558 
560  bool scan_after(const DB::Cell::Key& after, const DB::Cell::Key& to,
561  Mutable& cells, bool finalized) const {
562  if(!_size)
563  return false;
564 
565  const Cell* cell;
566  for(auto it=get<ConstIterator>(after); it; ++it) {
567  cell = it.item();
568  if(!to.empty() &&
570  return false;
571  if(cell->has_expired(ttl) ||
572  (!after.empty() &&
573  DB::KeySeq::compare(key_seq, after, cell->key) != Condition::GT))
574  continue;
575 
576  cells.add_raw(*cell, finalized);
577  }
578  return true;
579  }
580 
581 
583  bool split(Mutable& cells, size_t count, size_t bytes, bool loaded) {
584  if(_size < 2 || (count > _size && bytes > _bytes))
585  return false;
586 
587  if(_container.size() > 1) { // try container split
588  size_t split_at = _container.size() / 2;
589  for(auto it = _container.cbegin() + split_at - 1; ; ++it) {
590  auto it_nxt = it + 1;
591  if(!it->back()->key.equal(it_nxt->front()->key)) {
592  _container.split(split_at, cells._container);
593  for(auto it_cell = cells.get<ConstIterator>(); it_cell; ++it_cell) {
594  cells._add(*it_cell.item());
595  }
596  _size -= cells._size;
597  _bytes -= cells._bytes;
598  if(!loaded)
599  cells.free();
600  return true;
601  }
602  if(++split_at == _container.size())
603  break;
604  }
605  }
606 
607  if(!count)
608  count = _size / 2;
609  if(!bytes)
610  bytes = _bytes / 2;
611  size_t chk_size = 0;
612  size_t chk_bytes = 0;
613  bool found_at = false;
614  auto it = get<Iterator>();
615  Iterator it_at = get<Iterator>();
616  for(Cell* cell; it; ) {
617  cell = it.item();
618  if(!it.next())
619  break;
620  ++chk_size;
621  chk_bytes += cell->encoded_length();
622  if((chk_size >= count || chk_bytes >= bytes) &&
623  !cell->key.equal(it.item()->key)) {
624  it_at = it;
625  found_at = true;
626  break;
627  }
628  }
629  if(!found_at)
630  return false;
631 
632  for(; it; ++it) {
633  if(!loaded || it.item()->has_expired(ttl)) {
634  delete it.item();
635  } else {
636  cells.add_sorted(it.item());
637  }
638  }
639  it_at.remove(_size - chk_size);
640  _size = chk_size;
641  _bytes = chk_bytes;
642  return true;
643  }
644 
645 
647  void expand(Interval& interval) const {
648  expand_begin(interval);
649  if(_size > 1)
650  expand_end(interval);
651  }
652 
654  void expand_begin(Interval& interval) const {
655  interval.expand_begin(front());
656  }
657 
659  void expand_end(Interval& interval) const {
660  interval.expand_end(back());
661  }
662 
663  void print(std::ostream& out, bool with_cells=false) const;
664 
665 
666  private:
667 
668  void _add_remove(const Cell& e_cell, Iterator& it, size_t& offset);
669 
670  void _add_unfinalized(const Cell& e_cell, Iterator& it, size_t& offset);
671 
672  void _add_plain_version_single(const Cell& e_cell,
673  Iterator& it, size_t& offset);
674 
675  void _add_plain_version_multi(const Cell& e_cell,
676  Iterator& it, size_t& offset);
677 
678  void _add_counter(const Cell& e_cell, Iterator& it, size_t& offset);
679 
680  void _finalize_counter();
681 
682  constexpr SWC_CAN_INLINE
683  void _add(const Cell& cell) noexcept {
684  _bytes += cell.encoded_length();
685  ++_size;
686  }
687 
688  constexpr SWC_CAN_INLINE
689  void _remove(const Cell& cell) noexcept {
690  _bytes -= cell.encoded_length();
691  --_size;
692  }
693 
695  void _adjust_copy(Cell& cell, const Cell& other) {
696  _bytes -= cell.encoded_length();
697  cell.copy(other);
698  _bytes += cell.encoded_length();
699  }
700 
702  void _insert(Iterator& it, const Cell& cell) {
703  Cell* add = new Cell(cell);
704  _add(*add);
705  it.insert(add);
706  }
707 
709  void _remove(Iterator& it) {
710  _remove(*it.item());
711  delete it.item();
712  it.remove();
713  }
714 
716  void _remove(Iterator& it, size_t number, bool wdel = true) {
717  if(wdel) {
718  Iterator it_del(it);
719  for(auto c = number; c && it_del; ++it_del,--c) {
720  _remove(*it_del.item());
721  delete it_del.item();
722  }
723  }
724  it.remove(number);
725  }
726 
729  uint32_t revs) {
730  while(it && key.equal(it.item()->key)) {
731  if(it.item()->flag == INSERT && ++revs > max_revs)
732  _remove(it);
733  else
734  ++it;
735  }
736  }
737 
738 
739 };
740 
741 
742 
743 }}}
744 
745 
746 #include "swcdb/db/Cells/ReqScan.h"
747 
748 #ifdef SWC_IMPL_SOURCE
749 #include "swcdb/db/Cells/Mutable.cc"
750 #endif
751 
752 #endif // swcdb_db_Cells_Mutable_h
SWC::DB::Cells::Mutable::add_raw
SWC_CAN_INLINE void add_raw(const DynamicBuffer &cells, bool finalized)
Definition: Mutable.h:436
SWC::DB::Cells::Mutable::back
constexpr SWC_CAN_INLINE Cell & back() noexcept
Definition: Mutable.h:203
SWC::DB::Cells::Mutable::GetConstIterator
constexpr SWC_CAN_INLINE ConstIterator GetConstIterator(size_t offset) const noexcept
Definition: Mutable.h:356
SWC::DB::Cells::Cell::removal
constexpr SWC_CAN_INLINE bool removal() const noexcept
Definition: Cell.h:303
SWC::DB::Cells::Mutable::add_raw
SWC_CAN_INLINE void add_raw(const Cell &e_cell, bool finalized)
Definition: Mutable.h:468
Cell.h
SWC_LOG_OSTREAM
#define SWC_LOG_OSTREAM
Definition: Logger.h:44
SWC::DB::Cells::Mutable::scan_test_use
void scan_test_use(const Specs::Interval &specs, DynamicBuffer &result, size_t &count, size_t &skips) const
Definition: Mutable.cc:246
SWC::DB::Cells::Mutable::size
constexpr SWC_CAN_INLINE size_t size() const noexcept
Definition: Mutable.h:175
SWC::DB::Cells::Mutable::~Mutable
SWC_CAN_INLINE ~Mutable() noexcept
Definition: Mutable.h:151
SWC::DB::Cells::Mutable::write_and_free
void write_and_free(DynamicBuffer &cells, uint32_t &cell_count, Interval &intval, uint32_t threshold, uint32_t max_cells)
Definition: Mutable.cc:34
SWC::Core::VectorsVector::front
constexpr SWC_CAN_INLINE value_type & front() noexcept
Definition: VectorsVector.h:609
SWC::Condition::GE
@ GE
Definition: Comparators.h:31
SWC::Core::Vector::clear
SWC_CAN_INLINE void clear() noexcept(_NoExceptDestructor)
Definition: Vector.h:120
SWC_LOG_OUT
#define SWC_LOG_OUT(pr, _code_)
Definition: Logger.h:178
SWC::DB::Cells::Mutable::get
constexpr T get(size_t offset) const noexcept
Definition: Mutable.h:243
SWC::DB::Cells::Mutable::operator=
Mutable & operator=(const Mutable &other)=delete
SWC::DB::Cells::Mutable::operator[]
constexpr SWC_CAN_INLINE Cell * operator[](size_t pos) noexcept
Definition: Mutable.h:362
SWC::DB::Cells::Mutable::expand
SWC_CAN_INLINE void expand(Interval &interval) const
Definition: Mutable.h:647
SWC::Condition::GT
@ GT
Definition: Comparators.h:30
SWC::DB::Cells::Mutable::configure
void configure(const uint32_t revs, const uint64_t ttl_ns, const Types::Column typ, bool finalized)
Definition: Mutable.cc:13
SWC::DB::Cells::Interval::expand_end
SWC_CAN_INLINE void expand_end(const Cell &cell)
Definition: Interval.h:136
SWC::DB::Cells::Mutable::_bytes
size_t _bytes
Definition: Mutable.h:59
SWC::DB::Cells::Mutable::scan_version_single
void scan_version_single(ReqScan *req) const
Definition: Mutable.cc:162
SWC::Core::BufferDyn::ensure
SWC_CAN_INLINE void ensure(size_t len)
Definition: Buffer.h:212
SWC::DB::Types::Column
Column
Definition: Column.h:18
SWC::DB::Specs::Interval::range_begin
Cell::Key range_begin
Definition: SpecsInterval.h:238
SWC::DB::Cell::Key::equal
constexpr SWC_CAN_INLINE bool equal(const Key &other) const noexcept
Definition: CellKey.h:179
SWC::DB::Cells::Mutable::scan_version_multi
void scan_version_multi(ReqScan *req) const
Definition: Mutable.cc:181
SWC::DB::Cells::Mutable::get
SWC_CAN_INLINE bool get(const DB::Cell::Key &key, Condition::Comp comp, DB::Cell::Key &res) const
Definition: Mutable.h:377
SWC::DB::Cells::Cell
Definition: Cell.h:92
SWC::DB::Cells::Mutable::get
SWC_CAN_INLINE T get(const DB::Cell::Key &key) const
Definition: Mutable.h:299
SWC::DB::Cell::Key
Definition: CellKey.h:24
SWC::DB::Cells::Mutable::Mutable
Mutable(const Mutable &)=delete
SWC::DB::Cells::Mutable::_finalize_counter
void _finalize_counter()
Definition: Mutable.cc:556
SWC::DB::Cells::Mutable::takeout_begin
SWC_CAN_INLINE void takeout_begin(size_t pos, Cell *&cell)
Definition: Mutable.h:402
SWC::DB::Cells::Cell::key
DB::Cell::Key key
Definition: Cell.h:357
SWC::DB::Cells::Mutable::_remove_overhead
SWC_CAN_INLINE void _remove_overhead(Iterator &it, const DB::Cell::Key &key, uint32_t revs)
Definition: Mutable.h:728
SWC::DB::Cells::Mutable::get
T get(const DB::Cell::Key &key, size_t &offset) const
Definition: Mutable.h:306
SWC::DB::Cells::Cell::has_expired
SWC_CAN_INLINE bool has_expired(const int64_t ttl) const noexcept
Definition: Cell.h:327
SWC::DB::Cells::Mutable::scan_after
SWC_CAN_INLINE bool scan_after(const DB::Cell::Key &after, const DB::Cell::Key &to, Mutable &cells, bool finalized) const
Definition: Mutable.h:560
SWC::DB::Cells::Mutable::check_sequence
SWC_CAN_INLINE void check_sequence(const char *msg, bool w_assert=true) const
Definition: Mutable.h:525
SWC::DB::Cells::Mutable::_remove
SWC_CAN_INLINE void _remove(Iterator &it)
Definition: Mutable.h:709
SWC::DB::Cells::Mutable::get
T get(const DB::Cell::Key &key, size_t &offset)
Definition: Mutable.h:264
SWC::DB::Cells::Mutable::operator=
SWC_CAN_INLINE Mutable & operator=(Mutable &&other) noexcept
Definition: Mutable.h:119
SWC::Core::VectorsVector::split
SWC_CAN_INLINE void split(size_t split_at, VectorsVector &to)
Definition: VectorsVector.h:669
SWC::DB::Cells::Mutable::add_sorted
SWC_CAN_INLINE void add_sorted(const Cell &cell, bool no_value=false)
Definition: Mutable.h:413
SWC::DB::Cells::Mutable::VectorT
Core::Vector< Cell *, uint32_t > VectorT
Definition: Mutable.h:33
SWC::DB::Cells::Mutable::Mutable
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)
Definition: Mutable.h:95
SWC::DB::Types::KeySeq
KeySeq
Definition: KeySeq.h:13
SWC::DB::Cells::Mutable::_adjust_copy
SWC_CAN_INLINE void _adjust_copy(Cell &cell, const Cell &other)
Definition: Mutable.h:695
SWC::DB::Cell::Key::empty
constexpr SWC_CAN_INLINE bool empty() const noexcept
Definition: CellKey.h:186
SWC::DB::Cells::Mutable::_size
size_t _size
Definition: Mutable.h:60
SWC::Condition::Comp
Comp
Definition: Comparators.h:27
SWC::DB::Cells::Mutable::scan
SWC_CAN_INLINE void scan(ReqScan *req) const
Definition: Mutable.h:544
SWC::DB::Cells::Mutable::add_sorted
SWC_CAN_INLINE void add_sorted(Cell *cell)
Definition: Mutable.h:418
SWC_CAN_INLINE
#define SWC_CAN_INLINE
Definition: Compat.h:102
SWC::DB::Cells::Mutable::takeout
SWC_CAN_INLINE void takeout(size_t pos, Cell *&cell)
Definition: Mutable.h:393
SWC::DB::Cells::Mutable::_remove
SWC_CAN_INLINE void _remove(Iterator &it, size_t number, bool wdel=true)
Definition: Mutable.h:716
SWC::DB::Cells::ReqScan
Definition: ReqScan.h:19
SWC::Core::VectorsVector::add
SWC_CAN_INLINE void add(VectorsVector &&other)
Definition: VectorsVector.h:659
SWC::Core::VectorsVector::size_of_internal
constexpr SWC_CAN_INLINE size_t size_of_internal() const noexcept
Definition: VectorsVector.h:592
SWC::Core::VectorsVector::back
constexpr SWC_CAN_INLINE value_type & back() noexcept
Definition: VectorsVector.h:614
SWC::Core::Buffer::base
value_type * base
Definition: Buffer.h:131
SWC
The SWC-DB C++ namespace 'SWC'.
Definition: main.cc:12
SWC::DB::Cells::Mutable::expand_begin
SWC_CAN_INLINE void expand_begin(Interval &interval) const
Definition: Mutable.h:654
SWC::DB::Cells::Mutable::free
SWC_CAN_INLINE void free() noexcept
Definition: Mutable.h:157
SWC::DB::Types::is_counter
bool SWC_CONST_FUNC is_counter(const Column typ) noexcept
Definition: Column.cc:26
SWC::Core::VectorsVector
Definition: VectorsVector.h:20
SWC::Core::BufferDyn< StaticBuffer >
SWC::Core::Buffer
Definition: Buffer.h:18
SWC::DB::Cells::Mutable::_add_plain_version_single
void _add_plain_version_single(const Cell &e_cell, Iterator &it, size_t &offset)
Definition: Mutable.cc:366
SWC::Core::Buffer::size
size_t size
Definition: Buffer.h:130
SWC::DB::Cells::Mutable::front
constexpr SWC_CAN_INLINE Cell & front() const noexcept
Definition: Mutable.h:208
SWC::Condition::EQ
@ EQ
Definition: Comparators.h:32
SWC::DB::Cell::Key::copy
void copy(const Key &other)
Definition: CellKey.h:314
SWC::DB::Cells::Mutable::_add_unfinalized
void _add_unfinalized(const Cell &e_cell, Iterator &it, size_t &offset)
Definition: Mutable.cc:321
SWC::DB::Cells::Mutable::Mutable
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)
Definition: Mutable.h:86
SWC::DB::Cells::INSERT
@ INSERT
Definition: Cell.h:62
SWC::DB::Cells::Mutable::takeout_end
SWC_CAN_INLINE void takeout_end(size_t pos, Cell *&cell)
Definition: Mutable.h:407
SWC::Core::VectorsVector::push_back
SWC_CAN_INLINE void push_back(const value_type &value)
Definition: VectorsVector.h:646
SWC::DB::Cells::Mutable::empty
constexpr SWC_CAN_INLINE bool empty() const noexcept
Definition: Mutable.h:185
SWC::DB::Cells::Mutable::_add_plain_version_multi
void _add_plain_version_multi(const Cell &e_cell, Iterator &it, size_t &offset)
Definition: Mutable.cc:404
SWC::DB::Cells::Mutable::_remove
constexpr SWC_CAN_INLINE void _remove(const Cell &cell) noexcept
Definition: Mutable.h:689
SWC::LOG_ERROR
@ LOG_ERROR
Definition: Logger.h:32
SWC::DB::Cells::Mutable::add_raw
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)
Definition: Mutable.h:447
SWC::DB::Cells::Mutable::add_raw
SWC_CAN_INLINE void add_raw(const Cell &e_cell, size_t *offsetp, bool finalized)
Definition: Mutable.h:474
SWC::DB::Cells::Mutable::ConstIterator
Container::ConstIterator ConstIterator
Definition: Mutable.h:69
SWC::DB::Cells::Mutable::size_of_internal
constexpr SWC_CAN_INLINE size_t size_of_internal() const noexcept
Definition: Mutable.h:190
Mutable.cc
SWC::DB::Cells::Mutable::ttl
uint64_t ttl
Definition: Mutable.h:74
SWC::DB::Cells::Mutable::print
void print(std::ostream &out, bool with_cells=false) const
Definition: Mutable.cc:140
SWC::Core::Vector::shrink_to_fit
SWC_CAN_INLINE void shrink_to_fit(size_type sz=0)
Definition: Vector.h:276
SWC::Core::Vector
Definition: Vector.h:14
SWC::DB::Cells::Mutable::key_seq
const Types::KeySeq key_seq
Definition: Mutable.h:71
SWC::DB::Cells::Mutable::_container
Container _container
Definition: Mutable.h:58
SWC::DB::Cells::Mutable::Container
Core::VectorsVector< Core::Vector< VectorT, uint32_t, 1 >, VectorT, 8192 > Container
Definition: Mutable.h:38
SWC::Core::BufferDyn::fill
constexpr SWC_CAN_INLINE size_t fill() const noexcept
Definition: Buffer.h:192
SWC::DB::Cells::Mutable::has_one_key
constexpr SWC_CAN_INLINE bool has_one_key() const noexcept
Definition: Mutable.h:218
SWC::DB::Cells::Cell::encoded_length
constexpr SWC_CAN_INLINE size_t encoded_length(bool no_value=false) const noexcept
Definition: Cell.h:285
SWC::DB::Specs::Interval
Definition: SpecsInterval.h:25
SWC::DB::Cells::Interval::expand_begin
SWC_CAN_INLINE void expand_begin(const Cell &cell)
Definition: Interval.h:129
SWC::DB::Cells::Mutable::type
Types::Column type
Definition: Mutable.h:72
SWC::DB::Cells::Mutable::reset
SWC_CAN_INLINE void reset(const uint32_t revs=1, const uint64_t ttl_ns=0, const Types::Column typ=Types::Column::PLAIN)
Definition: Mutable.h:167
SWC::Config::T
const uint64_t T
Definition: Property.h:27
SWC::DB::Cells::Mutable::get
constexpr SWC_CAN_INLINE T get() noexcept
Definition: Mutable.h:225
SWC::DB::Cells::Mutable::Mutable
SWC_CAN_INLINE Mutable(Mutable &&other) noexcept
Definition: Mutable.h:106
SWC::DB::Cells::Mutable::write
SWC_CAN_INLINE void write(DynamicBuffer &cells) const
Definition: Mutable.h:516
ReqScan.h
SWC::DB::Cells::Mutable::back
constexpr SWC_CAN_INLINE Cell & back() const noexcept
Definition: Mutable.h:213
SWC::DB::Cells::Mutable::GetConstIterator
constexpr SWC_CAN_INLINE ConstIterator GetConstIterator() const noexcept
Definition: Mutable.h:351
SWC::DB::Cells::Mutable::_insert
SWC_CAN_INLINE void _insert(Iterator &it, const Cell &cell)
Definition: Mutable.h:702
SWC::DB::Cells::Mutable::NARROW_SIZE
constexpr static const uint8_t NARROW_SIZE
Definition: Mutable.h:61
SWC::DB::Cells::Mutable::Ptr
std::shared_ptr< Mutable > Ptr
Definition: Mutable.h:66
SWC::DB::Cells::Mutable::GetIterator
constexpr SWC_CAN_INLINE Iterator GetIterator() noexcept
Definition: Mutable.h:341
SWC::DB::Cells::Mutable::add_raw
SWC_CAN_INLINE void add_raw(const Cell &e_cell, size_t *offsetp, Iterator &it, bool finalized)
Definition: Mutable.h:480
SWC::DB::Cells::Mutable::add_sorted
SWC_CAN_INLINE size_t add_sorted(const uint8_t *ptr, size_t remain)
Definition: Mutable.h:424
SWC::DB::Specs::Interval::offset_key
Cell::Key offset_key
Definition: SpecsInterval.h:244
SWC::DB::Cells::Mutable::Iterator
Container::Iterator Iterator
Definition: Mutable.h:68
SWC::DB::Cells::Mutable::_add_remove
void _add_remove(const Cell &e_cell, Iterator &it, size_t &offset)
Definition: Mutable.cc:279
SWC::DB::Cells::Mutable::finalize_raw
SWC_CAN_INLINE void finalize_raw()
Definition: Mutable.h:496
SWC::DB::Cells::Mutable::take_sorted
SWC_CAN_INLINE void take_sorted(Mutable &other)
Definition: Mutable.h:133
SWC::DB::Cells::Mutable::expand_end
SWC_CAN_INLINE void expand_end(Interval &interval) const
Definition: Mutable.h:659
SWC::Core::VectorsVector::get
constexpr SWC_CAN_INLINE T get() noexcept
Definition: VectorsVector.h:547
SWC::DB::Cells::Mutable::size_bytes
constexpr SWC_CAN_INLINE size_t size_bytes() const noexcept
Definition: Mutable.h:180
SWC::DB::Cells::Mutable::make
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)
Definition: Mutable.h:77
SWC::DB::Cells::Cell::copy
void copy(const Cell &other, bool no_value=false)
Definition: Cell.h:424
SWC::DB::Cells::Interval
Definition: Interval.h:17
SWC_ASSERT
#define SWC_ASSERT(_e_)
Definition: Exception.h:165
SWC::DB::Cells::Mutable::get
SWC_CAN_INLINE void get(int32_t pos, DB::Cell::Key &key) const
Definition: Mutable.h:368
SWC::Core::Vector::cbegin
constexpr SWC_CAN_INLINE const_iterator cbegin() const noexcept
Definition: Vector.h:216
SWC::Core::Vector::size
constexpr SWC_CAN_INLINE size_type size() const noexcept
Definition: Vector.h:189
SWC::DB::Cells::Mutable::split
SWC_CAN_INLINE bool split(Mutable &cells, size_t count, size_t bytes, bool loaded)
Definition: Mutable.h:583
SWC::DB::Cells::Mutable::_add
constexpr SWC_CAN_INLINE void _add(const Cell &cell) noexcept
Definition: Mutable.h:683
SWC::DB::Cells::Mutable::get
SWC_CAN_INLINE T get(const DB::Cell::Key &key)
Definition: Mutable.h:257
VectorsVector.h
SWC::DB::Cells::Mutable::front
constexpr SWC_CAN_INLINE Cell & front() noexcept
Definition: Mutable.h:198
SWC::DB::Cells::Mutable
Definition: Mutable.h:21
SWC::DB::Cells::Mutable::_add_counter
void _add_counter(const Cell &e_cell, Iterator &it, size_t &offset)
Definition: Mutable.cc:473
SWC::DB::Cells::Mutable::get
constexpr SWC_CAN_INLINE T get() const noexcept
Definition: Mutable.h:231
SWC::DB::Cells::Mutable::get
constexpr T get(size_t offset) noexcept
Definition: Mutable.h:237
SWC::DB::KeySeq::compare
Condition::Comp compare(const Types::KeySeq seq, const Cell::Key &key, const Cell::Key &other) SWC_ATTRIBS((SWC_ATTRIB_O3))
Definition: KeyComparator.h:294
Interval.h
SWC::DB::Cells::Mutable::max_revs
uint32_t max_revs
Definition: Mutable.h:73
SWC::DB::Cells::Mutable::GetIterator
constexpr SWC_CAN_INLINE Iterator GetIterator(size_t offset) noexcept
Definition: Mutable.h:346
SWC::DB::Cells::Mutable::get
SWC_CAN_INLINE T get(const Specs::Interval &specs) const
Definition: Mutable.h:249