Thrill
0.1
|
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.
#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 () |
ConsumeFileBlockSource & | operator= (const ConsumeFileBlockSource &)=delete |
non-copyable: delete assignment operator More... | |
void | Prefetch (size_t prefetch_size) |
Perform prefetch. More... | |
Private Attributes | |
std::deque< PinRequestPtr > | fetching_blocks_ |
current prefetch operations More... | |
size_t | fetching_bytes_ |
current number of bytes in prefetch More... | |
File * | file_ |
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... | |
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_.
|
delete |
non-copyable: delete copy-constructor
Consume unread blocks and reset File to zero items.
Definition at line 282 of file file.cpp.
References File::Clear(), and ConsumeFileBlockSource::file_.
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().
PinnedBlock NextBlock | ( | ) |
Get the next block of file.
Definition at line 232 of file file.cpp.
References File::blocks_, ConsumeFileBlockSource::fetching_blocks_, ConsumeFileBlockSource::fetching_bytes_, ConsumeFileBlockSource::file_, ConsumeFileBlockSource::local_worker_id_, Block::Pin(), ConsumeFileBlockSource::prefetch_size_, Block::size(), and PinnedBlock::size().
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.
|
delete |
non-copyable: delete assignment operator
void Prefetch | ( | size_t | prefetch_size | ) |
Perform prefetch.
Definition at line 215 of file file.cpp.
References File::blocks_, ConsumeFileBlockSource::fetching_blocks_, ConsumeFileBlockSource::fetching_bytes_, ConsumeFileBlockSource::file_, ConsumeFileBlockSource::local_worker_id_, Block::Pin(), ConsumeFileBlockSource::prefetch_size_, and Block::size().
Referenced by ConsumeFileBlockSource::ConsumeFileBlockSource().
|
private |
current prefetch operations
Definition at line 458 of file file.hpp.
Referenced by ConsumeFileBlockSource::NextBlock(), ConsumeFileBlockSource::NextBlockUnpinned(), and ConsumeFileBlockSource::Prefetch().
|
private |
current number of bytes in prefetch
Definition at line 461 of file file.hpp.
Referenced by ConsumeFileBlockSource::NextBlock(), ConsumeFileBlockSource::NextBlockUnpinned(), and ConsumeFileBlockSource::Prefetch().
|
private |
file to consume blocks from (ptr to make moving easier)
Definition at line 449 of file file.hpp.
Referenced by ConsumeFileBlockSource::NextBlock(), ConsumeFileBlockSource::NextBlockUnpinned(), ConsumeFileBlockSource::Prefetch(), and ConsumeFileBlockSource::~ConsumeFileBlockSource().
|
private |
local worker id reading the File
Definition at line 452 of file file.hpp.
Referenced by ConsumeFileBlockSource::AcquirePin(), ConsumeFileBlockSource::NextBlock(), and ConsumeFileBlockSource::Prefetch().
|
private |
number of bytes of prefetch for reader
Definition at line 455 of file file.hpp.
Referenced by ConsumeFileBlockSource::ConsumeFileBlockSource(), ConsumeFileBlockSource::NextBlock(), ConsumeFileBlockSource::NextBlockUnpinned(), and ConsumeFileBlockSource::Prefetch().