#include <swcdb/ranger/db/RangeBlock.h>
Public Types | |
enum | State : uint8_t { NONE = 0x00, LOADING = 0x01, LOADED = 0x02 } |
enum | ScanState : uint8_t { UKNOWN = 0x00, QUEUED = 0x01, RESPONDED = 0x02, SYNCED = 0x03 } |
typedef Block * | Ptr |
Public Member Functions | |
Block (const DB::Cells::Interval &interval, Blocks *blocks, State state=State::NONE) | |
Block (const Block &)=delete | |
Block (const Block &&)=delete | |
Block & | operator= (const Block &)=delete |
~Block () noexcept | |
size_t | _releasing_size () const noexcept |
Ptr | ptr () |
void | schema_update () noexcept |
void | _set_prev_key_end (const DB::Cell::Key &key) |
void | _set_prev_key_end (const Ptr blk) |
Condition::Comp | _cond_key_end (const DB::Cell::Key &key) const |
void | _set_key_end (const DB::Cell::Key &key) |
void | _free_key_end () |
bool | is_consist (const DB::Cells::Interval &intval) const |
bool | is_in_end (const DB::Cell::Key &key) const |
bool | _is_in_end (const DB::Cell::Key &key) const |
bool | is_next (const DB::Specs::Interval &spec) const |
bool | includes (const DB::Specs::Interval &spec) const |
bool | _includes_begin (const DB::Specs::Interval &spec) const |
bool | includes_end (const DB::Specs::Interval &spec) const |
void | preload () |
bool | add_logged (const DB::Cells::Cell &cell) |
void | load_final (const DB::Cells::MutableVec &cells) |
size_t | load_cells (const uint8_t *buf, size_t remain, uint32_t revs, size_t avail, bool &was_splitted, bool synced=false) |
bool | splitter (bool loaded) |
ScanState | scan (const ReqScan::Ptr &req) |
void | loader_loaded () |
Ptr | split (bool loaded) |
Ptr | _split (bool loaded) |
void | _add (Ptr blk) |
size_t | release () |
void | processing_increment () noexcept |
void | processing_decrement () noexcept |
bool | loaded () const noexcept |
bool | need_load () const noexcept |
bool | processing () noexcept |
size_t | size () |
size_t | _size () const noexcept |
size_t | size_bytes () |
size_t | size_of_internal () |
bool | _need_split () const noexcept |
void | print (std::ostream &out) |
Static Public Member Functions | |
static Ptr | make (const DB::Cells::Interval &interval, Blocks *blocks, State state=State::NONE) |
Public Attributes | |
Blocks * | blocks |
Block::Ptr | next |
Block::Ptr | prev |
Private Member Functions | |
ScanState | _scan (const ReqScan::Ptr &req, bool synced=false) |
Private Attributes | |
std::shared_mutex | m_mutex |
DB::Cells::Mutable | m_cells |
Core::Atomic< size_t > | m_releasable_bytes |
Core::MutexAtomic | m_mutex_intval |
uint32_t | m_split_rev |
DB::Cell::Key | m_prev_key_end |
DB::Cell::Key | m_key_end |
Core::MutexSptd | m_mutex_state |
Core::Atomic< size_t > | m_processing |
Core::Atomic< State > | m_state |
BlockLoader * | m_loader |
Definition at line 23 of file RangeBlock.h.
typedef Block* SWC::Ranger::Block::Ptr |
Definition at line 26 of file RangeBlock.h.
enum SWC::Ranger::Block::ScanState : uint8_t |
Enumerator | |
---|---|
UKNOWN | |
QUEUED | |
RESPONDED | |
SYNCED |
Definition at line 34 of file RangeBlock.h.
enum SWC::Ranger::Block::State : uint8_t |
Enumerator | |
---|---|
NONE | |
LOADING | |
LOADED |
Definition at line 28 of file RangeBlock.h.
|
explicit |
Definition at line 22 of file RangeBlock.cc.
References blocks, SWC::DB::Types::SystemColumn::is_data(), SWC::System::Resources::more_mem_releasable(), SWC::Ranger::Blocks::range, and SWC::Env::Rgr::res().
Referenced by make().
|
delete |
|
delete |
|
noexcept |
Definition at line 44 of file RangeBlock.cc.
References blocks, SWC::DB::Types::SystemColumn::is_data(), SWC::System::Resources::less_mem_releasable(), m_releasable_bytes, SWC::Ranger::Blocks::range, and SWC::Env::Rgr::res().
SWC_CAN_INLINE void SWC::Ranger::Block::_add | ( | Block::Ptr | blk | ) |
Definition at line 392 of file RangeBlock.cc.
References next, prev, and ptr().
Referenced by _split(), and SWC::Ranger::Blocks::init_blocks().
SWC_CAN_INLINE Condition::Comp SWC::Ranger::Block::_cond_key_end | ( | const DB::Cell::Key & | key | ) | const |
Definition at line 81 of file RangeBlock.cc.
References SWC::DB::KeySeq::compare(), SWC::DB::Cells::Mutable::key_seq, m_cells, and m_key_end.
Referenced by SWC::Ranger::Blocks::init_blocks().
SWC_CAN_INLINE void SWC::Ranger::Block::_free_key_end | ( | ) |
Definition at line 91 of file RangeBlock.cc.
References SWC::DB::Cell::Key::free(), and m_key_end.
Referenced by SWC::Ranger::Blocks::init_blocks().
SWC_CAN_INLINE bool SWC::Ranger::Block::_includes_begin | ( | const DB::Specs::Interval & | spec | ) | const |
Definition at line 138 of file RangeBlock.cc.
References SWC::DB::Cell::Key::empty(), SWC::DB::Specs::Interval::is_matching_begin(), SWC::DB::Cells::Mutable::key_seq, m_cells, and m_key_end.
Referenced by includes(), and is_next().
SWC_CAN_INLINE bool SWC::Ranger::Block::_is_in_end | ( | const DB::Cell::Key & | key | ) | const |
Definition at line 112 of file RangeBlock.cc.
References SWC::DB::KeySeq::compare(), SWC::DB::Cell::Key::empty(), SWC::Condition::GT, SWC::DB::Cells::Mutable::key_seq, m_cells, and m_key_end.
Referenced by add_logged(), is_in_end(), and is_next().
|
noexcept |
Definition at line 486 of file RangeBlock.cc.
References _size(), blocks, SWC::DB::Cells::Mutable::has_one_key(), m_cells, SWC::Ranger::Blocks::range, and SWC::DB::Cells::Mutable::size_bytes().
Referenced by SWC::Ranger::Blocks::_split(), and splitter().
|
noexcept |
Definition at line 51 of file RangeBlock.cc.
References m_key_end, m_prev_key_end, and SWC::DB::Cell::Key::size.
|
private |
Definition at line 513 of file RangeBlock.cc.
References blocks, SWC::Error::Exception::code(), SWC::LOG_ERROR, m_cells, m_mutex, SWC::Time::now_ns(), SWC::Error::OK, SWC::Ranger::Blocks::processing_decrement(), processing_decrement(), ptr(), release(), SWC::DB::Cells::Mutable::scan(), SWC::Ranger::Blocks::scan(), SWC_CURRENT_EXCEPTION, SWC_LOG_OSTREAM, and SWC_LOG_OUT.
Referenced by loader_loaded(), and scan().
SWC_CAN_INLINE void SWC::Ranger::Block::_set_key_end | ( | const DB::Cell::Key & | key | ) |
Definition at line 86 of file RangeBlock.cc.
References SWC::DB::Cell::Key::copy(), and m_key_end.
Referenced by SWC::Ranger::Blocks::init_blocks().
SWC_CAN_INLINE void SWC::Ranger::Block::_set_prev_key_end | ( | const DB::Cell::Key & | key | ) |
Definition at line 71 of file RangeBlock.cc.
References SWC::DB::Cell::Key::copy(), and m_prev_key_end.
Referenced by SWC::Ranger::Blocks::init_blocks().
SWC_CAN_INLINE void SWC::Ranger::Block::_set_prev_key_end | ( | const Ptr | blk | ) |
Definition at line 76 of file RangeBlock.cc.
References SWC::DB::Cell::Key::copy(), m_key_end, and m_prev_key_end.
|
noexcept |
Definition at line 469 of file RangeBlock.cc.
References m_cells, and SWC::DB::Cells::Mutable::size().
Referenced by _need_split(), and size().
Block::Ptr SWC::Ranger::Block::_split | ( | bool | loaded | ) |
Definition at line 357 of file RangeBlock.cc.
References _add(), SWC::System::Resources::adj_mem_releasable(), SWC::DB::Cells::Mutable::back(), blocks, SWC::DB::Cell::Key::copy(), SWC::Core::AtomicBase< T, OrderT >::exchange(), SWC::DB::Types::SystemColumn::is_data(), SWC::DB::Cells::Cell::key, SWC::DB::Cells::Mutable::key_seq, loaded(), m_cells, m_key_end, m_mutex_intval, m_prev_key_end, m_releasable_bytes, m_split_rev, make(), SWC::DB::Cell::Key::move(), SWC::Condition::NONE, SWC::Ranger::Blocks::range, SWC::Env::Rgr::res(), SWC::DB::Cells::Mutable::size_of_internal(), SWC::DB::Cells::Mutable::split(), and SWC::Core::AtomicBase< T, OrderT >::store().
Referenced by SWC::Ranger::Blocks::_split(), and split().
SWC_CAN_INLINE bool SWC::Ranger::Block::add_logged | ( | const DB::Cells::Cell & | cell | ) |
Definition at line 168 of file RangeBlock.cc.
References _is_in_end(), SWC::DB::Cells::Mutable::add_raw(), SWC::DB::Cells::Cell::key, loaded(), m_cells, m_mutex, m_mutex_intval, m_split_rev, and splitter().
Referenced by SWC::Ranger::Blocks::add_logged().
SWC_CAN_INLINE bool SWC::Ranger::Block::includes | ( | const DB::Specs::Interval & | spec | ) | const |
Definition at line 129 of file RangeBlock.cc.
References _includes_begin(), includes_end(), and m_mutex_intval.
SWC_CAN_INLINE bool SWC::Ranger::Block::includes_end | ( | const DB::Specs::Interval & | spec | ) | const |
Definition at line 144 of file RangeBlock.cc.
References SWC::DB::Cell::Key::empty(), SWC::DB::Specs::Interval::is_in_previous(), SWC::DB::Cells::Mutable::key_seq, m_cells, and m_prev_key_end.
Referenced by includes(), and is_next().
SWC_CAN_INLINE bool SWC::Ranger::Block::is_consist | ( | const DB::Cells::Interval & | intval | ) | const |
Definition at line 96 of file RangeBlock.cc.
References SWC::DB::KeySeq::compare(), SWC::DB::Cell::Key::empty(), SWC::Condition::GT, is_in_end(), SWC::DB::Cells::Interval::key_begin, SWC::DB::Cells::Interval::key_end, SWC::DB::Cells::Mutable::key_seq, m_cells, and m_prev_key_end.
Referenced by SWC::Ranger::CommitLog::Fragments::_load_cells(), SWC::Ranger::CellStore::Read::load_cells(), and SWC::Ranger::CellStore::Readers::load_cells().
SWC_CAN_INLINE bool SWC::Ranger::Block::is_in_end | ( | const DB::Cell::Key & | key | ) | const |
Definition at line 106 of file RangeBlock.cc.
References _is_in_end(), and m_mutex_intval.
Referenced by is_consist(), SWC::Ranger::CellStore::Read::load_cells(), and SWC::Ranger::CellStore::Readers::load_cells().
SWC_CAN_INLINE bool SWC::Ranger::Block::is_next | ( | const DB::Specs::Interval & | spec | ) | const |
Definition at line 119 of file RangeBlock.cc.
References _includes_begin(), _is_in_end(), SWC::DB::Cell::Key::empty(), includes_end(), m_mutex_intval, and SWC::DB::Specs::Interval::offset_key.
Referenced by SWC::Ranger::Blocks::scan().
SWC_SHOULD_NOT_INLINE size_t SWC::Ranger::Block::load_cells | ( | const uint8_t * | buf, |
size_t | remain, | ||
uint32_t | revs, | ||
size_t | avail, | ||
bool & | was_splitted, | ||
bool | synced = false |
||
) |
Definition at line 209 of file RangeBlock.cc.
References SWC::DB::Cells::Mutable::add_raw(), SWC::DB::Cells::Mutable::add_sorted(), SWC::System::Resources::adj_mem_releasable(), blocks, SWC::DB::KeySeq::compare(), SWC::DB::Cell::Key::empty(), SWC::DB::Cells::Mutable::empty(), SWC::Core::AtomicBase< T, OrderT >::exchange(), SWC::Condition::GT, SWC::DB::Types::SystemColumn::is_data(), SWC::DB::Cells::Mutable::key_seq, SWC::LOG_ERROR, m_cells, m_key_end, m_mutex, m_prev_key_end, m_releasable_bytes, SWC::Error::Exception::print(), SWC::DB::Cell::Key::print(), SWC::Ranger::Blocks::range, SWC::Env::Rgr::res(), SWC::DB::Cells::Mutable::size_of_internal(), splitter(), SWC_CURRENT_EXCEPTION, SWC_LOG_OSTREAM, SWC_LOG_OUT, and SWC::DB::Cells::Mutable::ttl.
Referenced by SWC::Ranger::CellStore::Block::Read::load_cells(), and SWC::Ranger::CommitLog::Fragment::load_cells().
SWC_CAN_INLINE void SWC::Ranger::Block::load_final | ( | const DB::Cells::MutableVec & | cells | ) |
Definition at line 190 of file RangeBlock.cc.
References SWC::System::Resources::adj_mem_releasable(), blocks, SWC::Core::AtomicBase< T, OrderT >::exchange(), SWC::DB::Cells::Mutable::finalize_raw(), SWC::DB::Types::SystemColumn::is_data(), m_cells, m_key_end, m_mutex, m_mutex_state, m_prev_key_end, m_releasable_bytes, m_state, SWC::Ranger::Blocks::range, SWC::Env::Rgr::res(), SWC::DB::Cells::Mutable::size_of_internal(), splitter(), and SWC::Core::AtomicBase< T, OrderT >::store().
Referenced by SWC::Ranger::CommitLog::Fragments::load_cells().
|
noexcept |
Definition at line 432 of file RangeBlock.cc.
References m_state.
Referenced by SWC::Ranger::Blocks::_split(), _split(), add_logged(), release(), schema_update(), split(), and splitter().
void SWC::Ranger::Block::loader_loaded | ( | ) |
Definition at line 304 of file RangeBlock.cc.
References _scan(), blocks, SWC::Ranger::BlockLoader::count_cs_blocks, SWC::Ranger::BlockLoader::count_fragments, SWC::Ranger::BlockLoader::error, m_loader, m_mutex_state, operator=(), SWC::Env::Rgr::post(), SWC::Ranger::Blocks::processing_decrement(), processing_decrement(), SWC::Ranger::BlockLoader::q_req, and SWC_CAN_INLINE.
Referenced by SWC::Ranger::BlockLoader::load_cells().
|
static |
Definition at line 16 of file RangeBlock.cc.
References Block(), and blocks.
Referenced by _split(), and SWC::Ranger::Blocks::init_blocks().
|
noexcept |
Definition at line 437 of file RangeBlock.cc.
References m_state, and SWC::Condition::NONE.
SWC_CAN_INLINE void SWC::Ranger::Block::preload | ( | ) |
Definition at line 150 of file RangeBlock.cc.
References blocks, SWC::System::Resources::less_mem_future(), SWC::System::Resources::more_mem_future(), SWC::Env::Rgr::post(), SWC::Ranger::Blocks::range, SWC::Env::Rgr::res(), scan(), and SWC_CAN_INLINE.
Referenced by SWC::Ranger::Blocks::_split().
void SWC::Ranger::Block::print | ( | std::ostream & | out | ) |
Definition at line 494 of file RangeBlock.cc.
References SWC::DB::Cells::Mutable::key_seq, SWC::Core::AtomicBase< T, OrderT >::load(), m_cells, m_key_end, m_mutex, m_mutex_intval, m_prev_key_end, m_processing, m_state, SWC::DB::Cells::Mutable::print(), and SWC::DB::Types::to_string().
Referenced by SWC::Ranger::Blocks::print().
|
noexcept |
Definition at line 442 of file RangeBlock.cc.
References SWC::DB::Types::MngrColumn::LOADING, m_loader, m_mutex, m_mutex_state, m_processing, m_state, SWC::Core::MutexSptd::try_full_lock(), and SWC::Core::MutexSptd::unlock().
|
noexcept |
Definition at line 427 of file RangeBlock.cc.
References SWC::Core::Atomic< T, OrderT >::fetch_sub(), and m_processing.
Referenced by _scan(), loader_loaded(), and scan().
|
noexcept |
Definition at line 422 of file RangeBlock.cc.
References SWC::Core::Atomic< T, OrderT >::fetch_add(), and m_processing.
Referenced by SWC::Ranger::Blocks::_split().
SWC_CAN_INLINE Block::Ptr SWC::Ranger::Block::ptr | ( | ) |
Definition at line 56 of file RangeBlock.cc.
Referenced by _add(), _scan(), scan(), and splitter().
size_t SWC::Ranger::Block::release | ( | ) |
Definition at line 401 of file RangeBlock.cc.
References blocks, SWC::Core::AtomicBase< T, OrderT >::compare_exchange_weak(), SWC::Core::AtomicBase< T, OrderT >::exchange(), SWC::DB::Cells::Mutable::free(), SWC::DB::Types::SystemColumn::is_data(), SWC::System::Resources::less_mem_releasable(), loaded(), m_cells, m_loader, m_mutex, m_mutex_state, m_processing, m_releasable_bytes, m_state, SWC::Condition::NONE, SWC::Ranger::Blocks::range, SWC::Env::Rgr::res(), SWC::Core::MutexSptd::try_full_lock(), and SWC::Core::MutexSptd::unlock().
Referenced by _scan(), and SWC::Ranger::Blocks::scan().
Block::ScanState SWC::Ranger::Block::scan | ( | const ReqScan::Ptr & | req | ) |
Definition at line 271 of file RangeBlock.cc.
References _scan(), SWC::Ranger::BlockLoader::add(), SWC::Core::AtomicBase< T, OrderT >::compare_exchange_weak(), SWC::DB::Types::MngrColumn::LOADING, m_loader, m_mutex_state, m_state, SWC::Condition::NONE, processing_decrement(), ptr(), SWC::DB::Types::MngrRange::QUEUED, and SWC::Ranger::BlockLoader::run().
Referenced by preload().
|
noexcept |
Definition at line 60 of file RangeBlock.cc.
References blocks, SWC::DB::Cells::Mutable::configure(), loaded(), m_cells, m_mutex, and SWC::Ranger::Blocks::range.
SWC_CAN_INLINE size_t SWC::Ranger::Block::size | ( | ) |
Definition at line 463 of file RangeBlock.cc.
References _size(), and m_mutex.
SWC_CAN_INLINE size_t SWC::Ranger::Block::size_bytes | ( | ) |
Definition at line 474 of file RangeBlock.cc.
References m_cells, m_mutex, and SWC::DB::Cells::Mutable::size_bytes().
SWC_CAN_INLINE size_t SWC::Ranger::Block::size_of_internal | ( | ) |
Definition at line 480 of file RangeBlock.cc.
References m_cells, m_mutex, and SWC::DB::Cells::Mutable::size_of_internal().
Block::Ptr SWC::Ranger::Block::split | ( | bool | loaded | ) |
Definition at line 348 of file RangeBlock.cc.
References _split(), loaded(), and m_mutex.
SWC_CAN_INLINE bool SWC::Ranger::Block::splitter | ( | bool | loaded | ) |
Definition at line 267 of file RangeBlock.cc.
References _need_split(), SWC::Ranger::Blocks::_split(), blocks, loaded(), and ptr().
Referenced by add_logged(), load_cells(), and load_final().
Blocks* SWC::Ranger::Block::blocks |
Definition at line 41 of file RangeBlock.h.
Referenced by _need_split(), _scan(), _split(), Block(), SWC::Ranger::BlockLoader::load_cells(), load_cells(), load_final(), loader_loaded(), make(), preload(), release(), SWC::Ranger::BlockLoader::run(), schema_update(), splitter(), and ~Block().
|
private |
Definition at line 143 of file RangeBlock.h.
Referenced by _cond_key_end(), _includes_begin(), _is_in_end(), _need_split(), _scan(), _size(), _split(), add_logged(), includes_end(), is_consist(), load_cells(), load_final(), print(), release(), schema_update(), size_bytes(), and size_of_internal().
|
private |
Definition at line 149 of file RangeBlock.h.
Referenced by _cond_key_end(), _free_key_end(), _includes_begin(), _is_in_end(), _releasing_size(), _set_key_end(), _set_prev_key_end(), _split(), load_cells(), load_final(), and print().
|
private |
Definition at line 154 of file RangeBlock.h.
Referenced by loader_loaded(), processing(), release(), and scan().
|
private |
Definition at line 142 of file RangeBlock.h.
Referenced by _scan(), add_logged(), load_cells(), load_final(), print(), processing(), release(), schema_update(), size(), size_bytes(), size_of_internal(), and split().
|
mutableprivate |
Definition at line 146 of file RangeBlock.h.
Referenced by _split(), add_logged(), includes(), is_in_end(), is_next(), and print().
|
private |
Definition at line 151 of file RangeBlock.h.
Referenced by load_final(), loader_loaded(), processing(), release(), and scan().
|
private |
Definition at line 148 of file RangeBlock.h.
Referenced by _releasing_size(), _set_prev_key_end(), _split(), includes_end(), is_consist(), load_cells(), load_final(), and print().
|
private |
Definition at line 152 of file RangeBlock.h.
Referenced by print(), processing(), processing_decrement(), processing_increment(), and release().
|
private |
Definition at line 144 of file RangeBlock.h.
Referenced by _split(), load_cells(), load_final(), release(), and ~Block().
|
private |
Definition at line 147 of file RangeBlock.h.
Referenced by _split(), and add_logged().
|
private |
Definition at line 153 of file RangeBlock.h.
Referenced by load_final(), loaded(), need_load(), print(), processing(), release(), and scan().
Block::Ptr SWC::Ranger::Block::next |
Definition at line 42 of file RangeBlock.h.
Referenced by _add(), SWC::Ranger::Blocks::_clear(), SWC::Ranger::Blocks::_processing(), SWC::Ranger::Blocks::_size(), SWC::Ranger::Blocks::_size_bytes(), SWC::Ranger::Blocks::add_logged(), SWC::Ranger::Blocks::cells_count(), SWC::Ranger::Blocks::init_blocks(), SWC::Ranger::Blocks::print(), SWC::Ranger::Blocks::release(), SWC::Ranger::Blocks::scan(), and SWC::Ranger::Blocks::schema_update().
Block::Ptr SWC::Ranger::Block::prev |
Definition at line 43 of file RangeBlock.h.
Referenced by _add(), SWC::Ranger::Blocks::_clear(), and SWC::Ranger::Blocks::scan().