SWC-DB  v0.5.12 C++ documentations
SWC-DB© (Super Wide Column Database) - High Performance Scalable Database (https://github.com/kashirin-alex/swc-db)
RangeBlockLoader.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_BlockLoader_h
8 #define swcdb_ranger_db_BlockLoader_h
9 
10 
14 
15 
16 namespace SWC { namespace Ranger {
17 
18 
20  public:
21 
25 
26  struct ReqQueue {
28  const int64_t ts;
30  ReqQueue(const ReqScan::Ptr& a_req, int64_t a_ts) noexcept
31  : req(a_req), ts(a_ts) { }
33  ReqQueue(ReqQueue&& other) noexcept
34  : req(std::move(other.req)), ts(other.ts) { }
35  ReqQueue(const ReqQueue&) = delete;
36  ReqQueue& operator=(ReqQueue&&) = delete;
37  ReqQueue& operator=(const ReqQueue&) = delete;
38  ~ReqQueue() noexcept { }
39  };
40  std::queue<ReqQueue> q_req; // synced by Block mutex
41  int error;
42  const uint8_t preload;
43 
44  class LoadQueue;
45 
46  explicit BlockLoader(Block::Ptr block);
47 
48  BlockLoader(BlockLoader&&) = delete;
49  BlockLoader(const BlockLoader&) = delete;
51  BlockLoader& operator=(const BlockLoader&) = delete;
52 
53  ~BlockLoader() noexcept { }
54 
55  void add(const ReqScan::Ptr& req);
56 
57  void run();
58 
60 
62 
63  void loaded(CommitLog::Fragment::Ptr&& frag) override;
64 
65  void print(std::ostream& out) {
66  out << "BlockLoader(";
68  out << "blks=" << count_cs_blocks
69  << " frags=" << count_fragments
70  << " error=" << error
71  << " qreq=" << q_req.size()
72  << " m_cs_blks=" << m_cs_blks
73  << " logs=" << int(m_logs)
74  << " queue=" << m_queue.size()
75  << " selected=" << m_f_selected.size()
76  << ')';
77  }
78 
79  private:
80 
81  void load_cells();
82 
83  uint8_t m_logs;
84  size_t m_cs_blks;
85 
86  std::mutex m_mutex;
87  std::condition_variable m_cv;
88  std::queue<LoadQueue*> m_queue;
90  std::queue<CellStore::Block::Read::Ptr> m_cs_selected;
92 
93 };
94 
95 
96 
97 }}
98 
99 #endif // swcdb_ranger_db_BlockLoader_h
SWC::Ranger::BlockLoader::preload
const uint8_t preload
Definition: RangeBlockLoader.h:42
SWC::Ranger::CommitLog::Fragment::Ptr
std::shared_ptr< Fragment > Ptr
Definition: CommitLogFragment.h:31
SWC::Ranger::BlockLoader::ReqQueue::ReqQueue
SWC_CAN_INLINE ReqQueue(ReqQueue &&other) noexcept
Definition: RangeBlockLoader.h:33
SWC::Ranger::BlockLoader::count_fragments
size_t count_fragments
Definition: RangeBlockLoader.h:24
SWC::Ranger::BlockLoader::ReqQueue::ReqQueue
ReqQueue(const ReqQueue &)=delete
SWC::Ranger::Block
Definition: RangeBlock.h:23
SWC::Ranger::BlockLoader::m_f_selected
CommitLog::Fragments::Vec m_f_selected
Definition: RangeBlockLoader.h:89
CommitLog.h
SWC::Core::ScopedLock
Definition: MutexLock.h:41
SWC::Ranger::BlockLoader::BlockLoader
BlockLoader(Block::Ptr block)
Definition: RangeBlockLoader.cc:66
SWC::Ranger::BlockLoader::q_req
std::queue< ReqQueue > q_req
Definition: RangeBlockLoader.h:40
SWC::Ranger::BlockLoader::print
void print(std::ostream &out)
Definition: RangeBlockLoader.h:65
SWC::Ranger::BlockLoader::add
void add(const ReqScan::Ptr &req)
Definition: RangeBlockLoader.cc:78
SWC::Ranger::BlockLoader::loaded
void loaded(CellStore::Block::Read::Ptr &&blk)
Definition: RangeBlockLoader.cc:114
SWC::Ranger::BlockLoader::ReqQueue::ReqQueue
SWC_CAN_INLINE ReqQueue(const ReqScan::Ptr &a_req, int64_t a_ts) noexcept
Definition: RangeBlockLoader.h:30
SWC::Ranger::BlockLoader::BlockLoader
BlockLoader(BlockLoader &&)=delete
SWC::Ranger::BlockLoader::ReqQueue::ts
const int64_t ts
Definition: RangeBlockLoader.h:28
SWC::Ranger::BlockLoader::m_cv
std::condition_variable m_cv
Definition: RangeBlockLoader.h:87
SWC::Ranger::BlockLoader::m_cs_blks
size_t m_cs_blks
Definition: RangeBlockLoader.h:84
SWC::Ranger::BlockLoader::ReqQueue::~ReqQueue
~ReqQueue() noexcept
Definition: RangeBlockLoader.h:38
SWC_CAN_INLINE
#define SWC_CAN_INLINE
Definition: Compat.h:102
SWC::Ranger::BlockLoader::error
int error
Definition: RangeBlockLoader.h:41
SWC::Ranger::BlockLoader::load_cells
void load_cells()
Definition: RangeBlockLoader.cc:175
SWC
The SWC-DB C++ namespace 'SWC'.
Definition: main.cc:12
SWC::Ranger::BlockLoader::operator=
BlockLoader & operator=(BlockLoader &&)=delete
CellStoreReaders.h
SWC::Ranger::BlockLoader
Definition: RangeBlockLoader.h:19
SWC::Ranger::CellStore::Block::Read
Definition: CellStoreBlock.h:28
SWC::Ranger::BlockLoader::m_logs
uint8_t m_logs
Definition: RangeBlockLoader.h:83
SWC::Ranger::BlockLoader::block
Block::Ptr block
Definition: RangeBlockLoader.h:22
SWC::Ranger::BlockLoader::ReqQueue::operator=
ReqQueue & operator=(ReqQueue &&)=delete
SWC::Ranger::BlockLoader::LoadQueue
Definition: RangeBlockLoader.cc:12
SWC::Core::Vector< Fragment::Ptr >
SWC::Ranger::BlockLoader::ReqQueue
Definition: RangeBlockLoader.h:26
SWC::Ranger::BlockLoader::m_mutex
std::mutex m_mutex
Definition: RangeBlockLoader.h:86
SWC::Ranger::BlockLoader::count_cs_blocks
size_t count_cs_blocks
Definition: RangeBlockLoader.h:23
SWC::Ranger::BlockLoader::m_queue
std::queue< LoadQueue * > m_queue
Definition: RangeBlockLoader.h:88
SWC::Ranger::BlockLoader::~BlockLoader
~BlockLoader() noexcept
Definition: RangeBlockLoader.h:53
SWC::Ranger::BlockLoader::ReqQueue::req
ReqScan::Ptr req
Definition: RangeBlockLoader.h:27
SWC::Ranger::BlockLoader::m_cs_ready
Core::Vector< CellStore::Block::Read::Ptr > m_cs_ready
Definition: RangeBlockLoader.h:91
SWC::Ranger::BlockLoader::ReqQueue::operator=
ReqQueue & operator=(const ReqQueue &)=delete
SWC::Ranger::BlockLoader::run
void run()
Definition: RangeBlockLoader.cc:83
SWC::Core::Vector::size
constexpr SWC_CAN_INLINE size_type size() const noexcept
Definition: Vector.h:189
SWC::Ranger::BlockLoader::m_cs_selected
std::queue< CellStore::Block::Read::Ptr > m_cs_selected
Definition: RangeBlockLoader.h:90
SWC::Ranger::ReqScan::Ptr
std::shared_ptr< ReqScan > Ptr
Definition: ReqScan.h:30
SWC::Ranger::BlockLoader::BlockLoader
BlockLoader(const BlockLoader &)=delete
SWC::Ranger::BlockLoader::operator=
BlockLoader & operator=(const BlockLoader &)=delete
RangeBlock.h
SWC::Ranger::CommitLog::Fragment::LoadCallback
Definition: CommitLogFragment.h:32