MySQL 9.1.0
Source Code Documentation
|
A file input stream based on IO_CACHE class. More...
#include <basic_istream.h>
Public Member Functions | |
IO_CACHE_istream () | |
IO_CACHE_istream (const IO_CACHE_istream &)=delete | |
IO_CACHE_istream & | operator= (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 |
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.
|
default |
|
delete |
|
override |
void IO_CACHE_istream::close | ( | ) |
Closes the stream.
It deinitializes IO_CACHE and closes the file it opened.
|
overridevirtual |
Get the length of the file.
Implements Basic_seekable_istream.
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.
[in] | log_file_key | The PSI_file_key for this stream |
[in] | log_cache_key | The PSI_file_key for the IO_CACHE |
[in] | file_name | The file to be opened |
[in] | flags | The flags used by IO_CACHE. |
[in] | cache_size | Cache size of the IO_CACHE. |
false | Success |
true | Error |
|
delete |
|
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.
[out] | buffer | Where data will be put in. |
[in] | length | The number of bytes that you want to read. length should not be larger than max long. |
'length' | Read 'length' bytes successfully |
>=0 | Reach EOF, return the number of bytes actually read. It is between 0 and length-1. |
-1 | Error. |
Implements Basic_istream.
|
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.
[in] | offset | Where the read position will be. |
false | Success |
true | Error |
Implements Basic_seekable_istream.
|
private |