SWC-DB  v0.5.12 C++ documentations
SWC-DB© (Super Wide Column Database) - High Performance Scalable Database (https://github.com/kashirin-alex/swc-db)
CellStoreReaders.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_db_CellStoreReaders_h
8 #define swcdb_ranger_db_CellStoreReaders_h
9 
11 
12 
13 namespace SWC { namespace Ranger { namespace CellStore {
14 
15 class Readers final : private Core::Vector<Read::Ptr> {
16  public:
17 
19  typedef Readers* Ptr;
20 
21  using Vec::empty;
22  using Vec::size;
23  using Vec::begin;
24  using Vec::end;
25  using Vec::cbegin;
26  using Vec::cend;
27  using Vec::front;
28  using Vec::back;
29  using Vec::erase;
30  using Vec::reserve;
31 
33 
34  explicit Readers() noexcept: range(nullptr) { }
35 
36  Readers(const Readers&) = delete;
37 
38  Readers(const Readers&&) = delete;
39 
40  Readers& operator=(const Readers&) = delete;
41 
42  void init(const RangePtr& for_range) {
43  range = for_range;
44  }
45 
46  ~Readers() noexcept { }
47 
48  void add(Read::Ptr cs) {
49  push_back(cs);
50  }
51 
52  void load(int& err);
53 
54  void expand(DB::Cells::Interval& intval) const;
55 
56  void expand_and_align(DB::Cells::Interval& intval) const;
57 
58  size_t size_bytes(bool only_loaded=false) const;
59 
60  uint32_t get_cell_revs() const;
61 
62  int64_t SWC_PURE_FUNC get_ts_earliest() const;
63 
64  size_t blocks_count() const;
65 
66  size_t release(size_t bytes);
67 
68  bool processing() const noexcept;
69 
70  void remove(int &err);
71 
72  void unload();
73 
74  void clear();
75 
76  void load_cells(BlockLoader* loader);
77 
78  void get_blocks(int& err, Read::Blocks& to) const;
79 
80  void get_prev_key_end(uint32_t idx, DB::Cell::Key& key) const;
81 
82  void get_key_end(DB::Cell::Key& key) const;
83 
84  bool SWC_PURE_FUNC need_compaction(size_t cs_max, size_t cs_sz,
85  size_t blk_size) const;
86 
87  uint32_t SWC_PURE_FUNC encoded_length() const;
88 
89  void encode(uint8_t** ptr) const;
90 
91  void decode(int &err, const uint8_t** ptr, size_t* remain);
92 
93  void load_from_path(int &err);
94 
95  void replace(int &err, Writers& w_cellstores);
96 
97  void move_from(int &err, Readers::Vec& mv_css);
98 
99  void print(std::ostream& out, bool minimal=true) const;
100 
101  private:
102 
103  void _free();
104 
105  void _close();
106 
107 };
108 
109 
110 }}} // namespace SWC::Ranger::CellStore
111 
112 #endif // swcdb_ranger_db_CellStoreReaders_h
SWC::Core::Vector< Read::Ptr >::erase
SWC_CAN_INLINE iterator erase(size_type offset) noexcept(_NoExceptMoveAssign &&_NoExceptDestructor)
Definition: Vector.h:464
SWC::Ranger::CellStore::Readers::encoded_length
uint32_t SWC_PURE_FUNC encoded_length() const
Definition: CellStoreReaders.cc:152
SWC::Core::Vector< Read::Ptr >::front
constexpr SWC_CAN_INLINE reference front() noexcept
Definition: Vector.h:243
SWC::Ranger::CellStore::Readers::expand
void expand(DB::Cells::Interval &intval) const
Definition: CellStoreReaders.cc:21
SWC::Ranger::CellStore::Readers
Definition: CellStoreReaders.h:15
SWC::Ranger::CellStore::Readers::get_ts_earliest
int64_t SWC_PURE_FUNC get_ts_earliest() const
Definition: CellStoreReaders.cc:45
SWC::Ranger::CellStore::Readers::init
void init(const RangePtr &for_range)
Definition: CellStoreReaders.h:42
SWC::Ranger::CellStore::Readers::~Readers
~Readers() noexcept
Definition: CellStoreReaders.h:46
SWC::Ranger::CellStore::Readers::Vec
Core::Vector< Read::Ptr > Vec
Definition: CellStoreReaders.h:18
SWC::Ranger::CellStore::Readers::expand_and_align
void expand_and_align(DB::Cells::Interval &intval) const
Definition: CellStoreReaders.cc:26
SWC::Ranger::CellStore::Readers::add
void add(Read::Ptr cs)
Definition: CellStoreReaders.h:48
SWC::Ranger::CellStore::Readers::need_compaction
bool SWC_PURE_FUNC need_compaction(size_t cs_max, size_t cs_sz, size_t blk_size) const
Definition: CellStoreReaders.cc:131
SWC::Ranger::CellStore::Readers::remove
void remove(int &err)
Definition: CellStoreReaders.cc:80
SWC::Ranger::CellStore::Readers::size_bytes
size_t size_bytes(bool only_loaded=false) const
Definition: CellStoreReaders.cc:33
SWC::Core::Vector< Read::Ptr >::empty
constexpr SWC_CAN_INLINE bool empty() const noexcept
Definition: Vector.h:168
SWC::Ranger::RangePtr
std::shared_ptr< Range > RangePtr
Definition: Columns.h:15
SWC::Core::Vector< Read::Ptr >::back
constexpr SWC_CAN_INLINE reference back() noexcept
Definition: Vector.h:254
SWC::Core::Vector< Read::Ptr >::end
constexpr SWC_CAN_INLINE iterator end() noexcept
Definition: Vector.h:227
SWC::Ranger::CellStore::Readers::load
void load(int &err)
Definition: CellStoreReaders.cc:14
SWC::Ranger::CellStore::Readers::operator=
Readers & operator=(const Readers &)=delete
SWC
The SWC-DB C++ namespace 'SWC'.
Definition: main.cc:12
SWC::Ranger::CellStore::Readers::Readers
Readers() noexcept
Definition: CellStoreReaders.h:34
SWC::Ranger::CellStore::Readers::print
void print(std::ostream &out, bool minimal=true) const
Definition: CellStoreReaders.cc:312
SWC::Ranger::CellStore::Readers::release
size_t release(size_t bytes)
Definition: CellStoreReaders.cc:63
SWC::Ranger::CellStore::Readers::load_from_path
void load_from_path(int &err)
Definition: CellStoreReaders.cc:180
SWC_PURE_FUNC
#define SWC_PURE_FUNC
Definition: Compat.h:108
SWC::Ranger::CellStore::Readers::range
RangePtr range
Definition: CellStoreReaders.h:32
SWC::Ranger::CellStore::Read
Definition: CellStore.h:41
SWC::Ranger::CellStore::Readers::unload
void unload()
Definition: CellStoreReaders.cc:88
SWC::Ranger::CellStore::Readers::move_from
void move_from(int &err, Readers::Vec &mv_css)
Definition: CellStoreReaders.cc:267
SWC::Ranger::BlockLoader
Definition: RangeBlockLoader.h:19
SWC::Ranger::CellStore::Readers::get_blocks
void get_blocks(int &err, Read::Blocks &to) const
Definition: CellStoreReaders.cc:112
SWC::Ranger::CellStore::Readers::decode
void decode(int &err, const uint8_t **ptr, size_t *remain)
Definition: CellStoreReaders.cc:167
SWC::Ranger::CellStore::Readers::Readers
Readers(const Readers &)=delete
SWC::Ranger::CellStore::Readers::replace
void replace(int &err, Writers &w_cellstores)
Definition: CellStoreReaders.cc:224
CellStore.h
SWC::Core::Vector
Definition: Vector.h:14
SWC::Ranger::CellStore::Readers::get_key_end
void get_key_end(DB::Cell::Key &key) const
Definition: CellStoreReaders.cc:127
SWC::Core::Vector< Read::Ptr >::reserve
SWC_CAN_INLINE void reserve()
Definition: Vector.h:294
SWC::Core::Vector< Read::Ptr >::cend
constexpr SWC_CAN_INLINE const_iterator cend() const noexcept
Definition: Vector.h:232
SWC::Ranger::Blocks
Definition: RangeBlocks.h:23
SWC::Ranger::CellStore::Readers::encode
void encode(uint8_t **ptr) const
Definition: CellStoreReaders.cc:160
SWC::Ranger::CellStore::Readers::processing
bool processing() const noexcept
Definition: CellStoreReaders.cc:73
SWC::Ranger::CellStore::Readers::get_cell_revs
uint32_t get_cell_revs() const
Definition: CellStoreReaders.cc:41
SWC::Ranger::CellStore::Readers::load_cells
void load_cells(BlockLoader *loader)
Definition: CellStoreReaders.cc:100
SWC::DB::Cells::Interval
Definition: Interval.h:17
SWC::Core::Vector< Read::Ptr >::push_back
SWC_CAN_INLINE void push_back(ArgsT &&... args)
Definition: Vector.h:331
SWC::Core::Vector< Read::Ptr >::cbegin
constexpr SWC_CAN_INLINE const_iterator cbegin() const noexcept
Definition: Vector.h:216
SWC::Ranger::CellStore::Readers::blocks_count
size_t blocks_count() const
Definition: CellStoreReaders.cc:55
SWC::Ranger::CellStore::Readers::_free
void _free()
Definition: CellStoreReaders.cc:325
SWC::Core::Vector< Read::Ptr >::size
constexpr SWC_CAN_INLINE size_type size() const noexcept
Definition: Vector.h:189
SWC::Ranger::CellStore::Readers::Ptr
Readers * Ptr
Definition: CellStoreReaders.h:19
SWC::Ranger::CellStore::Readers::clear
void clear()
Definition: CellStoreReaders.cc:94
SWC::Ranger::CellStore::Readers::Readers
Readers(const Readers &&)=delete
SWC::Ranger::CellStore::Readers::get_prev_key_end
void get_prev_key_end(uint32_t idx, DB::Cell::Key &key) const
Definition: CellStoreReaders.cc:122
SWC::Core::Vector< Read::Ptr >::begin
constexpr SWC_CAN_INLINE iterator begin() noexcept
Definition: Vector.h:211
SWC::Ranger::CellStore::Readers::_close
void _close()
Definition: CellStoreReaders.cc:333