SWC-DB  v0.5.12 C++ documentations
SWC-DB© (Super Wide Column Database) - High Performance Scalable Database (https://github.com/kashirin-alex/swc-db)
RgrGet.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 
10 
11 
12 namespace SWC { namespace Comm { namespace Protocol {
13 namespace Mngr { namespace Params {
14 
15 
16 
17 void RgrGetReq::print(std::ostream& out) const {
18  out << "Ranger(cid=" << cid << " rid=" << rid;
19  if(!rid) {
20  out << " next_range=" << next_range;
21  range_begin.print(out << " RangeBegin");
22  range_end.print(out << " RangeEnd");
23  }
24  out << ')';
25 }
26 
30  + (rid ? 0 :
33  + 1)
34  );
35 }
36 
37 void RgrGetReq::internal_encode(uint8_t** bufp) const {
40  if(!rid) {
41  range_begin.encode(bufp);
42  range_end.encode(bufp);
44  }
45 }
46 
47 void RgrGetReq::internal_decode(const uint8_t** bufp, size_t* remainp) {
48  cid = Serialization::decode_vi64(bufp, remainp);
49  rid = Serialization::decode_vi64(bufp, remainp);
50  if(!rid) {
51  range_begin.decode(bufp, remainp, false);
52  range_end.decode(bufp, remainp, false);
53  next_range = Serialization::decode_bool(bufp, remainp);
54  }
55 }
56 
57 
58 RgrGetRsp::RgrGetRsp(int a_err, const uint8_t* ptr, size_t remain) noexcept
59  : endpoints(),
60  err(a_err), cid(), rid(),
61  range_end(), range_begin(),
62  revision() {
63  if(!err) try {
64  decode(&ptr, &remain);
65  } catch(...) {
67  err = e.code();
69  }
70 }
71 
72 void RgrGetRsp::print(std::ostream& out) const {
73  out << "Ranger(";
74  Error::print(out, err);
75  if(!err) {
76  out << " cid=" << cid << " rid=" << rid;
77  Comm::print(out << ' ', endpoints);
79  range_begin.print(out << " RangeBegin");
80  range_end.print(out << " RangeEnd");
81  out << " revision=" << revision;
82  }
83  }
84  out << ')';
85 }
86 
89  + (err ? 0 :
97  : 0)
98  )
99  );
100 }
101 
102 void RgrGetRsp::internal_encode(uint8_t** bufp) const {
104  if(!err) {
109  range_begin.encode(bufp);
110  range_end.encode(bufp);
112  }
113  }
114 }
115 
116 void RgrGetRsp::internal_decode(const uint8_t** bufp, size_t* remainp) {
117  err = Serialization::decode_vi32(bufp, remainp);
118  if(!err) {
119  cid = Serialization::decode_vi64(bufp, remainp);
120  rid = Serialization::decode_vi64(bufp, remainp);
121  Serialization::decode(bufp, remainp, endpoints);
123  range_begin.decode(bufp, remainp, false);
124  range_end.decode(bufp, remainp, false);
125  revision = Serialization::decode_vi64(bufp, remainp);
126  }
127  }
128 }
129 
130 
131 }}}}}
SWC::Error::Exception::code
constexpr SWC_CAN_INLINE int code() const noexcept
Definition: Exception.h:51
SWC_LOG_OSTREAM
#define SWC_LOG_OSTREAM
Definition: Logger.h:44
SWC_LOG_OUT
#define SWC_LOG_OUT(pr, _code_)
Definition: Logger.h:178
SWC::Comm::Protocol::Mngr::Params::RgrGetReq::next_range
bool next_range
Definition: RgrGet.h:38
SWC::Serialization::encoded_length_vi32
constexpr SWC_CAN_INLINE uint8_t encoded_length_vi32(uint32_t val) noexcept
Definition: Serialization.h:234
RgrGet.h
SWC::Comm::Protocol::Mngr::Params::RgrGetRsp::print
void print(std::ostream &out) const
Definition: RgrGet.cc:72
SWC::Comm::Protocol::Mngr::Params::RgrGetRsp::rid
rid_t rid
Definition: RgrGet.h:80
SWC::Comm::Protocol::Mngr::Params::RgrGetRsp::range_begin
DB::Cell::Key range_begin
Definition: RgrGet.h:82
SWC::DB::Types::SystemColumn::is_master
constexpr SWC_CAN_INLINE bool is_master(cid_t cid) noexcept
Definition: SystemColumn.h:31
SWC::Comm::Protocol::Mngr::Params::RgrGetRsp::internal_encode
void internal_encode(uint8_t **bufp) const override
Definition: RgrGet.cc:102
SWC::Serialization::encoded_length
SWC_CAN_INLINE uint8_t encoded_length(const Comm::EndPoint &endpoint) noexcept
Definition: Resolver.h:63
SWC::Comm::Protocol::Mngr::Params::RgrGetReq::range_end
DB::Cell::Key range_end
Definition: RgrGet.h:37
SWC::Comm::print
void print(std::ostream &out, const EndPoints &endpoints)
Definition: Resolver.cc:85
SWC::Serialization::encode
void encode(uint8_t **bufp, const Comm::EndPoint &endpoint)
Definition: Resolver.cc:22
SWC::DB::Cell::Key::decode
void decode(const uint8_t **bufp, size_t *remainp, bool owner)
Definition: CellKey.h:337
SWC::Serialization::encode_bool
constexpr SWC_CAN_INLINE void encode_bool(uint8_t **bufp, bool bval) noexcept
Definition: Serialization.h:102
decode
void decode(const uint8_t **bufp, size_t *remainp)
Definition: HeaderBufferInfo.h:33
SWC::Comm::Protocol::Mngr::Params::RgrGetRsp::range_end
DB::Cell::Key range_end
Definition: RgrGet.h:81
SWC_CURRENT_EXCEPTION
#define SWC_CURRENT_EXCEPTION(_msg_)
Definition: Exception.h:119
SWC
The SWC-DB C++ namespace 'SWC'.
Definition: main.cc:12
SWC::Comm::Protocol::Mngr::Params::RgrGetReq::internal_decode
void internal_decode(const uint8_t **bufp, size_t *remainp) override
Definition: RgrGet.cc:47
SWC::Serialization::decode_bool
constexpr SWC_CAN_INLINE bool decode_bool(const uint8_t **bufp, size_t *remainp)
Definition: Serialization.h:107
SWC::Comm::Protocol::Mngr::Params::RgrGetReq::internal_encoded_length
size_t SWC_PURE_FUNC internal_encoded_length() const override
Definition: RgrGet.cc:27
SWC::Comm::Protocol::Mngr::Params::RgrGetReq::range_begin
DB::Cell::Key range_begin
Definition: RgrGet.h:37
Serialization.h
SWC::Comm::Protocol::Mngr::Params::RgrGetRsp::cid
cid_t cid
Definition: RgrGet.h:79
SWC::Serialization::encoded_length_vi64
constexpr SWC_CAN_INLINE uint8_t encoded_length_vi64(uint64_t val) noexcept
Definition: Serialization.h:272
SWC::DB::Cell::Key::encoded_length
constexpr uint32_t encoded_length() const noexcept
Definition: CellKey.h:323
SWC::LOG_ERROR
@ LOG_ERROR
Definition: Logger.h:32
SWC::Comm::Protocol::Mngr::Params::RgrGetReq::cid
cid_t cid
Definition: RgrGet.h:35
SWC::Comm::Protocol::Mngr::Params::RgrGetRsp::revision
int64_t revision
Definition: RgrGet.h:83
SWC::Comm::Protocol::Mngr::Params::RgrGetRsp::internal_encoded_length
size_t SWC_PURE_FUNC internal_encoded_length() const override
Definition: RgrGet.cc:87
SWC::Comm::Protocol::Mngr::Params::RgrGetReq::internal_encode
void internal_encode(uint8_t **bufp) const override
Definition: RgrGet.cc:37
SWC::Comm::Protocol::Mngr::Params::RgrGetRsp::err
int err
Definition: RgrGet.h:78
SWC::Serialization::decode
Comm::EndPoint decode(const uint8_t **bufp, size_t *remainp)
Definition: Resolver.cc:35
SWC::Serialization::decode_vi64
constexpr SWC_CAN_INLINE uint64_t decode_vi64(const uint8_t **bufp, size_t *remainp)
Definition: Serialization.h:302
SWC::Comm::Protocol::Mngr::Params::RgrGetRsp::RgrGetRsp
SWC_CAN_INLINE RgrGetRsp(int a_err=Error::OK) noexcept
Definition: RgrGet.h:57
SWC::Serialization::encode_vi32
constexpr SWC_CAN_INLINE void encode_vi32(uint8_t **bufp, uint32_t val)
Definition: Serialization.h:243
SWC::Comm::Protocol::Mngr::Params::RgrGetReq::print
void print(std::ostream &out) const
Definition: RgrGet.cc:17
SWC::DB::Cell::Key::print
void print(std::ostream &out) const
Definition: CellKey.cc:182
SWC::Serialization::encode_vi64
constexpr SWC_CAN_INLINE void encode_vi64(uint8_t **bufp, uint64_t val)
Definition: Serialization.h:286
SWC::Comm::Protocol::Mngr::Params::RgrGetRsp::endpoints
EndPoints endpoints
Definition: RgrGet.h:77
SWC::Error::print
void print(std::ostream &out, int err)
Definition: Error.cc:191
SWC::Comm::Protocol::Mngr::Params::RgrGetReq::rid
rid_t rid
Definition: RgrGet.h:36
SWC::Comm::Protocol::Mngr::Params::RgrGetRsp::internal_decode
void internal_decode(const uint8_t **bufp, size_t *remainp) override
Definition: RgrGet.cc:116
SWC::Error::Exception
Definition: Exception.h:21
SystemColumn.h
SWC::DB::Cell::Key::encode
void encode(uint8_t **bufp) const
Definition: CellKey.h:328
SWC::Serialization::decode_vi32
constexpr SWC_CAN_INLINE uint32_t decode_vi32(const uint8_t **bufp, size_t *remainp)
Definition: Serialization.h:254