SWC-DB  v0.5.12 C++ documentations
SWC-DB© (Super Wide Column Database) - High Performance Scalable Database (https://github.com/kashirin-alex/swc-db)
RangeBlocks.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_RangeBlocks_h
8 #define swcdb_ranger_db_RangeBlocks_h
9 
10 namespace SWC { namespace Ranger { namespace CommitLog {
11 class Fragments;
13 }}}
14 
16 #ifdef SWC_RANGER_WITH_RANGEDATA
18 #endif
19 
20 namespace SWC { namespace Ranger {
21 
22 
23 class Blocks final {
24  public:
25  typedef Blocks* Ptr;
26 
27  // scan >> blk match >> load-cs + load+logs
28 
32 
33  explicit Blocks(const DB::Types::KeySeq key_seq);
34 
35  Blocks(const Blocks&) = delete;
36 
37  Blocks(const Blocks&&) = delete;
38 
39  Blocks& operator=(const Blocks&) = delete;
40 
41  void init(const RangePtr& for_range);
42 
43  Ptr ptr();
44 
45  ~Blocks() noexcept { }
46 
47  void schema_update();
48 
49  void processing_increment();
50 
51  void processing_decrement();
52 
53  void load(int& err);
54 
55  void unload();
56 
57  void remove(int& err);
58 
59  void expand(DB::Cells::Interval& intval);
60 
62 
63  void apply_new(int &err,
64  CellStore::Writers& w_cellstores,
65  CommitLog::Fragments::Vec& fragments_old);
66 
67  void add_logged(const DB::Cells::Cell& cell);
68 
69  void scan(ReqScan::Ptr req, Block::Ptr blk_ptr = nullptr);
70 
71  bool _split(Block::Ptr blk, bool loaded);
72 
73  size_t cells_count();
74 
75  size_t size() noexcept;
76 
77  size_t size_bytes();
78 
79  size_t size_bytes_total(bool only_loaded=false);
80 
81  size_t release(size_t bytes);
82 
83  size_t release(size_t bytes, uint8_t level);
84 
85  void reset_blocks();
86 
87  bool processing() noexcept;
88 
89  bool wait_processing(int64_t quit_time=0);
90 
91  void print(std::ostream& out, bool minimal);
92 
93  private:
94 
95  size_t SWC_PURE_FUNC _size() const noexcept;
96 
97  size_t _size_bytes();
98 
99  bool _processing() const noexcept;
100 
101  void _clear();
102 
103  void init_blocks(int& err);
104 
105  size_t SWC_PURE_FUNC _get_block_idx(const Block::Ptr blk) const noexcept;
106 
107  size_t _narrow(const DB::Cell::Key& key) const;
108 
109  static const uint8_t MAX_IDX_NARROW = 20;
110 
111  Core::MutexSptd m_mutex;
113  Core::Vector<Block::Ptr> m_blocks_idx;
114  Core::Atomic<size_t> m_processing;
115 
116 
117 };
118 
119 
120 
121 
122 
123 }}
124 
125 
126 
127 #endif // swcdb_ranger_db_RangeBlocks_h
RangeBlockLoader.h
SWC::Ranger::Block
Definition: RangeBlock.h:23
SWC::Ranger::Blocks::expand_and_align
void expand_and_align(DB::Cells::Interval &intval)
Definition: RangeBlocks.cc:89
SWC::Ranger::Blocks::remove
void remove(int &err)
Definition: RangeBlocks.cc:68
SWC::Ranger::CellStore::Readers
Definition: CellStoreReaders.h:15
SWC::Ranger::Blocks::MAX_IDX_NARROW
static const uint8_t MAX_IDX_NARROW
Definition: RangeBlocks.h:109
SWC::Ranger::Blocks::Ptr
Blocks * Ptr
Definition: RangeBlocks.h:25
SWC::DB::Cells::Cell
Definition: Cell.h:92
SWC::Ranger::Blocks::size_bytes_total
size_t size_bytes_total(bool only_loaded=false)
Definition: RangeBlocks.cc:292
SWC::Ranger::Blocks::processing_increment
void processing_increment()
Definition: RangeBlocks.cc:40
SWC::Ranger::Blocks::release
size_t release(size_t bytes)
Definition: RangeBlocks.cc:299
SWC::Ranger::Blocks::m_block
Block::Ptr m_block
Definition: RangeBlocks.h:112
SWC::Ranger::Blocks::commitlog
CommitLog::Fragments commitlog
Definition: RangeBlocks.h:30
SWC::Ranger::Blocks::size_bytes
size_t size_bytes()
Definition: RangeBlocks.cc:287
SWC::Ranger::Blocks::init
void init(const RangePtr &for_range)
Definition: RangeBlocks.cc:20
SWC::Ranger::CommitLog::Fragments
Definition: CommitLog.h:19
SWC::DB::Types::KeySeq
KeySeq
Definition: KeySeq.h:13
SWC::Ranger::Blocks::cells_count
size_t cells_count()
Definition: RangeBlocks.cc:274
SWC::Ranger::Blocks::m_mutex
Core::MutexSptd m_mutex
Definition: RangeBlocks.h:111
SWC::Ranger::RangePtr
std::shared_ptr< Range > RangePtr
Definition: Columns.h:15
SWC::Ranger::Blocks::processing_decrement
void processing_decrement()
Definition: RangeBlocks.cc:45
SWC::Ranger::Blocks::_size_bytes
size_t _size_bytes()
Definition: RangeBlocks.cc:440
SWC::Ranger::Blocks::wait_processing
bool wait_processing(int64_t quit_time=0)
Definition: RangeBlocks.cc:381
RangeData.h
SWC
The SWC-DB C++ namespace 'SWC'.
Definition: main.cc:12
SWC::Ranger::Blocks::_split
bool _split(Block::Ptr blk, bool loaded)
Definition: RangeBlocks.cc:241
SWC::Ranger::Blocks::schema_update
void schema_update()
Definition: RangeBlocks.cc:31
SWC_PURE_FUNC
#define SWC_PURE_FUNC
Definition: Compat.h:108
SWC::Ranger::Blocks::Blocks
Blocks(const DB::Types::KeySeq key_seq)
Definition: RangeBlocks.cc:13
SWC::Ranger::Blocks::Blocks
Blocks(const Blocks &&)=delete
SWC::Ranger::Blocks::reset_blocks
void reset_blocks()
Definition: RangeBlocks.cc:366
SWC::Ranger::Blocks::size
size_t size() noexcept
Definition: RangeBlocks.cc:282
SWC::Ranger::Blocks::operator=
Blocks & operator=(const Blocks &)=delete
SWC::Ranger::Blocks::Blocks
Blocks(const Blocks &)=delete
SWC::Ranger::Blocks::scan
void scan(ReqScan::Ptr req, Block::Ptr blk_ptr=nullptr)
Definition: RangeBlocks.cc:126
SWC::Ranger::Blocks::apply_new
void apply_new(int &err, CellStore::Writers &w_cellstores, CommitLog::Fragments::Vec &fragments_old)
Definition: RangeBlocks.cc:94
SWC::Ranger::Blocks::cellstores
CellStore::Readers cellstores
Definition: RangeBlocks.h:31
SWC::Core::Vector< Write::Ptr >
SWC::Ranger::Blocks::processing
bool processing() noexcept
Definition: RangeBlocks.cc:371
SWC::Ranger::Blocks::unload
void unload()
Definition: RangeBlocks.cc:55
SWC::Ranger::Blocks::m_blocks_idx
Core::Vector< Block::Ptr > m_blocks_idx
Definition: RangeBlocks.h:113
SWC::Ranger::Blocks::expand
void expand(DB::Cells::Interval &intval)
Definition: RangeBlocks.cc:83
SWC::Ranger::Blocks
Definition: RangeBlocks.h:23
SWC::Ranger::Blocks::~Blocks
~Blocks() noexcept
Definition: RangeBlocks.h:45
SWC::Ranger::Blocks::_get_block_idx
size_t SWC_PURE_FUNC _get_block_idx(const Block::Ptr blk) const noexcept
Definition: RangeBlocks.cc:505
SWC::Ranger::Blocks::add_logged
void add_logged(const DB::Cells::Cell &cell)
Definition: RangeBlocks.cc:111
SWC::Ranger::CommitLog::FragmentsPtr
Fragments * FragmentsPtr
Definition: RangeBlocks.h:11
SWC::Ranger::Blocks::print
void print(std::ostream &out, bool minimal)
Definition: RangeBlocks.cc:403
SWC::Ranger::Blocks::range
RangePtr range
Definition: RangeBlocks.h:29
SWC::Ranger::Blocks::_clear
void _clear()
Definition: RangeBlocks.cc:458
SWC::DB::Cells::Interval
Definition: Interval.h:17
SWC::Ranger::Blocks::m_processing
Core::Atomic< size_t > m_processing
Definition: RangeBlocks.h:114
SWC::Ranger::Blocks::_processing
bool _processing() const noexcept
Definition: RangeBlocks.cc:448
SWC::Ranger::Blocks::_narrow
size_t _narrow(const DB::Cell::Key &key) const
Definition: RangeBlocks.cc:513
SWC::Ranger::Blocks::init_blocks
void init_blocks(int &err)
Definition: RangeBlocks.cc:471
SWC::Ranger::ReqScan::Ptr
std::shared_ptr< ReqScan > Ptr
Definition: ReqScan.h:30
SWC::Ranger::Blocks::ptr
Ptr ptr()
Definition: RangeBlocks.cc:27
SWC::Ranger::Blocks::_size
size_t SWC_PURE_FUNC _size() const noexcept
Definition: RangeBlocks.cc:432
SWC::Ranger::Blocks::load
void load(int &err)
Definition: RangeBlocks.cc:50