MySQL 8.0.39
Source Code Documentation
Log_file Struct Reference

Meta information about single log file. More...

#include <log0types.h>

Public Member Functions

 Log_file (const Log_file &other)=default
 
bool operator== (const Log_file &rhs) const
 Checks if this object is equal to a given another object. More...
 
void lsn_validate () const
 Validates that lsn fields seem correct (m_start_lsn, m_end_lsn) More...
 
bool contains (lsn_t lsn) const
 Checks if a given lsn belongs to [m_start_lsn, m_end_lsn). More...
 
os_offset_t offset (lsn_t lsn) const
 Provides offset for the given LSN (from the beginning of the log file). More...
 
Log_file_id next_id () const
 Computes id of the next log file. More...
 

Static Public Member Functions

static os_offset_t offset (lsn_t lsn, lsn_t file_start_lsn)
 Provides offset for the given LSN and log file with the given start_lsn (offset from the beginning of the log file). More...
 
static Log_file_id next_id (Log_file_id id, size_t inc=1)
 Computes id + inc, asserting it does not overflow the maximum value. More...
 

Public Attributes

const Log_files_contextm_files_ctx
 Context within which this file exists. More...
 
Log_file_id m_id
 ID of the file. More...
 
bool m_consumed
 Set to true when file becomes consumed. More...
 
bool m_full
 Set to true when file became full and next file exists. More...
 
os_offset_t m_size_in_bytes
 Size, expressed in bytes, including LOG_FILE_HDR_SIZE. More...
 
lsn_t m_start_lsn
 LSN of the first byte within the file, aligned to OS_FILE_LOG_BLOCK_SIZE. More...
 
lsn_t m_end_lsn
 LSN of the first byte after the file, aligned to OS_FILE_LOG_BLOCK_SIZE. More...
 
Encryption_metadatam_encryption_metadata
 Encryption metadata passed to opened file handles. More...
 

Log_file_handle implementation

 Log_file (const Log_files_context &files_ctx, Encryption_metadata &encryption_metadata)
 
 Log_file (const Log_files_context &files_ctx, Log_file_id id, bool consumed, bool full, os_offset_t size_in_bytes, lsn_t start_lsn, lsn_t end_lsn, Encryption_metadata &encryption_metadata)
 
Log_fileoperator= (const Log_file &other)
 
Log_file_handle open (Log_file_access_mode access_mode) const
 Opens this file and provides handle that allows to read from this file and / or write to this file (depends on the requested access mode). More...
 
static Log_file_handle open (const Log_files_context &files_ctx, Log_file_id file_id, Log_file_access_mode access_mode, Encryption_metadata &encryption_metadata, Log_file_type file_type=Log_file_type::NORMAL)
 Opens a given redo log file and provides handle that allows to read from that file and / or write to that file (depends on the requested access mode). More...
 

Detailed Description

Meta information about single log file.

Constructor & Destructor Documentation

◆ Log_file() [1/3]

Log_file::Log_file ( const Log_files_context files_ctx,
Encryption_metadata encryption_metadata 
)

◆ Log_file() [2/3]

Log_file::Log_file ( const Log_files_context files_ctx,
Log_file_id  id,
bool  consumed,
bool  full,
os_offset_t  size_in_bytes,
lsn_t  start_lsn,
lsn_t  end_lsn,
Encryption_metadata encryption_metadata 
)

◆ Log_file() [3/3]

Log_file::Log_file ( const Log_file other)
default

Member Function Documentation

◆ contains()

bool Log_file::contains ( lsn_t  lsn) const
inline

Checks if a given lsn belongs to [m_start_lsn, m_end_lsn).

In other words, checks that the given lsn belongs to this file.

Parameters
[in]lsnlsn to test against lsn range
Returns
true iff lsn is in the file

◆ lsn_validate()

void Log_file::lsn_validate ( ) const
inline

Validates that lsn fields seem correct (m_start_lsn, m_end_lsn)

◆ next_id() [1/2]

Log_file_id Log_file::next_id ( ) const
inline

Computes id of the next log file.

Does not check if such file exists.

Returns
id of the next log file

◆ next_id() [2/2]

static Log_file_id Log_file::next_id ( Log_file_id  id,
size_t  inc = 1 
)
inlinestatic

Computes id + inc, asserting it does not overflow the maximum value.

Parameters
[in]idbase id of file, to which inc is added
[in]incnumber of log files ahead (1 = directly next one)
Returns
id + inc

◆ offset() [1/2]

os_offset_t Log_file::offset ( lsn_t  lsn) const
inline

Provides offset for the given LSN (from the beginning of the log file).

Parameters
[in]lsnlsn to locate (must exist in the file)
Returns
offset from the beginning of the file for the given lsn

◆ offset() [2/2]

static os_offset_t Log_file::offset ( lsn_t  lsn,
lsn_t  file_start_lsn 
)
inlinestatic

Provides offset for the given LSN and log file with the given start_lsn (offset from the beginning of the log file).

Parameters
[in]lsnlsn to locate (must be >= file_start_lsn)
[in]file_start_lsnstart lsn of the log file
Returns
offset from the beginning of the file for the given lsn

◆ open() [1/2]

Log_file_handle Log_file::open ( const Log_files_context files_ctx,
Log_file_id  file_id,
Log_file_access_mode  access_mode,
Encryption_metadata encryption_metadata,
Log_file_type  file_type = Log_file_type::NORMAL 
)
static

Opens a given redo log file and provides handle that allows to read from that file and / or write to that file (depends on the requested access mode).

Parameters
[in]files_ctxcontext within which file exists
[in]file_idid of the redo log file to open
[in]access_moderequested access mode (reads and/or writes)
[in]encryption_metadataencryption metadata
[in]file_typetype of underlying file on disk to open
Returns
handle to the opened file or empty handle with error information

◆ open() [2/2]

Log_file_handle Log_file::open ( Log_file_access_mode  access_mode) const

Opens this file and provides handle that allows to read from this file and / or write to this file (depends on the requested access mode).

Parameters
[in]access_moderequested access mode (reads and/or writes)
Returns
handle to the opened file or empty handle with error information

◆ operator=()

Log_file & Log_file::operator= ( const Log_file other)

◆ operator==()

bool Log_file::operator== ( const Log_file rhs) const
inline

Checks if this object is equal to a given another object.

Parameters
[in]rhsthe object to compare against
Returns
true iff all related fields of the two objects are equal

Member Data Documentation

◆ m_consumed

bool Log_file::m_consumed

Set to true when file becomes consumed.

◆ m_encryption_metadata

Encryption_metadata& Log_file::m_encryption_metadata

Encryption metadata passed to opened file handles.

See also
Log_file_handle::m_encryption_metadata

◆ m_end_lsn

lsn_t Log_file::m_end_lsn

LSN of the first byte after the file, aligned to OS_FILE_LOG_BLOCK_SIZE.

◆ m_files_ctx

const Log_files_context& Log_file::m_files_ctx

Context within which this file exists.

◆ m_full

bool Log_file::m_full

Set to true when file became full and next file exists.

◆ m_id

Log_file_id Log_file::m_id

ID of the file.

◆ m_size_in_bytes

os_offset_t Log_file::m_size_in_bytes

Size, expressed in bytes, including LOG_FILE_HDR_SIZE.

◆ m_start_lsn

lsn_t Log_file::m_start_lsn

LSN of the first byte within the file, aligned to OS_FILE_LOG_BLOCK_SIZE.


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