#include <swcdb/ranger/db/RangeBlocks.h>
Public Types | |
typedef Blocks * | Ptr |
Public Member Functions | |
Blocks (const DB::Types::KeySeq key_seq) | |
Blocks (const Blocks &)=delete | |
Blocks (const Blocks &&)=delete | |
Blocks & | operator= (const Blocks &)=delete |
void | init (const RangePtr &for_range) |
Ptr | ptr () |
~Blocks () noexcept | |
void | schema_update () |
void | processing_increment () |
void | processing_decrement () |
void | load (int &err) |
void | unload () |
void | remove (int &err) |
void | expand (DB::Cells::Interval &intval) |
void | expand_and_align (DB::Cells::Interval &intval) |
void | apply_new (int &err, CellStore::Writers &w_cellstores, CommitLog::Fragments::Vec &fragments_old) |
void | add_logged (const DB::Cells::Cell &cell) |
void | scan (ReqScan::Ptr req, Block::Ptr blk_ptr=nullptr) |
bool | _split (Block::Ptr blk, bool loaded) |
size_t | cells_count () |
size_t | size () noexcept |
size_t | size_bytes () |
size_t | size_bytes_total (bool only_loaded=false) |
size_t | release (size_t bytes) |
size_t | release (size_t bytes, uint8_t level) |
void | reset_blocks () |
bool | processing () noexcept |
bool | wait_processing (int64_t quit_time=0) |
void | print (std::ostream &out, bool minimal) |
Public Attributes | |
RangePtr | range |
CommitLog::Fragments | commitlog |
CellStore::Readers | cellstores |
Private Member Functions | |
size_t SWC_PURE_FUNC | _size () const noexcept |
size_t | _size_bytes () |
bool | _processing () const noexcept |
void | _clear () |
void | init_blocks (int &err) |
size_t SWC_PURE_FUNC | _get_block_idx (const Block::Ptr blk) const noexcept |
size_t | _narrow (const DB::Cell::Key &key) const |
Private Attributes | |
Core::MutexSptd | m_mutex |
Block::Ptr | m_block |
Core::Vector< Block::Ptr > | m_blocks_idx |
Core::Atomic< size_t > | m_processing |
Static Private Attributes | |
static const uint8_t | MAX_IDX_NARROW = 20 |
Definition at line 23 of file RangeBlocks.h.
typedef Blocks* SWC::Ranger::Blocks::Ptr |
Definition at line 25 of file RangeBlocks.h.
|
explicit |
Definition at line 13 of file RangeBlocks.cc.
|
delete |
|
delete |
|
inlinenoexcept |
Definition at line 45 of file RangeBlocks.h.
|
private |
Definition at line 458 of file RangeBlocks.cc.
References m_block, m_blocks_idx, SWC::Ranger::Block::next, and SWC::Ranger::Block::prev.
Referenced by init_blocks(), release(), remove(), reset_blocks(), and unload().
|
privatenoexcept |
Definition at line 505 of file RangeBlocks.cc.
Referenced by _split().
|
private |
Definition at line 513 of file RangeBlocks.cc.
References SWC::DB::Cell::Key::empty(), m_blocks_idx, and MAX_IDX_NARROW.
Referenced by add_logged(), and scan().
|
privatenoexcept |
Definition at line 448 of file RangeBlocks.cc.
References m_block, m_processing, and SWC::Ranger::Block::next.
Referenced by print(), and processing().
|
privatenoexcept |
Definition at line 432 of file RangeBlocks.cc.
References m_block, and SWC::Ranger::Block::next.
Referenced by print(), and size().
|
private |
Definition at line 440 of file RangeBlocks.cc.
References m_block, and SWC::Ranger::Block::next.
Referenced by print(), size_bytes(), and size_bytes_total().
bool SWC::Ranger::Blocks::_split | ( | Block::Ptr | blk, |
bool | loaded | ||
) |
Definition at line 241 of file RangeBlocks.cc.
References _get_block_idx(), SWC::Ranger::Block::_need_split(), SWC::Ranger::Block::_split(), commitlog, SWC::Ranger::CommitLog::Fragments::is_compacting(), SWC::Ranger::Block::loaded(), m_blocks_idx, m_mutex, SWC::System::Resources::need_ram(), SWC::Ranger::Block::preload(), SWC::Ranger::Block::processing_increment(), range, SWC::Env::Rgr::res(), SWC::Env::Rgr::scan_reserved_bytes(), SWC::Core::MutexSptd::try_full_lock(), and SWC::Core::MutexSptd::unlock().
Referenced by SWC::Ranger::Block::splitter().
SWC_CAN_INLINE void SWC::Ranger::Blocks::add_logged | ( | const DB::Cells::Cell & | cell | ) |
Definition at line 111 of file RangeBlocks.cc.
References _narrow(), SWC::Ranger::CommitLog::Fragments::add(), SWC::Ranger::Block::add_logged(), commitlog, SWC::DB::Cells::Cell::key, m_block, m_blocks_idx, m_mutex, and SWC::Ranger::Block::next.
Referenced by SWC::Ranger::Range::_run_add_queue().
void SWC::Ranger::Blocks::apply_new | ( | int & | err, |
CellStore::Writers & | w_cellstores, | ||
CommitLog::Fragments::Vec & | fragments_old | ||
) |
Definition at line 94 of file RangeBlocks.cc.
References cellstores, commitlog, m_mutex, SWC::Ranger::CommitLog::Fragments::remove(), SWC::Ranger::CellStore::Readers::replace(), SWC::Ranger::RangeData::save(), and wait_processing().
Referenced by SWC::Ranger::Range::apply_new().
size_t SWC::Ranger::Blocks::cells_count | ( | ) |
Definition at line 274 of file RangeBlocks.cc.
References m_block, m_mutex, and SWC::Ranger::Block::next.
SWC_CAN_INLINE void SWC::Ranger::Blocks::expand | ( | DB::Cells::Interval & | intval | ) |
Definition at line 83 of file RangeBlocks.cc.
References cellstores, commitlog, SWC::Ranger::CommitLog::Fragments::expand(), and SWC::Ranger::CellStore::Readers::expand().
Referenced by SWC::Ranger::Range::expand_and_align(), and SWC::Ranger::Range::load().
SWC_CAN_INLINE void SWC::Ranger::Blocks::expand_and_align | ( | DB::Cells::Interval & | intval | ) |
Definition at line 89 of file RangeBlocks.cc.
References cellstores, commitlog, SWC::Ranger::CommitLog::Fragments::expand_and_align(), and SWC::Ranger::CellStore::Readers::expand_and_align().
Referenced by SWC::Ranger::Range::expand_and_align(), and SWC::Ranger::Range::load().
SWC_CAN_INLINE void SWC::Ranger::Blocks::init | ( | const RangePtr & | for_range | ) |
Definition at line 20 of file RangeBlocks.cc.
References cellstores, commitlog, SWC::Ranger::CellStore::Readers::init(), SWC::Ranger::CommitLog::Fragments::init(), and range.
Referenced by SWC::Ranger::Range::init().
|
private |
Definition at line 471 of file RangeBlocks.cc.
References SWC::Ranger::Block::_add(), _clear(), SWC::Ranger::Block::_cond_key_end(), SWC::Ranger::Block::_free_key_end(), SWC::Ranger::Block::_set_key_end(), SWC::Ranger::Block::_set_prev_key_end(), cellstores, SWC::Condition::EQ, SWC::Ranger::CellStore::Readers::get_blocks(), m_block, m_blocks_idx, SWC::Ranger::Block::make(), SWC::Ranger::Block::next, ptr(), range, SWC::Error::RGR_NOT_LOADED_RANGE, and SWC::Core::Vector< T, SizeT, GROW_SZ >::size().
Referenced by scan().
SWC_CAN_INLINE void SWC::Ranger::Blocks::load | ( | int & | err | ) |
Definition at line 50 of file RangeBlocks.cc.
References cellstores, commitlog, SWC::Ranger::CellStore::Readers::load(), and SWC::Ranger::CommitLog::Fragments::load().
Referenced by SWC::Ranger::Range::load().
void SWC::Ranger::Blocks::print | ( | std::ostream & | out, |
bool | minimal | ||
) |
Definition at line 403 of file RangeBlocks.cc.
References _processing(), _size(), _size_bytes(), cellstores, commitlog, m_block, m_mutex, SWC::Ranger::Block::next, SWC::Ranger::Block::print(), SWC::Ranger::CommitLog::Fragments::print(), and SWC::Ranger::CellStore::Readers::print().
Referenced by SWC::Ranger::Range::print().
|
noexcept |
Definition at line 371 of file RangeBlocks.cc.
References _processing(), m_mutex, SWC::Core::MutexSptd::try_full_lock(), and SWC::Core::MutexSptd::unlock().
Referenced by SWC::Ranger::Range::compact_possible(), and wait_processing().
SWC_CAN_INLINE void SWC::Ranger::Blocks::processing_decrement | ( | ) |
Definition at line 45 of file RangeBlocks.cc.
References SWC::Core::Atomic< T, OrderT >::fetch_sub(), and m_processing.
Referenced by SWC::Ranger::Range::_run_add_queue(), SWC::Ranger::Range::_run_scan_queue(), SWC::Ranger::Block::_scan(), SWC::Ranger::Range::loaded(), SWC::Ranger::Block::loader_loaded(), release(), remove(), SWC::Ranger::Range::scan(), scan(), and unload().
SWC_CAN_INLINE void SWC::Ranger::Blocks::processing_increment | ( | ) |
Definition at line 40 of file RangeBlocks.cc.
References SWC::Core::Atomic< T, OrderT >::fetch_add(), and m_processing.
Referenced by SWC::Ranger::Range::_run_add_queue(), SWC::Ranger::Range::_run_scan_queue(), SWC::Ranger::Range::load(), release(), remove(), SWC::Ranger::Range::scan(), scan(), unload(), and SWC::Ranger::Range::wait().
SWC_CAN_INLINE Blocks::Ptr SWC::Ranger::Blocks::ptr | ( | ) |
Definition at line 27 of file RangeBlocks.cc.
Referenced by init_blocks().
size_t SWC::Ranger::Blocks::release | ( | size_t | bytes | ) |
Definition at line 299 of file RangeBlocks.cc.
References SWC::DB::Types::SystemColumn::is_data(), and range.
size_t SWC::Ranger::Blocks::release | ( | size_t | bytes, |
uint8_t | level | ||
) |
Definition at line 314 of file RangeBlocks.cc.
References _clear(), cellstores, SWC::Ranger::CommitLog::Fragments::commit_release(), commitlog, SWC::Core::Atomic< T, OrderT >::fetch_add(), m_block, m_mutex, m_processing, SWC::Ranger::Block::next, processing_decrement(), processing_increment(), range, SWC::Ranger::CellStore::Readers::release(), SWC::Ranger::CommitLog::Fragments::release(), SWC::Core::MutexSptd::try_full_lock(), and SWC::Core::MutexSptd::unlock().
void SWC::Ranger::Blocks::remove | ( | int & | err | ) |
Definition at line 68 of file RangeBlocks.cc.
References _clear(), cellstores, commitlog, m_mutex, processing_decrement(), processing_increment(), range, SWC::Ranger::CommitLog::Fragments::remove(), SWC::Ranger::CellStore::Readers::unload(), and wait_processing().
Referenced by SWC::Ranger::Range::internal_remove().
void SWC::Ranger::Blocks::reset_blocks | ( | ) |
Definition at line 366 of file RangeBlocks.cc.
References _clear(), and m_mutex.
void SWC::Ranger::Blocks::scan | ( | ReqScan::Ptr | req, |
Block::Ptr | blk_ptr = nullptr |
||
) |
Definition at line 126 of file RangeBlocks.cc.
References _narrow(), commitlog, init_blocks(), SWC::Ranger::CommitLog::Fragments::is_compacting(), SWC::Ranger::Block::is_next(), SWC::Core::MutexSptd::lock(), m_block, m_blocks_idx, m_mutex, SWC::System::Resources::need_ram(), SWC::Ranger::Block::next, SWC::Time::now_ns(), SWC::Error::OK, SWC::Ranger::Block::prev, processing_decrement(), processing_increment(), SWC::DB::Types::MngrRange::QUEUED, range, SWC::Ranger::Block::release(), SWC::Env::Rgr::res(), SWC::Env::Rgr::scan_reserved_bytes(), SWC::Core::MutexSptd::try_full_lock(), and SWC::Core::MutexSptd::unlock().
Referenced by SWC::Ranger::Block::_scan(), SWC::Ranger::Range::scan(), and SWC::Ranger::Range::scan_internal().
void SWC::Ranger::Blocks::schema_update | ( | ) |
Definition at line 31 of file RangeBlocks.cc.
References commitlog, m_block, m_mutex, SWC::Ranger::Block::next, and SWC::Ranger::CommitLog::Fragments::schema_update().
Referenced by SWC::Ranger::Range::schema_update().
|
noexcept |
Definition at line 282 of file RangeBlocks.cc.
References _size(), and m_mutex.
size_t SWC::Ranger::Blocks::size_bytes | ( | ) |
Definition at line 287 of file RangeBlocks.cc.
References _size_bytes(), and m_mutex.
size_t SWC::Ranger::Blocks::size_bytes_total | ( | bool | only_loaded = false | ) |
Definition at line 292 of file RangeBlocks.cc.
References _size_bytes(), cellstores, commitlog, m_mutex, SWC::Ranger::CommitLog::Fragments::size_bytes(), and SWC::Ranger::CellStore::Readers::size_bytes().
Referenced by SWC::Ranger::Range::internal_unload().
void SWC::Ranger::Blocks::unload | ( | ) |
Definition at line 55 of file RangeBlocks.cc.
References _clear(), cellstores, SWC::Ranger::CommitLog::Fragments::commit_finalize(), commitlog, m_mutex, processing_decrement(), processing_increment(), range, SWC::Ranger::CellStore::Readers::unload(), SWC::Ranger::CommitLog::Fragments::unload(), and wait_processing().
Referenced by SWC::Ranger::Range::internal_unload().
bool SWC::Ranger::Blocks::wait_processing | ( | int64_t | quit_time = 0 | ) |
Definition at line 381 of file RangeBlocks.cc.
References cellstores, commitlog, SWC::LOG_WARN, SWC::Time::now_ns(), SWC::Ranger::CellStore::Readers::processing(), SWC::Ranger::CommitLog::Fragments::processing(), processing(), range, SWC_FMT_LU, SWC_LOG_OSTREAM, SWC_LOG_OUT, and SWC_LOG_PRINTF.
Referenced by apply_new(), remove(), and unload().
CellStore::Readers SWC::Ranger::Blocks::cellstores |
Definition at line 31 of file RangeBlocks.h.
Referenced by apply_new(), SWC::Ranger::Range::can_be_merged(), expand(), expand_and_align(), init(), init_blocks(), SWC::Ranger::Range::internal_create(), load(), SWC::Ranger::Range::load(), print(), release(), remove(), SWC::Ranger::BlockLoader::run(), size_bytes_total(), unload(), and wait_processing().
CommitLog::Fragments SWC::Ranger::Blocks::commitlog |
Definition at line 30 of file RangeBlocks.h.
Referenced by SWC::Ranger::Range::_run_add_queue(), _split(), add_logged(), apply_new(), SWC::Ranger::Range::can_be_merged(), expand(), expand_and_align(), init(), SWC::Ranger::Range::internal_remove(), SWC::Ranger::Range::internal_unload(), load(), SWC::Ranger::BlockLoader::load_cells(), print(), release(), SWC::Ranger::Range::remove(), remove(), scan(), schema_update(), size_bytes_total(), unload(), and wait_processing().
|
private |
Definition at line 112 of file RangeBlocks.h.
Referenced by _clear(), _processing(), _size(), _size_bytes(), add_logged(), cells_count(), init_blocks(), print(), release(), scan(), and schema_update().
|
private |
Definition at line 113 of file RangeBlocks.h.
Referenced by _clear(), _narrow(), _split(), add_logged(), init_blocks(), and scan().
|
private |
Definition at line 111 of file RangeBlocks.h.
Referenced by _split(), add_logged(), apply_new(), cells_count(), print(), processing(), release(), remove(), reset_blocks(), scan(), schema_update(), size(), size_bytes(), size_bytes_total(), and unload().
|
private |
Definition at line 114 of file RangeBlocks.h.
Referenced by _processing(), processing_decrement(), processing_increment(), and release().
|
staticprivate |
Definition at line 109 of file RangeBlocks.h.
Referenced by _narrow().
RangePtr SWC::Ranger::Blocks::range |
Definition at line 29 of file RangeBlocks.h.
Referenced by SWC::Ranger::Block::_need_split(), _split(), SWC::Ranger::Block::_split(), SWC::Ranger::Block::Block(), init(), init_blocks(), SWC::Ranger::Range::internal_unload(), SWC::Ranger::Block::load_cells(), SWC::Ranger::Block::load_final(), SWC::Ranger::Block::preload(), SWC::Ranger::Block::release(), release(), remove(), scan(), SWC::Ranger::Block::schema_update(), unload(), wait_processing(), and SWC::Ranger::Block::~Block().