SWC-DB  v0.5.12 C++ documentations
SWC-DB© (Super Wide Column Database) - High Performance Scalable Database (https://github.com/kashirin-alex/swc-db)
RangeLocateScanCommit.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 #ifndef swcdb_ranger_callbacks_RangeLocateScanCommit_h
7 #define swcdb_ranger_callbacks_RangeLocateScanCommit_h
8 
10 
11 namespace SWC { namespace Ranger { namespace Callback {
12 
13 
15  public:
16 
17  typedef std::shared_ptr<RangeLocateScanCommit> Ptr;
18 
21  const Comm::Event::Ptr& ev,
22  const DB::Cell::Key& a_range_begin,
23  const RangePtr& a_range,
24  uint8_t a_flags)
26  conn, ev,
27  a_range_begin, DB::Cell::Key(), a_range, a_flags
28  ) {
29  }
30 
31  virtual ~RangeLocateScanCommit() noexcept { }
32 
33  bool selector(const DB::Types::KeySeq key_seq,
34  const DB::Cells::Cell& cell, bool& stop) override {
35  if(any_is &&
37  != Condition::EQ)
38  return false;
39 
40  StaticBuffer v;
41  cell.get_value(v, false);
42  const uint8_t* ptr = v.base;
43  size_t remain = v.size;
44 
46  DB::Cell::Key key_end;
47  key_end.decode(&ptr, &remain, false);
48  bool match = key_end.count == any_is ||
49  DB::KeySeq::compare(key_seq, key_end, range_begin)
50  != Condition::GT;
51  if(match) {
52  stop = true;
53  uint8_t after_idx = range->cfg->range_type == DB::Types::Range::MASTER;
54  params.range_begin.copy(after_idx, cell.key);
55  params.range_end.copy(after_idx, key_end);
57  params.rid = Serialization::decode_vi64(&ptr, &remain);
58  }
59  return match;
60  }
61 
62 
63 };
64 
65 
66 }}}
67 #endif // swcdb_ranger_callbacks_RangeLocateScanCommit_h
SWC::Condition::GT
@ GT
Definition: Comparators.h:30
SWC::Ranger::Callback::RangeLocateScanCommit::~RangeLocateScanCommit
virtual ~RangeLocateScanCommit() noexcept
Definition: RangeLocateScanCommit.h:31
SWC::Ranger::Callback::RangeLocateScanCommit::RangeLocateScanCommit
SWC_CAN_INLINE RangeLocateScanCommit(const Comm::ConnHandlerPtr &conn, const Comm::Event::Ptr &ev, const DB::Cell::Key &a_range_begin, const RangePtr &a_range, uint8_t a_flags)
Definition: RangeLocateScanCommit.h:20
SWC::Comm::Protocol::Rgr::Params::RangeLocateRsp::range_end
DB::Cell::Key range_end
Definition: RangeLocate.h:78
SWC::Comm::Protocol::Rgr::Params::RangeLocateRsp::rid
rid_t rid
Definition: RangeLocate.h:77
SWC::DB::Cells::Cell
Definition: Cell.h:92
SWC::Ranger::Callback::RangeLocateScanCommit::selector
bool selector(const DB::Types::KeySeq key_seq, const DB::Cells::Cell &cell, bool &stop) override
Definition: RangeLocateScanCommit.h:33
SWC::DB::Cell::Key
Definition: CellKey.h:24
SWC::DB::Cells::Cell::key
DB::Cell::Key key
Definition: Cell.h:357
SWC::DB::Cell::Key::decode
void decode(const uint8_t **bufp, size_t *remainp, bool owner)
Definition: CellKey.h:337
SWC::DB::Types::KeySeq
KeySeq
Definition: KeySeq.h:13
SWC::Ranger::RangePtr
std::shared_ptr< Range > RangePtr
Definition: Columns.h:15
SWC_CAN_INLINE
#define SWC_CAN_INLINE
Definition: Compat.h:102
SWC::Comm::Protocol::Rgr::Params::RangeLocateRsp::range_begin
DB::Cell::Key range_begin
Definition: RangeLocate.h:79
SWC::Core::Buffer::base
value_type * base
Definition: Buffer.h:131
SWC
The SWC-DB C++ namespace 'SWC'.
Definition: main.cc:12
RangeLocateScan.h
SWC::DB::KeySeq::compare_upto
Condition::Comp compare_upto(const Types::KeySeq seq, const Cell::Key &key, const Cell::Key &other, uint24_t max) SWC_ATTRIBS((SWC_ATTRIB_O3))
Definition: KeyComparator.h:417
SWC::Ranger::Callback::RangeLocateScan::range
RangePtr range
Definition: RangeLocateScan.h:168
SWC::Ranger::Callback::RangeLocateScan
Definition: RangeLocateScan.h:15
SWC::Core::Buffer
Definition: Buffer.h:18
SWC::Ranger::Callback::RangeLocateScanCommit
Definition: RangeLocateScanCommit.h:14
SWC::Core::Buffer::size
size_t size
Definition: Buffer.h:130
SWC::Condition::EQ
@ EQ
Definition: Comparators.h:32
SWC::DB::Cells::Cell::get_value
Types::Encoder get_value(StaticBuffer &v, bool owner) const
Definition: Cell.cc:77
SWC::DB::Cell::Key::copy
void copy(const Key &other)
Definition: CellKey.h:314
SWC::Ranger::Callback::RangeLocateScan::range_begin
const DB::Cell::Key range_begin
Definition: RangeLocateScan.h:171
SWC::Ranger::Callback::RangeLocateScanCommit::Ptr
std::shared_ptr< RangeLocateScanCommit > Ptr
Definition: RangeLocateScanCommit.h:17
SWC::Comm::ConnHandlerPtr
std::shared_ptr< ConnHandler > ConnHandlerPtr
Definition: AppContext.h:17
SWC::Ranger::Callback::RangeLocateScan::any_is
uint32_t any_is
Definition: RangeLocateScan.h:170
SWC::DB::Cell::Key::count
uint24_t count
Definition: CellKey.h:255
SWC::DB::Cell::Serial::Value::skip_type_and_id
SWC_CAN_INLINE void skip_type_and_id(const uint8_t **bufp, size_t *remainp)
Definition: CellValueSerialField.h:61
SWC::Serialization::decode_vi64
constexpr SWC_CAN_INLINE uint64_t decode_vi64(const uint8_t **bufp, size_t *remainp)
Definition: Serialization.h:302
SWC::Ranger::Callback::RangeLocateScan::params
Comm::Protocol::Rgr::Params::RangeLocateRsp params
Definition: RangeLocateScan.h:173
SWC::Comm::Event::Ptr
std::shared_ptr< Event > Ptr
Definition: Event.h:33
SWC::DB::KeySeq::compare
Condition::Comp compare(const Types::KeySeq seq, const Cell::Key &key, const Cell::Key &other) SWC_ATTRIBS((SWC_ATTRIB_O3))
Definition: KeyComparator.h:294