 |
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_Cell_h
8 #define swcdb_db_cells_Cell_h
94 typedef std::shared_ptr<Cell>
Ptr;
125 :
key(std::move(other.key)),
own(other.own),
flag(other.flag),
131 other.value =
nullptr;
136 Cell(
const uint8_t** bufp,
size_t* remainp,
bool own);
148 void copy(
const Cell& other,
bool no_value=
false);
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);
261 const uint8_t *ptr =
value;
267 const uint8_t* ptr =
value;
274 const uint8_t *ptr =
value;
282 void read(
const uint8_t** bufp,
size_t* remainp,
bool owner);
339 uint8_t
flags=0,
bool meta=
false)
const;
345 std::stringstream ss;
355 uint8_t& op, int64_t&
value) noexcept;
369 ?
static_cast<uint8_t*
>(memcpy(
new uint8_t[
vlen], v,
vlen))
381 Cell::Cell(
const uint8_t** bufp,
size_t* remainp,
bool a_own)
383 flag(Serialization::
decode_i8(bufp, remainp)),
384 control(), vlen(), value(), timestamp(), revision() {
414 control = other.control;
415 timestamp = other.timestamp;
416 revision = other.revision;
419 other.value =
nullptr;
445 v.append(
reinterpret_cast<const char*
>(_v.
base), _v.
size);
455 case Types::Column::COUNTER_I8:
458 case Types::Column::COUNTER_I16:
461 case Types::Column::COUNTER_I32:
475 uint8_t* ptr = (
value =
new uint8_t[
vlen]);
484 void Cell::read(
const uint8_t** bufp,
size_t* remainp,
bool owner) {
541 uint8_t& op, int64_t& value) noexcept {
557 const char* p =
reinterpret_cast<const char*
>(*ptrp);
558 char *last =
const_cast<char*
>(p + (*remainp > 30 ? 30 : *remainp));
560 value = strtoll(p, &last, 0);
563 }
else if(last > p) {
564 *remainp -= last - p;
565 *ptrp =
reinterpret_cast<const uint8_t*
>(last);
575 #ifdef SWC_IMPL_SOURCE
579 #endif // swcdb_db_Cells_Cell_h
void set_counter(uint8_t op, int64_t v, Types::Column typ=Types::Column::COUNTER_I64, int64_t rev=TIMESTAMP_NULL)
SWC_CAN_INLINE void set_value(uint8_t *v, uint32_t len, bool owner)
constexpr SWC_CAN_INLINE bool removal() const noexcept
constexpr SWC_CAN_INLINE Cell() noexcept
constexpr const uint8_t MASK_HAVE_TIMESTAMP
constexpr const int64_t TIMESTAMP_MIN
SWC_CAN_INLINE void encode_i64(uint8_t **bufp, uint64_t val) noexcept
SWC_CAN_INLINE int64_t now_ns() noexcept
const char *SWC_CONST_FUNC to_string(Flag flag) noexcept
SWC_CAN_INLINE void free() noexcept
constexpr SWC_CAN_INLINE uint8_t encoded_length_vi32(uint32_t val) noexcept
constexpr const uint8_t MASK_REV_IS_TS
SWC_CAN_INLINE void set_value(const char *v, uint32_t len, bool owner)
SWC_CAN_INLINE void set_value(const char *v, bool owner)
SWC_CAN_INLINE void ensure(size_t len)
constexpr const int64_t TIMESTAMP_AUTO
constexpr SWC_CAN_INLINE bool is_removing(const int64_t &ts) const noexcept
@ SERIALIZATION_INPUT_OVERRUN
SWC_CAN_INLINE value_type * add_unchecked(const value_type *data, size_t len) noexcept
constexpr SWC_CAN_INLINE void encode_i8(uint8_t **bufp, uint8_t val) noexcept
static int counter_from_str(const uint8_t **ptrp, size_t *remainp, uint8_t &op, int64_t &value) noexcept
void move(Cell &other) noexcept
constexpr SWC_CAN_INLINE int64_t get_counter(uint8_t &op, int64_t &rev) const
SWC_CAN_INLINE bool has_expired(const int64_t ttl) const noexcept
void decode(const uint8_t **bufp, size_t *remainp, bool owner)
SWC_CAN_INLINE std::string to_string(Types::Column typ=Types::Column::PLAIN) const
constexpr SWC_CAN_INLINE void set_revision(int64_t ts) noexcept
constexpr const uint8_t TS_DESC
Cell & operator=(const Cell &)=delete
constexpr const uint8_t MASK_HAVE_ENCODER
constexpr SWC_CAN_INLINE bool is_time_order_desc() const noexcept
SWC_CAN_INLINE Cell & operator=(Cell &&other) noexcept
The SWC-DB C++ namespace 'SWC'.
void display(std::ostream &out, Types::Column typ=Types::Column::PLAIN, uint8_t flags=0, bool meta=false) const
constexpr SWC_CAN_INLINE bool have_encoder() const noexcept
SWC_CAN_INLINE void set_value(Types::Encoder encoder, const std::string &v)
constexpr const uint8_t HAVE_ENCODER
constexpr const uint8_t HAVE_REVISION
constexpr SWC_CAN_INLINE void set_timestamp_with_rev_is_ts(int64_t ts) noexcept
Types::Encoder get_value(StaticBuffer &v, bool owner) const
SWC_CAN_INLINE std::string to_string() const
void copy(const Key &other)
#define SWC_THROWF(_code_, _fmt_,...)
constexpr const uint8_t REV_IS_TS
SWC_CAN_INLINE ~Cell() noexcept
SWC_CAN_INLINE void _free() noexcept
constexpr SWC_CAN_INLINE void set_time_order_desc(bool desc) noexcept
constexpr SWC_CAN_INLINE uint8_t encoded_length_vi64(uint64_t val) noexcept
constexpr const uint8_t HAVE_TIMESTAMP
constexpr uint32_t encoded_length() const noexcept
constexpr const int64_t TIMESTAMP_NULL
void read(const uint8_t **bufp, size_t *remainp, bool owner)
constexpr SWC_CAN_INLINE Cell(Cell &&other) noexcept
constexpr SWC_CAN_INLINE void set_timestamp_auto() noexcept
void print(std::ostream &out, Types::Column typ) const
void write(DynamicBuffer &dst_buf, bool no_value=false) const
constexpr SWC_CAN_INLINE size_t encoded_length(bool no_value=false) const noexcept
constexpr SWC_CAN_INLINE int64_t get_timestamp() const noexcept
constexpr const uint8_t OP_EQUAL
constexpr const uint8_t MASK_HAVE_REVISION
constexpr SWC_CAN_INLINE int64_t get_counter() const
constexpr SWC_CAN_INLINE uint64_t decode_vi64(const uint8_t **bufp, size_t *remainp)
constexpr SWC_CAN_INLINE void encode_vi32(uint8_t **bufp, uint32_t val)
constexpr const uint8_t MASK_TS_DESC
constexpr SWC_CAN_INLINE void set_timestamp_null() noexcept
SWC_CAN_INLINE uint8_t * _value(const uint8_t *v)
constexpr SWC_CAN_INLINE uint8_t get_counter(int64_t &count) const
constexpr SWC_CAN_INLINE void encode_vi64(uint8_t **bufp, uint64_t val)
bool SWC_PURE_FUNC equal(const Cell &other) const noexcept
SWC_CAN_INLINE void set_value(const std::string &v, bool owner)
constexpr const int64_t TIMESTAMP_MAX
SWC_CAN_INLINE Cell(const Cell &other, bool no_value)
void copy(const Cell &other, bool no_value=false)
Flag SWC_PURE_FUNC flag_from(const uint8_t *rptr, uint32_t len) noexcept
constexpr SWC_CAN_INLINE uint8_t decode_i8(const uint8_t **bufp, size_t *remainp)
SWC_CAN_INLINE uint64_t decode_i64(const uint8_t **bufp, size_t *remainp)
constexpr SWC_CAN_INLINE int64_t get_revision() const noexcept
void encode(uint8_t **bufp) const
SWC_CAN_INLINE Cell(const Cell &other)
constexpr SWC_CAN_INLINE uint32_t decode_vi32(const uint8_t **bufp, size_t *remainp)
std::shared_ptr< Cell > Ptr
constexpr SWC_CAN_INLINE void set_timestamp(int64_t ts) noexcept