SWC-DB  v0.5.12 C++ documentations
SWC-DB© (Super Wide Column Database) - High Performance Scalable Database (https://github.com/kashirin-alex/swc-db)
Cell.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_Cell_h
8 #define swcdb_db_cells_Cell_h
9 
10 
12 #include "swcdb/core/Buffer.h"
13 #include "swcdb/core/Time.h"
14 
15 #include "swcdb/db/Types/Column.h"
16 #include "swcdb/db/Types/Encoder.h"
17 #include "swcdb/db/Cells/CellKey.h"
18 
19 
20 namespace SWC {
21 
22 
23 
38 namespace DB {
39 
40 
41 enum DisplayFlag : uint8_t {
42  TIMESTAMP = 0x01,
43  DATETIME = 0x04,
44  BINARY = 0x08,
45  SPECS = 0x10,
46  STATS = 0x20,
47  COLUMN = 0x40
48 };
49 
50 enum OutputFlag : uint8_t {
51  NO_TS = 0x01,
52  NO_VALUE = 0x04,
53  NO_ENCODE = 0x08
54 };
55 
56 
58 namespace Cells {
59 
60 enum Flag : uint8_t {
61  NONE = 0x0, // empty instance
62  INSERT = 0x1,
63  DELETE_LE = 0x2,
64  DELETE_EQ = 0x3
65 };
66 
67 const char* SWC_CONST_FUNC to_string(Flag flag) noexcept;
68 
69 Flag SWC_PURE_FUNC flag_from(const uint8_t* rptr, uint32_t len) noexcept;
70 
71 
72 constexpr const int64_t TIMESTAMP_NULL = INT64_MIN + 1;
73 constexpr const int64_t TIMESTAMP_AUTO = INT64_MIN + 2;
74 constexpr const int64_t TIMESTAMP_MIN = INT64_MIN + 3;
75 constexpr const int64_t TIMESTAMP_MAX = INT64_MAX;
76 
77 constexpr const uint8_t TS_DESC = 0x01;
78 constexpr const uint8_t HAVE_ENCODER = 0x02;
79 constexpr const uint8_t REV_IS_TS = 0x04;
80 constexpr const uint8_t HAVE_TIMESTAMP = 0x08;
81 constexpr const uint8_t HAVE_REVISION = 0x10;
82 
83 constexpr const uint8_t OP_EQUAL = 0x01;
84 
85 constexpr const uint8_t MASK_TS_DESC = 0xff - TS_DESC;
86 constexpr const uint8_t MASK_HAVE_ENCODER = 0xff - HAVE_ENCODER;
87 constexpr const uint8_t MASK_REV_IS_TS = 0xff - REV_IS_TS;
88 constexpr const uint8_t MASK_HAVE_TIMESTAMP = 0xff - HAVE_TIMESTAMP;
89 constexpr const uint8_t MASK_HAVE_REVISION = 0xff - HAVE_REVISION;
90 
91 
92 class Cell final {
93  public:
94  typedef std::shared_ptr<Cell> Ptr;
95 
96  constexpr SWC_CAN_INLINE explicit
97  Cell() noexcept
98  : key(), own(false), flag(Flag::NONE), control(0),
99  vlen(0), value(nullptr),
101  }
102 
103  SWC_CAN_INLINE explicit
104  Cell(const Cell& other)
105  : key(other.key), own(other.vlen), flag(other.flag),
106  control(other.control),
107  vlen(other.vlen),
108  value(_value(other.value)),
109  timestamp(other.timestamp),
110  revision(other.revision) {
111  }
112 
113  SWC_CAN_INLINE explicit
114  Cell(const Cell& other, bool no_value)
115  : key(other.key), own(!no_value && other.vlen), flag(other.flag),
116  control(no_value ? other.control & MASK_HAVE_ENCODER : other.control),
117  vlen(own ? other.vlen : 0),
118  value(_value(other.value)),
119  timestamp(other.timestamp),
120  revision(other.revision) {
121  }
122 
123  constexpr SWC_CAN_INLINE explicit
124  Cell(Cell&& other) noexcept
125  : key(std::move(other.key)), own(other.own), flag(other.flag),
126  control(other.control),
127  vlen(other.vlen),
128  value(other.value),
129  timestamp(other.timestamp),
130  revision(other.revision) {
131  other.value = nullptr;
132  other.vlen = 0;
133  }
134 
135  explicit
136  Cell(const uint8_t** bufp, size_t* remainp, bool own);
137 
138  Cell& operator=(const Cell&) = delete;
139 
141  Cell& operator=(Cell&& other) noexcept {
142  move(other);
143  return *this;
144  }
145 
146  void move(Cell& other) noexcept;
147 
148  void copy(const Cell& other, bool no_value=false);
149 
151  ~Cell() noexcept {
152  _free();
153  }
154 
156  void _free() noexcept {
157  if(own)
158  delete [] value;
159  }
160 
162  void free() noexcept {
163  _free();
164  vlen = 0;
165  value = nullptr;
166  }
167 
168  constexpr SWC_CAN_INLINE
169  void set_time_order_desc(bool desc) noexcept {
170  if(desc)
171  control |= TS_DESC;
172  else
174  }
175 
176  constexpr SWC_CAN_INLINE
177  bool is_time_order_desc() const noexcept {
178  return control & TS_DESC;
179  }
180 
181  constexpr SWC_CAN_INLINE
182  void set_timestamp(int64_t ts) noexcept {
183  timestamp = ts;
185  }
186 
187  constexpr SWC_CAN_INLINE
188  void set_timestamp_null() noexcept {
191  if(control & REV_IS_TS) {
194  }
195  }
196 
197  constexpr SWC_CAN_INLINE
198  void set_timestamp_auto() noexcept {
201  if(control & REV_IS_TS) {
204  }
205  }
206 
207  constexpr SWC_CAN_INLINE
208  void set_timestamp_with_rev_is_ts(int64_t ts) noexcept {
209  set_timestamp(ts);
212  control |= REV_IS_TS;
213  }
214 
215  constexpr SWC_CAN_INLINE
216  void set_revision(int64_t ts) noexcept {
217  revision = ts;
220  }
221 
223  void set_value(uint8_t* v, uint32_t len, bool owner) {
224  _free();
225  vlen = len;
226  value = (own = owner) ? _value(v) : v;
227  }
228 
230  void set_value(const char* v, uint32_t len, bool owner) {
231  set_value(reinterpret_cast<uint8_t*>(const_cast<char*>(v)), len, owner);
232  }
233 
235  void set_value(const char* v, bool owner) {
236  set_value(v, strlen(v), owner);
237  }
238 
240  void set_value(const std::string& v, bool owner) {
241  set_value(v.c_str(), v.length(), owner);
242  }
243 
244  void set_value(Types::Encoder encoder, const uint8_t* v, uint32_t len);
245 
247  void set_value(Types::Encoder encoder, const std::string& v) {
248  set_value(encoder, reinterpret_cast<const uint8_t*>(v.c_str()), v.size());
249  }
250 
251  Types::Encoder get_value(StaticBuffer& v, bool owner) const;
252 
253  void get_value(std::string& v) const;
254 
255  void set_counter(uint8_t op, int64_t v,
256  Types::Column typ = Types::Column::COUNTER_I64,
257  int64_t rev = TIMESTAMP_NULL);
258 
259  constexpr SWC_CAN_INLINE
260  int64_t get_counter() const {
261  const uint8_t *ptr = value;
262  return Serialization::decode_vi64(&ptr);
263  }
264 
265  constexpr SWC_CAN_INLINE
266  uint8_t get_counter(int64_t& count) const {
267  const uint8_t* ptr = value;
268  count = Serialization::decode_vi64(&ptr);
269  return *ptr;
270  }
271 
272  constexpr SWC_CAN_INLINE
273  int64_t get_counter(uint8_t& op, int64_t& rev) const {
274  const uint8_t *ptr = value;
275  int64_t v = Serialization::decode_vi64(&ptr);
276  rev = ((op = *ptr) & HAVE_REVISION)
278  : TIMESTAMP_NULL;
279  return v;
280  }
281 
282  void read(const uint8_t** bufp, size_t* remainp, bool owner);
283 
284  constexpr SWC_CAN_INLINE
285  size_t encoded_length(bool no_value=false) const noexcept {
286  size_t len = key.encoded_length();
287  len += 2;
288  if(control & HAVE_TIMESTAMP)
289  len += 8;
290  if(control & HAVE_REVISION)
291  len += 8;
292  if(no_value)
293  return ++len;
295  return len += vlen;
296  }
297 
298  void write(DynamicBuffer &dst_buf, bool no_value=false) const;
299 
300  bool SWC_PURE_FUNC equal(const Cell& other) const noexcept;
301 
302  constexpr SWC_CAN_INLINE
303  bool removal() const noexcept {
304  return flag != Flag::INSERT;
305  }
306 
307  constexpr SWC_CAN_INLINE
308  bool is_removing(const int64_t& ts) const noexcept {
309  return ts != TIMESTAMP_AUTO && (
310  (flag == DELETE_LE && timestamp >= ts)
311  ||
312  (flag == DELETE_EQ && timestamp == ts)
313  );
314  }
315 
316  constexpr SWC_CAN_INLINE
317  int64_t get_timestamp() const noexcept {
318  return timestamp;
319  }
320 
321  constexpr SWC_CAN_INLINE
322  int64_t get_revision() const noexcept {
323  return revision;
324  }
325 
327  bool has_expired(const int64_t ttl) const noexcept {
328  return ttl &&
329  (control & HAVE_TIMESTAMP) &&
330  (Time::now_ns() > timestamp + ttl);
331  }
332 
333  constexpr SWC_CAN_INLINE
334  bool have_encoder() const noexcept {
335  return control & HAVE_ENCODER;
336  }
337 
338  void display(std::ostream& out, Types::Column typ = Types::Column::PLAIN,
339  uint8_t flags=0, bool meta=false) const;
340 
342  std::string to_string(Types::Column typ = Types::Column::PLAIN) const {
343  std::string s;
344  {
345  std::stringstream ss;
346  print(ss, typ);
347  s = ss.str();
348  }
349  return s;
350  }
351 
352  void print(std::ostream& out, Types::Column typ) const;
353 
354  static int counter_from_str(const uint8_t** ptrp, size_t* remainp,
355  uint8_t& op, int64_t& value) noexcept;
356 
358  bool own;
359  uint8_t flag;
360  uint8_t control;
361  uint32_t vlen;
362  uint8_t* value;
363 
364  private:
365 
367  uint8_t* _value(const uint8_t* v) {
368  return vlen
369  ? static_cast<uint8_t*>(memcpy(new uint8_t[vlen], v, vlen))
370  : nullptr;
371  }
372 
373  int64_t timestamp;
374  int64_t revision;
375 
376 };
377 
378 
379 
381 Cell::Cell(const uint8_t** bufp, size_t* remainp, bool a_own)
382  : key(), own(a_own),
383  flag(Serialization::decode_i8(bufp, remainp)),
384  control(), vlen(), value(), timestamp(), revision() {
385  key.decode(bufp, remainp, own);
386  control = Serialization::decode_i8(bufp, remainp);
387 
389  ? Serialization::decode_i64(bufp, remainp)
390  : TIMESTAMP_AUTO;
391 
393  ? Serialization::decode_i64(bufp, remainp)
395 
396  if((vlen = Serialization::decode_vi32(bufp, remainp))) {
397  if(*remainp < vlen)
399  "Read Cell(key=%s) value", key.to_string().c_str());
400  value = own ? _value(*bufp) : const_cast<uint8_t*>(*bufp);
401  *bufp += vlen;
402  *remainp -= vlen;
403  } else {
404  value = nullptr;
405  }
406 }
407 
409 void Cell::move(Cell& other) noexcept {
410  _free();
411  own = other.own;
412  key.move(other.key);
413  flag = other.flag;
414  control = other.control;
415  timestamp = other.timestamp;
416  revision = other.revision;
417  value = other.value;
418  vlen = other.vlen;
419  other.value = nullptr;
420  other.vlen = 0;
421 }
422 
424 void Cell::copy(const Cell& other, bool no_value) {
425  key.copy(other.key);
426  flag = other.flag;
427  control = other.control;
428  timestamp = other.timestamp;
429  revision = other.revision;
430 
431  if(no_value) {
433  free();
434  } else {
435  set_value(other.value, other.vlen, true);
436  }
437 }
438 
440 void Cell::get_value(std::string& v) const {
441  v.clear();
442  if(vlen) {
443  StaticBuffer _v;
444  get_value(_v, false);
445  v.append(reinterpret_cast<const char*>(_v.base), _v.size);
446  }
447 }
448 
450 void Cell::set_counter(uint8_t op, int64_t v, Types::Column typ, int64_t rev) {
451  _free();
452  own = true;
453 
454  switch(typ) {
455  case Types::Column::COUNTER_I8:
456  v = int8_t(v);
457  break;
458  case Types::Column::COUNTER_I16:
459  v = int16_t(v);
460  break;
461  case Types::Column::COUNTER_I32:
462  v = int32_t(v);
463  break;
464  default:
465  break;
466  }
467 
469  bool has_rev = op & OP_EQUAL && rev != TIMESTAMP_NULL;
470  if(has_rev) {
471  op |= HAVE_REVISION;
473  }
474 
475  uint8_t* ptr = (value = new uint8_t[vlen]);
477  *ptr++ = op;
478  if(has_rev)
479  Serialization::encode_vi64(&ptr, rev);
480  // +? i64's storing epochs
481 }
482 
484 void Cell::read(const uint8_t** bufp, size_t* remainp, bool owner) {
485 
486  flag = Serialization::decode_i8(bufp, remainp);
487  key.decode(bufp, remainp, owner);
488  control = Serialization::decode_i8(bufp, remainp);
489 
491  ? Serialization::decode_i64(bufp, remainp)
492  : TIMESTAMP_AUTO;
493 
495  ? Serialization::decode_i64(bufp, remainp)
497 
498  _free();
499  own = owner;
500  if((vlen = Serialization::decode_vi32(bufp, remainp))) {
501  if(*remainp < vlen)
503  "Read Cell(key=%s) value", key.to_string().c_str());
504  value = own ? _value(*bufp) : const_cast<uint8_t*>(*bufp);
505  *bufp += vlen;
506  *remainp -= vlen;
507  } else {
508  value = nullptr;
509  }
510 }
511 
513 void Cell::write(DynamicBuffer &dst_buf, bool no_value) const {
514  dst_buf.ensure(encoded_length( no_value || (no_value = !vlen) ));
515 
516  Serialization::encode_i8(&dst_buf.ptr, flag);
517  key.encode(&dst_buf.ptr);
518 
519  uint8_t ctrl = control;
520  if(no_value)
521  ctrl &= MASK_HAVE_ENCODER;
522 
523  Serialization::encode_i8(&dst_buf.ptr, ctrl);
524  if(ctrl & HAVE_TIMESTAMP)
526  if(ctrl & HAVE_REVISION)
528 
529  if(no_value) {
530  Serialization::encode_i8(&dst_buf.ptr, 0);
531  } else {
533  dst_buf.add_unchecked(value, vlen);
534  }
535 }
536 
537 
538 
540 int Cell::counter_from_str(const uint8_t** ptrp, size_t* remainp,
541  uint8_t& op, int64_t& value) noexcept {
542  if(!*remainp) {
543  op = OP_EQUAL;
544  value = 0;
545  return Error::OK;
546  }
547  if(**ptrp == '=') {
548  op = OP_EQUAL;
549  ++*ptrp;
550  if(!--*remainp) {
551  value = 0;
552  return Error::OK;
553  }
554  } else {
555  op = 0;
556  }
557  const char* p = reinterpret_cast<const char*>(*ptrp);
558  char *last = const_cast<char*>(p + (*remainp > 30 ? 30 : *remainp));
559  errno = 0;
560  value = strtoll(p, &last, 0);
561  if(errno) {
562  return errno;
563  } else if(last > p) {
564  *remainp -= last - p;
565  *ptrp = reinterpret_cast<const uint8_t*>(last);
566  return Error::OK;
567  }
568  return EINVAL;
569 }
570 
571 
572 
573 }}}
574 
575 #ifdef SWC_IMPL_SOURCE
576 #include "swcdb/db/Cells/Cell.cc"
577 #endif
578 
579 #endif // swcdb_db_Cells_Cell_h
SWC::DB::Cells::Cell::set_counter
void set_counter(uint8_t op, int64_t v, Types::Column typ=Types::Column::COUNTER_I64, int64_t rev=TIMESTAMP_NULL)
Definition: Cell.h:450
SWC::Core::BufferDyn::ptr
value_type * ptr
Definition: Buffer.h:293
SWC::DB::Cells::Cell::set_value
SWC_CAN_INLINE void set_value(uint8_t *v, uint32_t len, bool owner)
Definition: Cell.h:223
SWC::DB::Cells::Cell::removal
constexpr SWC_CAN_INLINE bool removal() const noexcept
Definition: Cell.h:303
SWC::DB::Cells::Cell::Cell
constexpr SWC_CAN_INLINE Cell() noexcept
Definition: Cell.h:97
SWC::DB::Cells::MASK_HAVE_TIMESTAMP
constexpr const uint8_t MASK_HAVE_TIMESTAMP
Definition: Cell.h:88
SWC::DB::Cells::DELETE_EQ
@ DELETE_EQ
Definition: Cell.h:64
SWC::DB::COLUMN
@ COLUMN
Definition: Cell.h:47
SWC::DB::Cells::TIMESTAMP_MIN
constexpr const int64_t TIMESTAMP_MIN
Definition: Cell.h:74
SWC::DB::NO_VALUE
@ NO_VALUE
Definition: Cell.h:52
SWC::Serialization::encode_i64
SWC_CAN_INLINE void encode_i64(uint8_t **bufp, uint64_t val) noexcept
Definition: Serialization.h:151
SWC::Time::now_ns
SWC_CAN_INLINE int64_t now_ns() noexcept
Definition: Time.h:43
SWC::DB::Cells::Flag
Flag
Definition: Cell.h:60
SWC::DB::Cells::to_string
const char *SWC_CONST_FUNC to_string(Flag flag) noexcept
Definition: Cell.cc:17
SWC::DB::Cells::Cell::free
SWC_CAN_INLINE void free() noexcept
Definition: Cell.h:162
SWC::Core::Encoder::Type
Type
Definition: Encoder.h:28
SWC::Serialization::encoded_length_vi32
constexpr SWC_CAN_INLINE uint8_t encoded_length_vi32(uint32_t val) noexcept
Definition: Serialization.h:234
SWC::DB::Cells::Cell::timestamp
int64_t timestamp
Definition: Cell.h:373
SWC::DB::Cells::MASK_REV_IS_TS
constexpr const uint8_t MASK_REV_IS_TS
Definition: Cell.h:87
SWC::DB::Cells::Cell::set_value
SWC_CAN_INLINE void set_value(const char *v, uint32_t len, bool owner)
Definition: Cell.h:230
SWC::DB::Cells::Cell::set_value
SWC_CAN_INLINE void set_value(const char *v, bool owner)
Definition: Cell.h:235
SWC::DB::NO_ENCODE
@ NO_ENCODE
Definition: Cell.h:53
Encoder.h
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::Cells::DELETE_LE
@ DELETE_LE
Definition: Cell.h:63
SWC::DB::BINARY
@ BINARY
Definition: Cell.h:44
SWC::DB::Cells::TIMESTAMP_AUTO
constexpr const int64_t TIMESTAMP_AUTO
Definition: Cell.h:73
SWC::DB::Cells::Cell::is_removing
constexpr SWC_CAN_INLINE bool is_removing(const int64_t &ts) const noexcept
Definition: Cell.h:308
SWC::DB::Cells::Cell
Definition: Cell.h:92
SWC::DB::Cell::Key
Definition: CellKey.h:24
SWC::Error::SERIALIZATION_INPUT_OVERRUN
@ SERIALIZATION_INPUT_OVERRUN
Definition: Error.h:61
SWC::Core::BufferDyn::add_unchecked
SWC_CAN_INLINE value_type * add_unchecked(const value_type *data, size_t len) noexcept
Definition: Buffer.h:240
SWC::DB::Cells::Cell::own
bool own
Definition: Cell.h:358
SWC::Serialization::encode_i8
constexpr SWC_CAN_INLINE void encode_i8(uint8_t **bufp, uint8_t val) noexcept
Definition: Serialization.h:85
SWC::DB::Cells::Cell::key
DB::Cell::Key key
Definition: Cell.h:357
SWC::DB::Cells::Cell::counter_from_str
static int counter_from_str(const uint8_t **ptrp, size_t *remainp, uint8_t &op, int64_t &value) noexcept
Definition: Cell.h:540
SWC::DB::Cells::Cell::move
void move(Cell &other) noexcept
Definition: Cell.h:409
SWC::DB::Cells::Cell::get_counter
constexpr SWC_CAN_INLINE int64_t get_counter(uint8_t &op, int64_t &rev) const
Definition: Cell.h:273
SWC::DB::Cells::Cell::has_expired
SWC_CAN_INLINE bool has_expired(const int64_t ttl) const noexcept
Definition: Cell.h:327
SWC::DB::SPECS
@ SPECS
Definition: Cell.h:45
SWC::DB::Cell::Key::decode
void decode(const uint8_t **bufp, size_t *remainp, bool owner)
Definition: CellKey.h:337
SWC::DB::Cells::Cell::revision
int64_t revision
Definition: Cell.h:374
SWC::DB::Cells::Cell::to_string
SWC_CAN_INLINE std::string to_string(Types::Column typ=Types::Column::PLAIN) const
Definition: Cell.h:342
SWC::DB::Cells::Cell::set_revision
constexpr SWC_CAN_INLINE void set_revision(int64_t ts) noexcept
Definition: Cell.h:216
encoder
Core::Encoder::Type encoder
Buffer Encoder.
Definition: HeaderBufferInfo.h:50
SWC::DB::Cells::TS_DESC
constexpr const uint8_t TS_DESC
Definition: Cell.h:77
SWC::DB::Cells::Cell::operator=
Cell & operator=(const Cell &)=delete
SWC::DB::Cells::MASK_HAVE_ENCODER
constexpr const uint8_t MASK_HAVE_ENCODER
Definition: Cell.h:86
SWC::DB::STATS
@ STATS
Definition: Cell.h:46
SWC_CONST_FUNC
#define SWC_CONST_FUNC
Definition: Compat.h:107
SWC::Error::OK
@ OK
Definition: Error.h:45
SWC::DB::DisplayFlag
DisplayFlag
Definition: Cell.h:41
SWC_CAN_INLINE
#define SWC_CAN_INLINE
Definition: Compat.h:102
SWC::DB::Cells::Cell::is_time_order_desc
constexpr SWC_CAN_INLINE bool is_time_order_desc() const noexcept
Definition: Cell.h:177
SWC::DB::Cells::Cell::operator=
SWC_CAN_INLINE Cell & operator=(Cell &&other) noexcept
Definition: Cell.h:141
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::NONE
@ NONE
Definition: Cell.h:61
Column.h
SWC::DB::Cells::Cell::display
void display(std::ostream &out, Types::Column typ=Types::Column::PLAIN, uint8_t flags=0, bool meta=false) const
Definition: Cell.cc:111
SWC::DB::Cells::Cell::have_encoder
constexpr SWC_CAN_INLINE bool have_encoder() const noexcept
Definition: Cell.h:334
SWC::DB::Cells::Cell::set_value
SWC_CAN_INLINE void set_value(Types::Encoder encoder, const std::string &v)
Definition: Cell.h:247
SWC::Core::BufferDyn< StaticBuffer >
SWC::Core::Buffer
Definition: Buffer.h:18
SWC_PURE_FUNC
#define SWC_PURE_FUNC
Definition: Compat.h:108
SWC::DB::Cells::HAVE_ENCODER
constexpr const uint8_t HAVE_ENCODER
Definition: Cell.h:78
SWC::Core::Buffer::size
size_t size
Definition: Buffer.h:130
SWC::DB::Cells::HAVE_REVISION
constexpr const uint8_t HAVE_REVISION
Definition: Cell.h:81
SWC::DB::Cells::Cell::set_timestamp_with_rev_is_ts
constexpr SWC_CAN_INLINE void set_timestamp_with_rev_is_ts(int64_t ts) noexcept
Definition: Cell.h:208
SWC::DB::Cells::Cell::get_value
Types::Encoder get_value(StaticBuffer &v, bool owner) const
Definition: Cell.cc:77
SWC::DB::Cell::Key::to_string
SWC_CAN_INLINE std::string to_string() const
Definition: CellKey.h:232
SWC::DB::Cell::Key::copy
void copy(const Key &other)
Definition: CellKey.h:314
SWC::DB::Cells::Cell::value
uint8_t * value
Definition: Cell.h:362
Serialization.h
SWC_THROWF
#define SWC_THROWF(_code_, _fmt_,...)
Definition: Exception.h:136
SWC::DB::Cells::INSERT
@ INSERT
Definition: Cell.h:62
SWC::DB::Cells::Cell::control
uint8_t control
Definition: Cell.h:360
SWC::DB::Cells::REV_IS_TS
constexpr const uint8_t REV_IS_TS
Definition: Cell.h:79
SWC::DB::Cells::Cell::~Cell
SWC_CAN_INLINE ~Cell() noexcept
Definition: Cell.h:151
Buffer.h
SWC::DB::Cells::Cell::_free
SWC_CAN_INLINE void _free() noexcept
Definition: Cell.h:156
SWC::DB::Cells::Cell::set_time_order_desc
constexpr SWC_CAN_INLINE void set_time_order_desc(bool desc) noexcept
Definition: Cell.h:169
SWC::Serialization::encoded_length_vi64
constexpr SWC_CAN_INLINE uint8_t encoded_length_vi64(uint64_t val) noexcept
Definition: Serialization.h:272
Time.h
SWC::DB::Cells::HAVE_TIMESTAMP
constexpr const uint8_t HAVE_TIMESTAMP
Definition: Cell.h:80
SWC::DB::Cell::Key::encoded_length
constexpr uint32_t encoded_length() const noexcept
Definition: CellKey.h:323
SWC::DB::Cells::TIMESTAMP_NULL
constexpr const int64_t TIMESTAMP_NULL
Definition: Cell.h:72
SWC::DB::Cells::Cell::read
void read(const uint8_t **bufp, size_t *remainp, bool owner)
Definition: Cell.h:484
SWC::DB::Cells::Cell::Cell
constexpr SWC_CAN_INLINE Cell(Cell &&other) noexcept
Definition: Cell.h:124
SWC::DB::Cells::Cell::set_timestamp_auto
constexpr SWC_CAN_INLINE void set_timestamp_auto() noexcept
Definition: Cell.h:198
SWC::DB::Cells::Cell::print
void print(std::ostream &out, Types::Column typ) const
Definition: Cell.cc:187
SWC::DB::Cells::Cell::vlen
uint32_t vlen
Definition: Cell.h:361
SWC::DB::Cells::Cell::write
void write(DynamicBuffer &dst_buf, bool no_value=false) const
Definition: Cell.h:513
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::Cells::Cell::get_timestamp
constexpr SWC_CAN_INLINE int64_t get_timestamp() const noexcept
Definition: Cell.h:317
SWC::DB::Cells::OP_EQUAL
constexpr const uint8_t OP_EQUAL
Definition: Cell.h:83
SWC::DB::Cells::MASK_HAVE_REVISION
constexpr const uint8_t MASK_HAVE_REVISION
Definition: Cell.h:89
SWC::DB::Cells::Cell::get_counter
constexpr SWC_CAN_INLINE int64_t get_counter() const
Definition: Cell.h:260
SWC::DB::TIMESTAMP
@ TIMESTAMP
Definition: Cell.h:42
SWC::Serialization::decode_vi64
constexpr SWC_CAN_INLINE uint64_t decode_vi64(const uint8_t **bufp, size_t *remainp)
Definition: Serialization.h:302
SWC::DB::OutputFlag
OutputFlag
Definition: Cell.h:50
SWC::Serialization::encode_vi32
constexpr SWC_CAN_INLINE void encode_vi32(uint8_t **bufp, uint32_t val)
Definition: Serialization.h:243
SWC::DB::NO_TS
@ NO_TS
Definition: Cell.h:51
SWC::DB::Cells::MASK_TS_DESC
constexpr const uint8_t MASK_TS_DESC
Definition: Cell.h:85
SWC::DB::DATETIME
@ DATETIME
Definition: Cell.h:43
SWC::DB::Cells::Cell::set_timestamp_null
constexpr SWC_CAN_INLINE void set_timestamp_null() noexcept
Definition: Cell.h:188
SWC::DB::Cells::Cell::_value
SWC_CAN_INLINE uint8_t * _value(const uint8_t *v)
Definition: Cell.h:367
SWC::DB::Cells::Cell::get_counter
constexpr SWC_CAN_INLINE uint8_t get_counter(int64_t &count) const
Definition: Cell.h:266
SWC::Serialization::encode_vi64
constexpr SWC_CAN_INLINE void encode_vi64(uint8_t **bufp, uint64_t val)
Definition: Serialization.h:286
SWC::DB::Cells::Cell::equal
bool SWC_PURE_FUNC equal(const Cell &other) const noexcept
Definition: Cell.cc:100
flags
uint8_t flags
Flags.
Definition: Header.h:55
SWC::DB::Cells::Cell::set_value
SWC_CAN_INLINE void set_value(const std::string &v, bool owner)
Definition: Cell.h:240
SWC::DB::Cells::TIMESTAMP_MAX
constexpr const int64_t TIMESTAMP_MAX
Definition: Cell.h:75
SWC::DB::Cells::Cell::Cell
SWC_CAN_INLINE Cell(const Cell &other, bool no_value)
Definition: Cell.h:114
SWC::DB::Cells::Cell::copy
void copy(const Cell &other, bool no_value=false)
Definition: Cell.h:424
SWC::DB::Cells::flag_from
Flag SWC_PURE_FUNC flag_from(const uint8_t *rptr, uint32_t len) noexcept
Definition: Cell.cc:32
SWC::Serialization::decode_i8
constexpr SWC_CAN_INLINE uint8_t decode_i8(const uint8_t **bufp, size_t *remainp)
Definition: Serialization.h:91
SWC::Serialization::decode_i64
SWC_CAN_INLINE uint64_t decode_i64(const uint8_t **bufp, size_t *remainp)
Definition: Serialization.h:156
Cell.cc
SWC::DB::Cells::Cell::flag
uint8_t flag
Definition: Cell.h:359
CellKey.h
SWC::DB::Cells::Cell::get_revision
constexpr SWC_CAN_INLINE int64_t get_revision() const noexcept
Definition: Cell.h:322
SWC::DB::Cell::Key::encode
void encode(uint8_t **bufp) const
Definition: CellKey.h:328
SWC::DB::Cells::Cell::Cell
SWC_CAN_INLINE Cell(const Cell &other)
Definition: Cell.h:104
SWC::Serialization::decode_vi32
constexpr SWC_CAN_INLINE uint32_t decode_vi32(const uint8_t **bufp, size_t *remainp)
Definition: Serialization.h:254
SWC::DB::Cells::Cell::Ptr
std::shared_ptr< Cell > Ptr
Definition: Cell.h:94
SWC::DB::Cells::Cell::set_timestamp
constexpr SWC_CAN_INLINE void set_timestamp(int64_t ts) noexcept
Definition: Cell.h:182