util::stream::RewindableStream Class Reference

#include <rewindable_stream.hh>

Collaboration diagram for util::stream::RewindableStream:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 RewindableStream ()
 ~RewindableStream ()
void Init (const ChainPosition &position)
 RewindableStream (const ChainPosition &position)
const void * Get () const
void * Get ()
 operator bool () const
bool operator! () const
void Mark ()
void Rewind ()
RewindableStreamoperator++ ()
void Poison ()


Detailed Description

A RewindableStream is like a Stream (but one that is only used for creating input at the start of a chain) except that it can be rewound to be able to re-write a part of the stream before it is sent. Rewinding has a limit of 2 * block_size_ - 1 in distance (it does *not* buffer an entire stream into memory, only a maximum of 2 * block_size_).

Definition at line 20 of file rewindable_stream.hh.


Constructor & Destructor Documentation

util::stream::RewindableStream::RewindableStream (  ) 

Creates an uninitialized RewindableStream. You **must** call Init() on it later!

Definition at line 9 of file rewindable_stream.cc.

util::stream::RewindableStream::~RewindableStream (  )  [inline]

Definition at line 28 of file rewindable_stream.hh.

References Poison().

Here is the call graph for this function:

util::stream::RewindableStream::RewindableStream ( const ChainPosition position  )  [inline, explicit]

Constructs a RewindableStream at a specific position in a Chain all in one step.

Equivalent to RewindableStream a(); a.Init(....);

Definition at line 47 of file rewindable_stream.hh.

References Init().

Here is the call graph for this function:


Member Function Documentation

void* util::stream::RewindableStream::Get (  )  [inline]

Gets the record at the current stream position.

Definition at line 64 of file rewindable_stream.hh.

const void* util::stream::RewindableStream::Get (  )  const [inline]

Gets the record at the current stream position. Const version.

Definition at line 55 of file rewindable_stream.hh.

Referenced by operator++(), and Rewind().

Here is the caller graph for this function:

void util::stream::RewindableStream::Init ( const ChainPosition position  ) 

Initializes an existing RewindableStream at a specific position in a Chain.

Parameters:
position The position in the chain to get input from and produce output on

Definition at line 14 of file rewindable_stream.cc.

References util::stream::Chain::BlockCount(), util::stream::Chain::BlockSize(), util::stream::Chain::EntrySize(), util::stream::ChainPosition::GetChain(), NULL, and UTIL_THROW_IF2.

Referenced by util::stream::operator>>(), and RewindableStream().

Here is the call graph for this function:

Here is the caller graph for this function:

void util::stream::RewindableStream::Mark (  ) 

Marks the current position in the stream to be rewound to later. Note that you can only rewind back as far as 2 * block_size_ - 1!

Definition at line 58 of file rewindable_stream.cc.

util::stream::RewindableStream::operator bool (  )  const [inline]

Definition at line 70 of file rewindable_stream.hh.

bool util::stream::RewindableStream::operator! (  )  const [inline]

Definition at line 72 of file rewindable_stream.hh.

RewindableStream & util::stream::RewindableStream::operator++ (  ) 

Moves the stream forward to the next record. This internally may buffer a block for the purposes of rewinding.

Definition at line 30 of file rewindable_stream.cc.

References Get(), util::stream::Block::Get(), UTIL_UNLIKELY, and util::stream::Block::ValidSize().

Here is the call graph for this function:

void util::stream::RewindableStream::Poison (  ) 

Poisons the stream. This sends any buffered blocks down the chain and sends a poison block as well (sending at most 2 non-poison and 1 poison block).

Definition at line 78 of file rewindable_stream.cc.

References util::PCQueue< T >::Consume(), and util::PCQueue< T >::Produce().

Referenced by ~RewindableStream().

Here is the call graph for this function:

Here is the caller graph for this function:

void util::stream::RewindableStream::Rewind (  ) 

Rewinds the stream back to the marked position. This will throw an exception if the marked position is too far away.

Definition at line 64 of file rewindable_stream.cc.

References Get().

Here is the call graph for this function:


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

Generated on Thu Jul 6 00:34:54 2017 for Moses by  doxygen 1.5.9