SWC-DB  v0.5.12 C++ documentations
SWC-DB© (Super Wide Column Database) - High Performance Scalable Database (https://github.com/kashirin-alex/swc-db)
RangeQuerySelectUpdating_Insert.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_RangeQuerySelectUpdating_Insert_h
7 #define swcdb_ranger_callbacks_RangeQuerySelectUpdating_Insert_h
8 
9 
11 
12 
13 namespace SWC { namespace Ranger { namespace Callback {
14 
15 
17  : public RangeQuerySelectUpdating {
18  public:
19 
20  typedef std::shared_ptr<RangeQuerySelectUpdating_Insert> Ptr;
21 
24  const Comm::Event::Ptr& ev,
25  DB::Specs::Interval&& req_spec,
26  const RangePtr& a_range)
28  conn,
29  ev,
30  std::move(req_spec),
31  a_range
32  ) {
33  only_keys = false;
34  }
35 
36  virtual ~RangeQuerySelectUpdating_Insert() noexcept { }
37 
38  void update_cell_value(DB::Cells::Cell& cell) override {
39  StaticBuffer v;
40  DB::Types::Encoder encoder = cell.get_value(v, false);
41  uint32_t sz = v.size + spec.updating->vlen;
42 
43  uint32_t pos = spec.updating->operation.get_pos();
44  if(pos > v.size)
45  pos = v.size;
46  uint8_t* ptr = static_cast<uint8_t*>(memcpy(
47  new uint8_t[sz],
48  v.base,
49  pos
50  ));
51  memcpy(
52  ptr + pos,
53  spec.updating->value,
54  spec.updating->vlen
55  );
56  memcpy(
57  ptr + pos + spec.updating->vlen,
58  v.base + pos,
59  v.size - pos
60  );
61 
63  encoder = spec.updating->encoder;
65  cell.own = true;
66  cell.value = ptr;
67  cell.vlen = sz;
68  } else {
69  cell.set_value(encoder, ptr, sz);
70  delete [] ptr;
71  }
72 
73  }
74 
75 };
76 
77 
78 }}}
79 #endif // swcdb_ranger_callbacks_RangeQuerySelectUpdating_Insert_h
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::Core::Encoder::Type
Type
Definition: Encoder.h:28
SWC::DB::Cells::Cell
Definition: Cell.h:92
SWC::DB::Cells::Cell::own
bool own
Definition: Cell.h:358
SWC::Core::Encoder::Type::DEFAULT
@ DEFAULT
encoder
Core::Encoder::Type encoder
Buffer Encoder.
Definition: HeaderBufferInfo.h:50
RangeQuerySelectUpdating.h
SWC::Ranger::RangePtr
std::shared_ptr< Range > RangePtr
Definition: Columns.h:15
SWC_CAN_INLINE
#define SWC_CAN_INLINE
Definition: Compat.h:102
SWC::Core::Buffer::base
value_type * base
Definition: Buffer.h:131
SWC
The SWC-DB C++ namespace 'SWC'.
Definition: main.cc:12
SWC::Core::Buffer
Definition: Buffer.h:18
SWC::Core::Buffer::size
size_t size
Definition: Buffer.h:130
SWC::DB::Cells::Cell::get_value
Types::Encoder get_value(StaticBuffer &v, bool owner) const
Definition: Cell.cc:77
SWC::DB::Cells::Cell::value
uint8_t * value
Definition: Cell.h:362
SWC::DB::Cells::ReqScan::only_keys
bool only_keys
Definition: ReqScan.h:107
SWC::Comm::ConnHandlerPtr
std::shared_ptr< ConnHandler > ConnHandlerPtr
Definition: AppContext.h:17
SWC::Ranger::Callback::RangeQuerySelectUpdating_Insert
Definition: RangeQuerySelectUpdating_Insert.h:17
SWC::DB::Cells::Cell::vlen
uint32_t vlen
Definition: Cell.h:361
SWC::DB::Cells::ReqScan::spec
DB::Specs::Interval spec
Definition: ReqScan.h:106
SWC::Ranger::Callback::RangeQuerySelectUpdating_Insert::RangeQuerySelectUpdating_Insert
SWC_CAN_INLINE RangeQuerySelectUpdating_Insert(const Comm::ConnHandlerPtr &conn, const Comm::Event::Ptr &ev, DB::Specs::Interval &&req_spec, const RangePtr &a_range)
Definition: RangeQuerySelectUpdating_Insert.h:23
SWC::DB::Specs::Interval::updating
IntervalUpdate::Ptr updating
Definition: SpecsInterval.h:249
SWC::DB::Specs::Interval
Definition: SpecsInterval.h:25
SWC::Comm::Event::Ptr
std::shared_ptr< Event > Ptr
Definition: Event.h:33
SWC::Ranger::Callback::RangeQuerySelectUpdating_Insert::Ptr
std::shared_ptr< RangeQuerySelectUpdating_Insert > Ptr
Definition: RangeQuerySelectUpdating_Insert.h:20
SWC::Ranger::Callback::RangeQuerySelectUpdating_Insert::update_cell_value
void update_cell_value(DB::Cells::Cell &cell) override
Definition: RangeQuerySelectUpdating_Insert.h:38
SWC::Ranger::Callback::RangeQuerySelectUpdating
Definition: RangeQuerySelectUpdating.h:16
SWC::Ranger::Callback::RangeQuerySelectUpdating_Insert::~RangeQuerySelectUpdating_Insert
virtual ~RangeQuerySelectUpdating_Insert() noexcept
Definition: RangeQuerySelectUpdating_Insert.h:36