SWC-DB  v0.5.12 C++ documentations
SWC-DB© (Super Wide Column Database) - High Performance Scalable Database (https://github.com/kashirin-alex/swc-db)
SWC::Ranger::Block Class Referencefinal

#include <swcdb/ranger/db/RangeBlock.h>

+ Collaboration diagram for SWC::Ranger::Block:

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 BlockPtr
 

Public Member Functions

 Block (const DB::Cells::Interval &interval, Blocks *blocks, State state=State::NONE)
 
 Block (const Block &)=delete
 
 Block (const Block &&)=delete
 
Blockoperator= (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

Blocksblocks
 
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< Statem_state
 
BlockLoaderm_loader
 

Detailed Description

Definition at line 23 of file RangeBlock.h.

Member Typedef Documentation

◆ Ptr

Definition at line 26 of file RangeBlock.h.

Member Enumeration Documentation

◆ ScanState

Enumerator
UKNOWN 
QUEUED 
RESPONDED 
SYNCED 

Definition at line 34 of file RangeBlock.h.

◆ State

enum SWC::Ranger::Block::State : uint8_t
Enumerator
NONE 
LOADING 
LOADED 

Definition at line 28 of file RangeBlock.h.

Constructor & Destructor Documentation

◆ Block() [1/3]

SWC_CAN_INLINE SWC::Ranger::Block::Block ( const DB::Cells::Interval interval,
Blocks blocks,
State  state = State::NONE 
)
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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Block() [2/3]

SWC::Ranger::Block::Block ( const Block )
delete

◆ Block() [3/3]

SWC::Ranger::Block::Block ( const Block &&  )
delete

◆ ~Block()

SWC_CAN_INLINE SWC::Ranger::Block::~Block ( )
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().

+ Here is the call graph for this function:

Member Function Documentation

◆ _add()

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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _cond_key_end()

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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _free_key_end()

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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _includes_begin()

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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _is_in_end()

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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _need_split()

SWC_CAN_INLINE bool SWC::Ranger::Block::_need_split ( ) const
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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _releasing_size()

SWC_CAN_INLINE size_t SWC::Ranger::Block::_releasing_size ( ) const
noexcept

Definition at line 51 of file RangeBlock.cc.

References m_key_end, m_prev_key_end, and SWC::DB::Cell::Key::size.

◆ _scan()

Block::ScanState SWC::Ranger::Block::_scan ( const ReqScan::Ptr req,
bool  synced = false 
)
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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _set_key_end()

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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _set_prev_key_end() [1/2]

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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _set_prev_key_end() [2/2]

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.

+ Here is the call graph for this function:

◆ _size()

SWC_CAN_INLINE size_t SWC::Ranger::Block::_size ( ) const
noexcept

Definition at line 469 of file RangeBlock.cc.

References m_cells, and SWC::DB::Cells::Mutable::size().

Referenced by _need_split(), and size().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _split()

Block::Ptr SWC::Ranger::Block::_split ( bool  loaded)

◆ add_logged()

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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ includes()

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.

+ Here is the call graph for this function:

◆ includes_end()

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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ is_consist()

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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ is_in_end()

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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ is_next()

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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ load_cells()

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 
)

◆ load_final()

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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ loaded()

SWC_CAN_INLINE bool SWC::Ranger::Block::loaded ( ) const
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().

+ Here is the caller graph for this function:

◆ loader_loaded()

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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ make()

SWC_CAN_INLINE Block::Ptr SWC::Ranger::Block::make ( const DB::Cells::Interval interval,
Blocks blocks,
State  state = State::NONE 
)
static

Definition at line 16 of file RangeBlock.cc.

References Block(), and blocks.

Referenced by _split(), and SWC::Ranger::Blocks::init_blocks().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ need_load()

SWC_CAN_INLINE bool SWC::Ranger::Block::need_load ( ) const
noexcept

Definition at line 437 of file RangeBlock.cc.

References m_state, and SWC::Condition::NONE.

◆ operator=()

Block& SWC::Ranger::Block::operator= ( const Block )
delete

Referenced by loader_loaded().

+ Here is the caller graph for this function:

◆ preload()

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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ print()

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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ processing()

SWC_CAN_INLINE bool SWC::Ranger::Block::processing ( )
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().

+ Here is the call graph for this function:

◆ processing_decrement()

SWC_CAN_INLINE void SWC::Ranger::Block::processing_decrement ( )
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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ processing_increment()

SWC_CAN_INLINE void SWC::Ranger::Block::processing_increment ( )
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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ptr()

SWC_CAN_INLINE Block::Ptr SWC::Ranger::Block::ptr ( )

Definition at line 56 of file RangeBlock.cc.

Referenced by _add(), _scan(), scan(), and splitter().

+ Here is the caller graph for this function:

◆ release()

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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ 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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ schema_update()

void SWC::Ranger::Block::schema_update ( )
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.

+ Here is the call graph for this function:

◆ size()

SWC_CAN_INLINE size_t SWC::Ranger::Block::size ( )

Definition at line 463 of file RangeBlock.cc.

References _size(), and m_mutex.

+ Here is the call graph for this function:

◆ size_bytes()

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().

+ Here is the call graph for this function:

◆ size_of_internal()

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().

+ Here is the call graph for this function:

◆ split()

Block::Ptr SWC::Ranger::Block::split ( bool  loaded)

Definition at line 348 of file RangeBlock.cc.

References _split(), loaded(), and m_mutex.

+ Here is the call graph for this function:

◆ splitter()

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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ blocks

◆ m_cells

◆ m_key_end

◆ m_loader

BlockLoader* SWC::Ranger::Block::m_loader
private

Definition at line 154 of file RangeBlock.h.

Referenced by loader_loaded(), processing(), release(), and scan().

◆ m_mutex

std::shared_mutex SWC::Ranger::Block::m_mutex
private

◆ m_mutex_intval

Core::MutexAtomic SWC::Ranger::Block::m_mutex_intval
mutableprivate

Definition at line 146 of file RangeBlock.h.

Referenced by _split(), add_logged(), includes(), is_in_end(), is_next(), and print().

◆ m_mutex_state

Core::MutexSptd SWC::Ranger::Block::m_mutex_state
private

Definition at line 151 of file RangeBlock.h.

Referenced by load_final(), loader_loaded(), processing(), release(), and scan().

◆ m_prev_key_end

DB::Cell::Key SWC::Ranger::Block::m_prev_key_end
private

◆ m_processing

Core::Atomic<size_t> SWC::Ranger::Block::m_processing
private

Definition at line 152 of file RangeBlock.h.

Referenced by print(), processing(), processing_decrement(), processing_increment(), and release().

◆ m_releasable_bytes

Core::Atomic<size_t> SWC::Ranger::Block::m_releasable_bytes
private

Definition at line 144 of file RangeBlock.h.

Referenced by _split(), load_cells(), load_final(), release(), and ~Block().

◆ m_split_rev

uint32_t SWC::Ranger::Block::m_split_rev
private

Definition at line 147 of file RangeBlock.h.

Referenced by _split(), and add_logged().

◆ m_state

Core::Atomic<State> SWC::Ranger::Block::m_state
private

Definition at line 153 of file RangeBlock.h.

Referenced by load_final(), loaded(), need_load(), print(), processing(), release(), and scan().

◆ next

◆ prev

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().


The documentation for this class was generated from the following files: