|
SWC-DB
v0.5.12 C++ documentations
SWC-DB© (Super Wide Column Database) - High Performance Scalable Database (https://github.com/kashirin-alex/swc-db)
|
Go to the documentation of this file.
9 namespace SWC {
namespace Ranger {
14 : range(nullptr), commitlog(key_seq), cellstores(),
16 m_block(nullptr), m_blocks_idx(), m_processing(0) {
103 #ifdef SWC_RANGER_WITH_RANGEDATA
151 for(
Block::Ptr blk =
nullptr; ; blk =
nullptr) {
154 if(req->with_block() && req->block) {
155 (blk = blk_ptr =
static_cast<Block*
>(req->block))
156 ->processing_increment();
157 req->block =
nullptr;
164 blk_ptr = blk_ptr->
next;
170 req->spec.offset_key.empty()
171 ? req->spec.range_begin
172 : req->spec.offset_key
178 while(blk_ptr && !blk_ptr->
is_next(req->spec)) {
180 blk_ptr = blk_ptr->
next;
188 req->profile.add_block_locate(ts);
192 switch(blk->scan(req)) {
194 case Block::ScanState::RESPONDED:
201 n < req->readahead &&
208 if(blk->need_load() && blk->includes(req->spec)) {
209 blk->processing_increment();
213 if(!req->with_block()) {
216 for(
size_t sz; ; need -= sz) {
220 if(!prev || (sz = prev->
release()) > need)
245 bool preload =
false;
249 blk = blk->
_split(loaded);
301 if((released =
release(bytes, 0)) < bytes &&
302 (released +=
release(bytes, 1)) < bytes &&
318 if(!
range->compact_apply())
switch(level) {
331 released += blk->release();
332 if(released >= bytes)
349 released += blk->_releasing_size();
388 " blocks=%d commitlog=%d cellstores=%d",
396 std::this_thread::sleep_for(std::chrono::microseconds(50));
398 std::this_thread::yield();
405 out <<
"Blocks(count=" <<
_size();
409 blk->
print(out <<
" first=");
412 blk->
print(out <<
" last=");
443 sz += blk->size_bytes();
452 if(blk->processing())
461 for(; blk; blk=blk->
next) {
481 for(
auto cs_blk : blocks) {
486 }
else if(blk->
_cond_key_end(cs_blk->header.interval.key_begin)
500 if(
range->_is_any_end())
506 for(
auto it=m_blocks_idx.cbegin(); it != m_blocks_idx.cend();++it)
508 return it - m_blocks_idx.cbegin();
520 if(!(*(
m_blocks_idx.cbegin() + offset))->is_in_end(key)) {
523 offset += step >>= 1;
void save(int &err, CellStore::Readers &cellstores)
static SWC_CAN_INLINE System::Resources & res() noexcept
bool is_next(const DB::Specs::Interval &spec) const
void expand(DB::Cells::Interval &intval) const
static Ptr make(const DB::Cells::Interval &interval, Blocks *blocks, State state=State::NONE)
#define SWC_LOG_OUT(pr, _code_)
SWC_CAN_INLINE int64_t now_ns() noexcept
#define SWC_LOG_PRINTF(fmt,...)
constexpr SWC_CAN_INLINE bool is_data(cid_t cid) noexcept
void expand_and_align(DB::Cells::Interval &intval)
void processing_increment() noexcept
bool add_logged(const DB::Cells::Cell &cell)
static const uint8_t MAX_IDX_NARROW
void init(const RangePtr &for_range)
void print(std::ostream &out, bool minimal)
bool processing() noexcept
SWC_CAN_INLINE void unlock(const bool &support) noexcept
size_t size_bytes_total(bool only_loaded=false)
void processing_increment()
void expand_and_align(DB::Cells::Interval &intval) const
size_t release(size_t bytes)
CommitLog::Fragments commitlog
void expand(DB::Cells::Interval &intval)
void init(const RangePtr &for_range)
size_t size_bytes(bool only_loaded=false) const
constexpr SWC_CAN_INLINE bool empty() const noexcept
std::shared_ptr< Range > RangePtr
void processing_decrement()
Condition::Comp _cond_key_end(const DB::Cell::Key &key) const
bool wait_processing(int64_t quit_time=0)
The SWC-DB C++ namespace 'SWC'.
bool _split(Block::Ptr blk, bool loaded)
void print(std::ostream &out, bool minimal=true) const
size_t size_bytes(bool only_loaded=false)
SWC_CAN_INLINE bool lock() noexcept
size_t release(size_t bytes)
void remove(int &err, Vec &fragments_old)
Blocks(const DB::Types::KeySeq key_seq)
SWC_CAN_INLINE size_t need_ram() const noexcept
void get_blocks(int &err, Read::Blocks &to) const
void scan(ReqScan::Ptr req, Block::Ptr blk_ptr=nullptr)
bool loaded() const noexcept
void replace(int &err, Writers &w_cellstores)
void apply_new(int &err, CellStore::Writers &w_cellstores, CommitLog::Fragments::Vec &fragments_old)
CellStore::Readers cellstores
void print(std::ostream &out)
bool processing() noexcept
void add(const DB::Cells::Cell &cell)
Core::Vector< Block::Ptr > m_blocks_idx
void expand(DB::Cells::Interval &intval)
void expand_and_align(DB::Cells::Interval &intval)
void _set_key_end(const DB::Cell::Key &key)
bool processing() const noexcept
size_t SWC_PURE_FUNC _get_block_idx(const Block::Ptr blk) const noexcept
static SWC_CAN_INLINE size_t scan_reserved_bytes() noexcept
void add_logged(const DB::Cells::Cell &cell)
void print(std::ostream &out, bool minimal)
void init(const RangePtr &for_range)
constexpr SWC_CAN_INLINE T fetch_sub(T v) noexcept
bool is_compacting() const
Core::Atomic< size_t > m_processing
bool _processing() const noexcept
constexpr SWC_CAN_INLINE T fetch_add(T v) noexcept
size_t _narrow(const DB::Cell::Key &key) const
void init_blocks(int &err)
constexpr SWC_CAN_INLINE size_type size() const noexcept
bool try_full_lock(bool &support) noexcept
std::shared_ptr< ReqScan > Ptr
size_t release(size_t bytes)
bool _need_split() const noexcept
size_t SWC_PURE_FUNC _size() const noexcept
void _set_prev_key_end(const DB::Cell::Key &key)