Thrill  0.1
Block Class Reference

Detailed Description

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

Definition at line 52 of file block.hpp.

+ Inheritance diagram for Block:
+ Collaboration diagram for Block:

#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 ByteBlockPtrbyte_block () const
 access to byte_block_ More...
 
ByteBlockPtrbyte_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...
 
Blockoperator= (const Block &other)=default
 
Blockoperator= (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)
 

Constructor & Destructor Documentation

◆ Block() [1/4]

Block ( )
default

default-ctor: create invalid Block.

Referenced by PinnedBlock::MoveToBlock(), and PinnedBlock::ToBlock().

◆ Block() [2/4]

Block ( const Block other)
default

◆ Block() [3/4]

Block ( Block &&  other)
default

◆ Block() [4/4]

Block ( ByteBlockPtr &&  byte_block,
size_t  begin,
size_t  end,
size_t  first_item,
size_t  num_items,
bool  typecode_verify 
)
inline

Creates a block that points to the given data::ByteBlock with the given offsets The block can be initialized as pinned or not.

Definition at line 65 of file block.hpp.

Member Function Documentation

◆ byte_block() [1/2]

const ByteBlockPtr& byte_block ( ) const
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().

◆ byte_block() [2/2]

ByteBlockPtr& byte_block ( )
inline

mutable access to byte_block_

Definition at line 82 of file block.hpp.

References Block::byte_block_.

◆ first_item_absolute()

size_t first_item_absolute ( ) const
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().

◆ first_item_relative()

size_t first_item_relative ( ) const
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().

◆ IsValid()

◆ num_items()

size_t num_items ( ) const
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().

◆ operator=() [1/2]

Block& operator= ( const Block other)
default

Referenced by PinnedBlock::operator=().

◆ operator=() [2/2]

Block& operator= ( Block &&  other)
default

◆ Pin()

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

◆ pin_count()

size_t pin_count ( size_t  local_worker_id) const
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().

◆ PinWait()

◆ set_begin()

void set_begin ( size_t  i)
inline

accessor to begin_

Definition at line 94 of file block.hpp.

References Block::begin_.

Referenced by KeepFileBlockSource::MakeNextBlock(), and PinnedBlock::set_begin().

◆ set_end()

void set_end ( size_t  i)
inline

accessor to end_

Definition at line 97 of file block.hpp.

References Block::end_.

Referenced by PinnedBlock::set_end().

◆ size()

◆ typecode_verify()

bool typecode_verify ( ) const
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().

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
const Block b 
)
friend

Definition at line 22 of file block.cpp.

Referenced by PinnedBlock::CopyPinnedByteBlock(), and Block::typecode_verify().

Member Data Documentation

◆ begin_

size_t begin_ = 0
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().

◆ byte_block_

◆ debug

constexpr bool debug = false
staticprotected

Definition at line 122 of file block.hpp.

◆ end_

size_t end_ = 0
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().

◆ first_item_

size_t first_item_ = 0
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<<().

◆ num_items_

size_t num_items_ = 0
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<<().

◆ typecode_verify_

bool typecode_verify_ = false
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().


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