Thrill  0.1
ConsumeFileBlockSource Class Reference

Detailed Description

A BlockSource to read and simultaneously consume Blocks from a File.

The ConsumeFileBlockSource always returns the first block of the File and removes it, hence, consuming Blocks from the File.

Attention
The reader consumes the File's contents UNCONDITIONALLY, the File will always be emptied whether all items were read via the Reader or not.

Definition at line 414 of file file.hpp.

+ Collaboration diagram for ConsumeFileBlockSource:

#include <file.hpp>

Public Member Functions

 ConsumeFileBlockSource (File *file, size_t local_worker_id, size_t prefetch_size=File::default_prefetch_size_)
 
 ConsumeFileBlockSource (const ConsumeFileBlockSource &)=delete
 non-copyable: delete copy-constructor More...
 
 ConsumeFileBlockSource (ConsumeFileBlockSource &&s)
 move-constructor: default More...
 
 ~ConsumeFileBlockSource ()
 Consume unread blocks and reset File to zero items. More...
 
PinnedBlock AcquirePin (const Block &block)
 Acquire Pin for Block returned from NextBlockUnpinned. More...
 
PinnedBlock NextBlock ()
 Get the next block of file. More...
 
Block NextBlockUnpinned ()
 
ConsumeFileBlockSourceoperator= (const ConsumeFileBlockSource &)=delete
 non-copyable: delete assignment operator More...
 
void Prefetch (size_t prefetch_size)
 Perform prefetch. More...
 

Private Attributes

std::deque< PinRequestPtrfetching_blocks_
 current prefetch operations More...
 
size_t fetching_bytes_
 current number of bytes in prefetch More...
 
Filefile_
 file to consume blocks from (ptr to make moving easier) More...
 
size_t local_worker_id_
 local worker id reading the File More...
 
size_t prefetch_size_
 number of bytes of prefetch for reader More...
 

Constructor & Destructor Documentation

◆ ConsumeFileBlockSource() [1/3]

ConsumeFileBlockSource ( File file,
size_t  local_worker_id,
size_t  prefetch_size = File::default_prefetch_size_ 
)

Start reading a File. Creates a source for the given file and set the number of blocks that should be prefetched. 0 means that no blocks are prefetched.

Definition at line 199 of file file.cpp.

References ConsumeFileBlockSource::Prefetch(), and ConsumeFileBlockSource::prefetch_size_.

◆ ConsumeFileBlockSource() [2/3]

non-copyable: delete copy-constructor

◆ ConsumeFileBlockSource() [3/3]

move-constructor: default

Definition at line 207 of file file.cpp.

◆ ~ConsumeFileBlockSource()

Consume unread blocks and reset File to zero items.

Definition at line 282 of file file.cpp.

References File::Clear(), and ConsumeFileBlockSource::file_.

Member Function Documentation

◆ AcquirePin()

PinnedBlock AcquirePin ( const Block block)

Acquire Pin for Block returned from NextBlockUnpinned.

Definition at line 278 of file file.cpp.

References ConsumeFileBlockSource::local_worker_id_, and Block::PinWait().

◆ NextBlock()

◆ NextBlockUnpinned()

Block NextBlockUnpinned ( )

Get next block unpinned, used by GetItemBatch to read Blocks without pinning them

Definition at line 259 of file file.cpp.

References File::blocks_, ConsumeFileBlockSource::fetching_blocks_, ConsumeFileBlockSource::fetching_bytes_, ConsumeFileBlockSource::file_, ConsumeFileBlockSource::prefetch_size_, PinnedBlock::size(), and TLX_UNLIKELY.

◆ operator=()

ConsumeFileBlockSource& operator= ( const ConsumeFileBlockSource )
delete

non-copyable: delete assignment operator

◆ Prefetch()

Member Data Documentation

◆ fetching_blocks_

std::deque<PinRequestPtr> fetching_blocks_
private

current prefetch operations

Definition at line 458 of file file.hpp.

Referenced by ConsumeFileBlockSource::NextBlock(), ConsumeFileBlockSource::NextBlockUnpinned(), and ConsumeFileBlockSource::Prefetch().

◆ fetching_bytes_

size_t fetching_bytes_
private

current number of bytes in prefetch

Definition at line 461 of file file.hpp.

Referenced by ConsumeFileBlockSource::NextBlock(), ConsumeFileBlockSource::NextBlockUnpinned(), and ConsumeFileBlockSource::Prefetch().

◆ file_

File* file_
private

◆ local_worker_id_

size_t local_worker_id_
private

local worker id reading the File

Definition at line 452 of file file.hpp.

Referenced by ConsumeFileBlockSource::AcquirePin(), ConsumeFileBlockSource::NextBlock(), and ConsumeFileBlockSource::Prefetch().

◆ prefetch_size_

size_t prefetch_size_
private

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