Thrill
0.1
|
Block combines a reference to a read-only ByteBlock and book-keeping information.
The book-keeping meta-information currently is the start of the first item, the ends of the item range, and the number of items in the range.
Multiple Block instances can share the same ByteBlock but have different book-keeping / meta- information!
+–+------—+------—+----------—+------—+--—+ | |Item1 |Item2 |Item3 |Item4 |Item5|(partial) +–+------—+------—+----------—+------—+--—+ ^ ^ ^ begin first_item num_items=5 end
#include <block.hpp>
Public Member Functions | |
Block ()=default | |
default-ctor: create invalid Block. More... | |
Block (const Block &other)=default | |
Block (Block &&other)=default | |
Block (ByteBlockPtr &&byte_block, size_t begin, size_t end, size_t first_item, size_t num_items, bool typecode_verify) | |
const ByteBlockPtr & | byte_block () const |
access to byte_block_ More... | |
ByteBlockPtr & | byte_block () |
mutable access to byte_block_ More... | |
size_t | first_item_absolute () const |
accessor to first_item_ (absolute in ByteBlock) More... | |
size_t | first_item_relative () const |
return the first_item_offset relative to data_begin(). More... | |
bool | IsValid () const |
Return whether the enclosed ByteBlock is valid. More... | |
size_t | num_items () const |
return number of items beginning in this block More... | |
Block & | operator= (const Block &other)=default |
Block & | operator= (Block &&other)=default |
PinRequestPtr | Pin (size_t local_worker_id) const |
size_t | pin_count (size_t local_worker_id) const |
return number of pins in underlying ByteBlock More... | |
PinnedBlock | PinWait (size_t local_worker_id) const |
Convenience function to call Pin() and wait for the future. More... | |
void | set_begin (size_t i) |
accessor to begin_ More... | |
void | set_end (size_t i) |
accessor to end_ More... | |
size_t | size () const |
return length of valid data in bytes. More... | |
bool | typecode_verify () const |
Returns typecode_verify_. More... | |
Protected Attributes | |
size_t | begin_ = 0 |
beginning offset of valid bytes to read More... | |
ByteBlockPtr | byte_block_ |
referenced ByteBlock More... | |
size_t | end_ = 0 |
size_t | first_item_ = 0 |
size_t | num_items_ = 0 |
bool | typecode_verify_ = false |
Static Protected Attributes | |
static constexpr bool | debug = false |
Friends | |
std::ostream & | operator<< (std::ostream &os, const Block &b) |
|
default |
default-ctor: create invalid Block.
Referenced by PinnedBlock::MoveToBlock(), and PinnedBlock::ToBlock().
|
inline |
Creates a block that points to the given data::ByteBlock with the given offsets The block can be initialized as pinned or not.
|
inline |
access to byte_block_
Definition at line 79 of file block.hpp.
References Block::byte_block_.
Referenced by PinnedBlock::byte_block(), Block::Pin(), and BlockPool::PinBlock().
|
inline |
mutable access to byte_block_
Definition at line 82 of file block.hpp.
References Block::byte_block_.
|
inline |
accessor to first_item_ (absolute in ByteBlock)
Definition at line 103 of file block.hpp.
References Block::first_item_.
Referenced by PinnedBlock::first_item_absolute().
|
inline |
return the first_item_offset relative to data_begin().
Definition at line 106 of file block.hpp.
References Block::begin_, and Block::first_item_.
Referenced by PinnedBlock::first_item_relative().
|
inline |
Return whether the enclosed ByteBlock is valid.
Definition at line 74 of file block.hpp.
References Block::byte_block_.
Referenced by BlockReader< CatBlockSource >::GetItemBatch(), PinnedBlock::IsValid(), thrill::data::operator<<(), Block::Pin(), BlockQueue::Pop(), MixBlockQueue::Pop(), MixBlockQueueReader::PullBlock(), and PinnedBlock::ToString().
|
inline |
return number of items beginning in this block
Definition at line 85 of file block.hpp.
References Block::num_items_.
Referenced by StreamSink::AppendBlock(), File::AppendBlock(), BlockReader< CatBlockSource >::GetItemBatch(), PinnedBlock::num_items(), and MixBlockQueueReader::PullBlock().
Referenced by PinnedBlock::operator=().
PinRequestPtr Pin | ( | size_t | local_worker_id | ) | const |
Creates a pinned copy of this Block. If the underlying data::ByteBlock is already pinned, the Future is directly filled with a copy if this block. Otherwise an async pin call will be issued.
Definition at line 39 of file block.cpp.
References Block::byte_block(), and Block::IsValid().
Referenced by PinnedBlock::CopyPinnedByteBlock(), KeepFileBlockSource::NextBlock(), ConsumeFileBlockSource::NextBlock(), Block::PinWait(), KeepFileBlockSource::Prefetch(), ConsumeFileBlockSource::Prefetch(), and Block::typecode_verify().
|
inline |
return number of pins in underlying ByteBlock
Definition at line 88 of file block.hpp.
References Block::byte_block_.
Referenced by PinnedBlock::pin_count().
PinnedBlock PinWait | ( | size_t | local_worker_id | ) | const |
Convenience function to call Pin() and wait for the future.
Definition at line 35 of file block.cpp.
References Block::Pin().
Referenced by KeepFileBlockSource::AcquirePin(), ConsumeFileBlockSource::AcquirePin(), StreamSink::AppendBlock(), WriteBinaryNode< ValueType >::SysFileSink::AppendBlock(), PinnedBlock::CopyPinnedByteBlock(), KeepFileBlockSource::NextBlock(), and Block::typecode_verify().
|
inline |
accessor to begin_
Definition at line 94 of file block.hpp.
References Block::begin_.
Referenced by KeepFileBlockSource::MakeNextBlock(), and PinnedBlock::set_begin().
|
inline |
accessor to end_
Definition at line 97 of file block.hpp.
References Block::end_.
Referenced by PinnedBlock::set_end().
|
inline |
return length of valid data in bytes.
Definition at line 100 of file block.hpp.
References Block::begin_, and Block::end_.
Referenced by StreamSink::AppendBlock(), File::AppendBlock(), KeepFileBlockSource::NextBlock(), ConsumeFileBlockSource::NextBlock(), KeepFileBlockSource::Prefetch(), ConsumeFileBlockSource::Prefetch(), PinnedBlock::size(), and PinnedBlock::ToString().
|
inline |
Returns typecode_verify_.
Definition at line 109 of file block.hpp.
References Block::operator<<, Block::Pin(), Block::PinWait(), and Block::typecode_verify_.
Referenced by PinnedBlock::typecode_verify().
|
friend |
Definition at line 22 of file block.cpp.
Referenced by PinnedBlock::CopyPinnedByteBlock(), and Block::typecode_verify().
|
protected |
beginning offset of valid bytes to read
Definition at line 128 of file block.hpp.
Referenced by PinnedBlock::data_begin(), Block::first_item_relative(), thrill::data::operator<<(), Block::set_begin(), and Block::size().
|
protected |
referenced ByteBlock
Definition at line 125 of file block.hpp.
Referenced by Block::byte_block(), PinnedBlock::CopyPinnedByteBlock(), PinnedBlock::data_begin(), PinnedBlock::data_end(), Block::IsValid(), PinnedBlock::MoveToBlock(), thrill::data::operator<<(), PinnedBlock::operator=(), Block::pin_count(), PinnedBlock::PinnedBlock(), PinnedBlock::Reset(), PinnedBlock::StealPinnedByteBlock(), and PinnedBlock::~PinnedBlock().
|
protected |
one byte beyond the end of the valid bytes in the ByteBlock (can be used to virtually shorten a ByteBlock)
Definition at line 132 of file block.hpp.
Referenced by PinnedBlock::data_end(), thrill::data::operator<<(), Block::set_end(), and Block::size().
|
protected |
offset of first valid element in the ByteBlock in absolute bytes from byte_block_->begin().
Definition at line 136 of file block.hpp.
Referenced by Block::first_item_absolute(), Block::first_item_relative(), and thrill::data::operator<<().
|
protected |
number of valid items that start in this block (includes cut-off element at the end)
Definition at line 140 of file block.hpp.
Referenced by Block::num_items(), and thrill::data::operator<<().
|
protected |
flag whether the underlying data contains self verify type codes from BlockReader, this is false to needed to read external files.
Definition at line 144 of file block.hpp.
Referenced by Block::typecode_verify().