MySQL 8.3.0
Source Code Documentation
IO_CACHE_istream Class Reference

A file input stream based on IO_CACHE class. More...

#include <basic_istream.h>

Inheritance diagram for IO_CACHE_istream:
[legend]

Public Member Functions

 IO_CACHE_istream ()
 
 IO_CACHE_istream (const IO_CACHE_istream &)=delete
 
IO_CACHE_istreamoperator= (const IO_CACHE_istream &)=delete
 
 ~IO_CACHE_istream () override
 
bool open (PSI_file_key log_file_key, PSI_file_key log_cache_key, const char *file_name, myf flags, size_t cache_size=IO_SIZE *2)
 Open the stream. More...
 
void close ()
 Closes the stream. More...
 
ssize_t read (unsigned char *buffer, size_t length) override
 Read some bytes from the input stream. More...
 
bool seek (my_off_t bytes) override
 Puts the read position to a given offset. More...
 
my_off_t length () override
 Get the length of the file. More...
 
- Public Member Functions inherited from Basic_seekable_istream
 ~Basic_seekable_istream () override=default
 
- Public Member Functions inherited from Basic_istream
virtual ~Basic_istream ()=default
 

Private Attributes

IO_CACHE m_io_cache
 

Detailed Description

A file input stream based on IO_CACHE class.

It can be used to open a file and provide a Basic_seekable_istream based on the file.

Constructor & Destructor Documentation

◆ IO_CACHE_istream() [1/2]

IO_CACHE_istream::IO_CACHE_istream ( )
default

◆ IO_CACHE_istream() [2/2]

IO_CACHE_istream::IO_CACHE_istream ( const IO_CACHE_istream )
delete

◆ ~IO_CACHE_istream()

IO_CACHE_istream::~IO_CACHE_istream ( )
override

Member Function Documentation

◆ close()

void IO_CACHE_istream::close ( )

Closes the stream.

It deinitializes IO_CACHE and closes the file it opened.

◆ length()

my_off_t IO_CACHE_istream::length ( )
overridevirtual

Get the length of the file.

Implements Basic_seekable_istream.

◆ open()

bool IO_CACHE_istream::open ( PSI_file_key  log_file_key,
PSI_file_key  log_cache_key,
const char *  file_name,
myf  flags,
size_t  cache_size = IO_SIZE * 2 
)

Open the stream.

It opens related file and initializes IO_CACHE.

Parameters
[in]log_file_keyThe PSI_file_key for this stream
[in]log_cache_keyThe PSI_file_key for the IO_CACHE
[in]file_nameThe file to be opened
[in]flagsThe flags used by IO_CACHE.
[in]cache_sizeCache size of the IO_CACHE.
Return values
falseSuccess
trueError

◆ operator=()

IO_CACHE_istream & IO_CACHE_istream::operator= ( const IO_CACHE_istream )
delete

◆ read()

ssize_t IO_CACHE_istream::read ( unsigned char *  buffer,
size_t  length 
)
overridevirtual

Read some bytes from the input stream.

It should read exact 'length' bytes unless error happens or it reaches the end of the stream. It should block when reaching the end of a pipe that is not closed.

Parameters
[out]bufferWhere data will be put in.
[in]lengthThe number of bytes that you want to read. length should not be larger than max long.
Returns
Return values fall into three cases:
Return values
'length'Read 'length' bytes successfully
>=0Reach EOF, return the number of bytes actually read. It is between 0 and length-1.
-1Error.

Implements Basic_istream.

◆ seek()

bool IO_CACHE_istream::seek ( my_off_t  offset)
overridevirtual

Puts the read position to a given offset.

The offset counts from the beginning of the stream. In case an implementing class transforms the data in a way that does not preserve positions, the offset here will be relative to the bytes that are read out from the stream, not relative to the bytes in lower layer storage.

it is allowed for a subclass to return success even if the position is greater than the size of the file. Error may be returned by the next read for this case. Users should call length() if they need to check that the position is within bounds.

Parameters
[in]offsetWhere the read position will be.
Return values
falseSuccess
trueError

Implements Basic_seekable_istream.

Member Data Documentation

◆ m_io_cache

IO_CACHE IO_CACHE_istream::m_io_cache
private

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