SWC-DB  v0.5.12 C++ documentations
SWC-DB© (Super Wide Column Database) - High Performance Scalable Database (https://github.com/kashirin-alex/swc-db)
BaseColumnMutable.cc
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 
8 
9 
10 namespace SWC { namespace client { namespace Query { namespace Update {
11 
12 namespace Handlers {
13 
14 
15 
16 void ColumnMutable::print(std::ostream& out) {
17  out << "(cid=" << cid;
18  {
20  m_cells.print(out << ' ');
21  }
22  out << ')';
23 }
24 
25 bool ColumnMutable::empty() noexcept {
27  return m_cells.empty();
28 }
29 
30 size_t ColumnMutable::size() noexcept {
32  return m_cells.size();
33 }
34 
35 size_t ColumnMutable::size_bytes() noexcept {
37  return m_cells.size_bytes();
38 }
39 
43  if(m_cells.size())
44  m_cells.get(0, *key.get());
45  return key;
46 }
47 
49 ColumnMutable::get_key_next(const DB::Cell::Key& eval_key, bool start_key) {
50  if(eval_key.empty())
51  return nullptr;
52  DB::Cell::Key key;
54  return
55  m_cells.get(eval_key, start_key ? Condition::GE : Condition::GT, key)
56  ? DB::Cell::Key::Ptr(new DB::Cell::Key(std::move(key)))
57  : nullptr;
58 }
59 
60 size_t ColumnMutable::add(const DynamicBuffer& cells,
61  const DB::Cell::Key& upto_key,
62  const DB::Cell::Key& from_key,
63  uint32_t skip,
64  bool malformed) {
66  auto sz = m_cells.size();
67  m_cells.add_raw(cells, upto_key, from_key, skip, malformed, false);
68  return m_cells.size() - sz;
69 }
70 
71 size_t ColumnMutable::add(const DynamicBuffer& cells, bool finalized) {
73  auto sz = m_cells.size();
74  m_cells.add_raw(cells, finalized);
75  return m_cells.size() - sz;
76 }
77 
78 void ColumnMutable::add(const DB::Cells::Cell& cell, bool finalized) {
80  m_cells.add_raw(cell, finalized);
81 }
82 
83 bool ColumnMutable::get_buff(const DB::Cell::Key& key_start,
84  const DB::Cell::Key& key_end,
85  size_t buff_sz, bool& more,
86  DynamicBuffer& cells_buff) {
87  {
89  more = m_cells.write_and_free(
90  key_start, key_end, cells_buff, buff_sz);
91  }
92  return cells_buff.fill();
93 }
94 
95 bool ColumnMutable::get_buff(size_t buff_sz, bool& more,
96  DynamicBuffer& cells_buff) {
97  {
99  more = m_cells.write_and_free(cells_buff, buff_sz);
100  }
101  return cells_buff.fill();
102 }
103 
104 
105 
106 }}}}}
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::size
constexpr SWC_CAN_INLINE size_t size() const noexcept
Definition: Mutable.h:175
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::Condition::GE
@ GE
Definition: Comparators.h:31
SWC::client::Query::Update::Handlers::ColumnMutable::empty
virtual bool empty() noexcept override
Definition: BaseColumnMutable.cc:25
SWC::Condition::GT
@ GT
Definition: Comparators.h:30
SWC::client::Query::Update::Handlers::ColumnMutable::add
virtual size_t add(const DynamicBuffer &cells, const DB::Cell::Key &upto_key, const DB::Cell::Key &from_key, uint32_t skip, bool malformed) override
Definition: BaseColumnMutable.cc:60
SWC::client::Query::Update::Handlers::ColumnMutable::size_bytes
virtual size_t size_bytes() noexcept override
Definition: BaseColumnMutable.cc:35
SWC::Core::MutexSptd::scope
Definition: MutexSptd.h:96
SWC::DB::Cells::Cell
Definition: Cell.h:92
SWC::client::Query::Update::Handlers::ColumnMutable::size
virtual size_t size() noexcept override
Definition: BaseColumnMutable.cc:30
SWC::DB::Cell::Key
Definition: CellKey.h:24
SWC::client::Query::Update::Handlers::ColumnMutable::cid
cid_t cid
Definition: BaseColumnMutable.h:25
SWC::client::Query::Update::Handlers::ColumnMutable::get_first_key
virtual DB::Cell::Key::Ptr get_first_key() override
Definition: BaseColumnMutable.cc:40
SWC::client::Query::Update::Handlers::ColumnMutable::print
virtual void print(std::ostream &out) override
Definition: BaseColumnMutable.cc:16
BaseColumnMutable.h
SWC::client::Query::Update::Handlers::ColumnMutable::get_key_next
virtual DB::Cell::Key::Ptr get_key_next(const DB::Cell::Key &eval_key, bool start_key=false) override
Definition: BaseColumnMutable.cc:49
SWC::DB::Cell::Key::empty
constexpr SWC_CAN_INLINE bool empty() const noexcept
Definition: CellKey.h:186
SWC
The SWC-DB C++ namespace 'SWC'.
Definition: main.cc:12
SWC::Core::BufferDyn< StaticBuffer >
SWC::client::Query::Update::Handlers::ColumnMutable::m_mutex
Core::MutexSptd m_mutex
Definition: BaseColumnMutable.h:100
SWC::DB::Cells::Mutable::empty
constexpr SWC_CAN_INLINE bool empty() const noexcept
Definition: Mutable.h:185
SWC::client::Query::Update::Handlers::ColumnMutable::get_buff
virtual bool get_buff(const DB::Cell::Key &key_start, const DB::Cell::Key &key_end, size_t buff_sz, bool &more, DynamicBuffer &cells_buff) override
Definition: BaseColumnMutable.cc:83
SWC::DB::Cells::Mutable::print
void print(std::ostream &out, bool with_cells=false) const
Definition: Mutable.cc:140
SWC::client::Query::Update::Handlers::ColumnMutable::m_cells
DB::Cells::Mutable m_cells
Definition: BaseColumnMutable.h:101
SWC::Core::BufferDyn::fill
constexpr SWC_CAN_INLINE size_t fill() const noexcept
Definition: Buffer.h:192
SWC::DB::Cells::Mutable::get
constexpr SWC_CAN_INLINE T get() noexcept
Definition: Mutable.h:225
SWC::DB::Cell::Key::Ptr
std::shared_ptr< Key > Ptr
Definition: CellKey.h:27
SWC::DB::Cells::Mutable::size_bytes
constexpr SWC_CAN_INLINE size_t size_bytes() const noexcept
Definition: Mutable.h:180