SWC-DB  v0.5.12 C++ documentations
SWC-DB© (Super Wide Column Database) - High Performance Scalable Database (https://github.com/kashirin-alex/swc-db)
RangeLocate.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_ranger_Protocol_handlers_RangeLocate_h
8 #define swcdb_ranger_Protocol_handlers_RangeLocate_h
9 
12 
13 
14 namespace SWC { namespace Comm { namespace Protocol {
15 namespace Rgr { namespace Handler {
16 
17 
18 struct RangeLocate {
21 
24  const Comm::Event::Ptr& a_ev) noexcept
25  : conn(a_conn), ev(a_ev) {
26  }
27 
29  RangeLocate(RangeLocate&& other) noexcept
30  : conn(std::move(other.conn)),
31  ev(std::move(other.ev)) {
32  }
33 
34  RangeLocate(const RangeLocate&) = delete;
36  RangeLocate& operator=(const RangeLocate&) = delete;
37 
38  ~RangeLocate() noexcept { }
39 
40  void operator()() {
41  if(ev->expired())
42  return;
43 
44  int err = Error::OK;
46  Ranger::RangePtr range;
47 
48  try {
49  const uint8_t *ptr = ev->data.base;
50  size_t remain = ev->data.size;
51  params.decode(&ptr, &remain);
52 
53  range = Env::Rgr::columns()->get_range(err, params.cid, params.rid);
54  if((!err && (!range || !range->is_loaded())) ||
56  params.revision != range->get_load_revision()))
58 
59  } catch(...) {
62  err = e.code();
63  }
64 
65 
66  if(err) {
68  params.print(SWC_LOG_OSTREAM);
69  Error::print(SWC_LOG_OSTREAM << ' ', err);
70  );
71 
72  conn->send_response(Buffers::make(ev, Params::RangeLocateRsp(err)));
73 
74  } else {
75 
76  Ranger::ReqScan* req;
79  conn, ev,
80  params.range_begin, //params.range_end,
81  range,
82  params.flags
83  );
84  } else {
86  conn, ev,
87  params.range_begin, params.range_end,
88  range,
89  params.flags
90  );
93  req->spec.offset_key.copy(params.range_offset);
94  }
95 
96  range->scan(Ranger::ReqScan::Ptr(req));
97  }
98 
99  }
100 
101 };
102 
103 
104 }}}}}
105 
106 #endif // swcdb_ranger_Protocol_handlers_RangeLocate_h
SWC::Error::RGR_NOT_LOADED_RANGE
@ RGR_NOT_LOADED_RANGE
Definition: Error.h:91
SWC::Ranger::ReqScan
Definition: ReqScan.h:21
SWC::Error::Exception::code
constexpr SWC_CAN_INLINE int code() const noexcept
Definition: Exception.h:51
SWC::Ranger::Columns::get_range
RangePtr get_range(int &err, const cid_t cid, const rid_t rid)
Definition: Columns.cc:21
SWC_LOG_OSTREAM
#define SWC_LOG_OSTREAM
Definition: Logger.h:44
SWC::Comm::Protocol::Rgr::Handler::RangeLocate::operator()
void operator()()
Definition: RangeLocate.h:40
SWC_LOG_OUT
#define SWC_LOG_OUT(pr, _code_)
Definition: Logger.h:178
SWC::Comm::Protocol::Rgr::Handler::RangeLocate::ev
Comm::Event::Ptr ev
Definition: RangeLocate.h:20
SWC::Comm::Protocol::Rgr::Params::RangeLocateReq::range_begin
DB::Cell::Key range_begin
Definition: RangeLocate.h:43
SWC::Comm::Protocol::Rgr::Params::RangeLocateRsp
Definition: RangeLocate.h:59
SWC::Comm::Protocol::Rgr::Params::RangeLocateReq::NEXT_RANGE
static const uint8_t NEXT_RANGE
Definition: RangeLocate.h:23
SWC::Env::Rgr::columns
static SWC_CAN_INLINE Ranger::Columns * columns() noexcept
Definition: RangerEnv.h:144
SWC::Comm::Protocol::Rgr::Params::RangeLocateReq::HAVE_REVISION
static const uint8_t HAVE_REVISION
Definition: RangeLocate.h:27
SWC::Comm::Protocol::Rgr::Handler::RangeLocate
Definition: RangeLocate.h:18
SWC::Comm::Protocol::Rgr::Params::RangeLocateReq::print
void print(std::ostream &out) const
Definition: RangeLocate.cc:16
SWC::Comm::Protocol::Rgr::Handler::RangeLocate::conn
Comm::ConnHandlerPtr conn
Definition: RangeLocate.h:19
SWC::Comm::Protocol::Rgr::Handler::RangeLocate::~RangeLocate
~RangeLocate() noexcept
Definition: RangeLocate.h:38
SWC::Error::OK
@ OK
Definition: Error.h:45
SWC::Ranger::RangePtr
std::shared_ptr< Range > RangePtr
Definition: Columns.h:15
SWC_CAN_INLINE
#define SWC_CAN_INLINE
Definition: Compat.h:102
SWC::LOG_DEBUG
@ LOG_DEBUG
Definition: Logger.h:36
SWC::Comm::Protocol::Rgr::Params::RangeLocateReq::range_end
DB::Cell::Key range_end
Definition: RangeLocate.h:43
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::Rgr::Params::RangeLocateReq::range_offset
DB::Cell::Key range_offset
Definition: RangeLocate.h:43
RangeLocate.h
SWC::Comm::Protocol::Rgr::Handler::RangeLocate::RangeLocate
SWC_CAN_INLINE RangeLocate(const Comm::ConnHandlerPtr &a_conn, const Comm::Event::Ptr &a_ev) noexcept
Definition: RangeLocate.h:23
SWC::Comm::Protocol::Rgr::Handler::RangeLocate::operator=
RangeLocate & operator=(const RangeLocate &)=delete
SWC::Ranger::Callback::RangeLocateScan
Definition: RangeLocateScan.h:15
SWC::Comm::Protocol::Rgr::Params::RangeLocateReq
Definition: RangeLocate.h:19
SWC::Ranger::Callback::RangeLocateScanCommit
Definition: RangeLocateScanCommit.h:14
SWC::Comm::Protocol::Rgr::Handler::RangeLocate::RangeLocate
RangeLocate(const RangeLocate &)=delete
SWC::DB::Cell::Key::copy
void copy(const Key &other)
Definition: CellKey.h:314
SWC::Comm::Protocol::Rgr::Params::RangeLocateReq::rid
rid_t rid
Definition: RangeLocate.h:42
SWC::Comm::Protocol::Rgr::Params::RangeLocateReq::flags
uint8_t flags
Definition: RangeLocate.h:44
SWC::LOG_ERROR
@ LOG_ERROR
Definition: Logger.h:32
SWC::Comm::Protocol::Rgr::Params::RangeLocateReq::cid
cid_t cid
Definition: RangeLocate.h:41
SWC::Comm::ConnHandlerPtr
std::shared_ptr< ConnHandler > ConnHandlerPtr
Definition: AppContext.h:17
SWC::Comm::Protocol::Rgr::Params::RangeLocateReq::revision
int64_t revision
Definition: RangeLocate.h:45
SWC::DB::Cells::ReqScan::spec
DB::Specs::Interval spec
Definition: ReqScan.h:106
SWC::Comm::Protocol::Rgr::Handler::RangeLocate::RangeLocate
SWC_CAN_INLINE RangeLocate(RangeLocate &&other) noexcept
Definition: RangeLocate.h:29
SWC::Comm::Buffers::make
static SWC_CAN_INLINE Ptr make(uint32_t reserve=0)
Definition: Buffers.h:27
RangeLocateScanCommit.h
SWC::DB::Specs::Interval::offset_key
Cell::Key offset_key
Definition: SpecsInterval.h:244
SWC::Comm::Protocol::Rgr::Params::RangeLocateReq::COMMIT
static const uint8_t COMMIT
Definition: RangeLocate.h:24
SWC::Comm::Protocol::Rgr::Handler::RangeLocate::operator=
RangeLocate & operator=(RangeLocate &&)=delete
SWC::Comm::Serializable::decode
void decode(const uint8_t **bufp, size_t *remainp)
Definition: Serializable.h:59
SWC::Comm::Event::Ptr
std::shared_ptr< Event > Ptr
Definition: Event.h:33
SWC::Error::print
void print(std::ostream &out, int err)
Definition: Error.cc:191
SWC::Comm::Protocol::Rgr::Params::RangeLocateReq::CURRENT_RANGE
static const uint8_t CURRENT_RANGE
Definition: RangeLocate.h:22
SWC::Ranger::ReqScan::Ptr
std::shared_ptr< ReqScan > Ptr
Definition: ReqScan.h:30
SWC::Error::Exception
Definition: Exception.h:21