MySQL 8.4.3
Source Code Documentation
TraceBuffer Class Referencefinal

This class is used for storing unstructured optimizer trace text (as used by the Hypergraph optimizer). More...

#include <optimizer_trace.h>

Inheritance diagram for TraceBuffer:
[legend]

Public Member Functions

int_type overflow (int_type ch) override
 Called by std::ostream if the current segment is full. More...
 
template<typename Sink >
void ForEach (Sink sink) const
 Apply 'sink' to each character in the trace text. More...
 
template<typename Sink >
void ForEachRemove (Sink sink)
 Apply 'sink' to each character in the trace text. More...
 
std::string ToString () const
 Return a copy of the contents as a string. More...
 

Static Public Attributes

static constexpr size_t kSegmentSize = 4096
 The size of each consecutive buffer. More...
 

Private Types

using Segment = std::array< char, kSegmentSize >
 A consecutive buffer. More...
 
using DequeType = std::deque< Segment >
 The sequence of consecutive buffers. More...
 

Private Attributes

DequeType m_segments
 The sequence of segments. More...
 

Detailed Description

This class is used for storing unstructured optimizer trace text (as used by the Hypergraph optimizer).

It is used as the std::streambuf object of an associated std::ostream (which writes the formatted text into a TraceBuffer object). The text is stored in a non-consecutive sequence of segments, where each segment has a chunk of consecutive memory. That way, the buffer can grow without having to copy the text into ever bigger buffers of consecutive memory.

Member Typedef Documentation

◆ DequeType

using TraceBuffer::DequeType = std::deque<Segment>
private

The sequence of consecutive buffers.

◆ Segment

using TraceBuffer::Segment = std::array<char, kSegmentSize>
private

A consecutive buffer.

Member Function Documentation

◆ ForEach()

template<typename Sink >
void TraceBuffer::ForEach ( Sink  sink) const
inline

Apply 'sink' to each character in the trace text.

◆ ForEachRemove()

template<typename Sink >
void TraceBuffer::ForEachRemove ( Sink  sink)
inline

Apply 'sink' to each character in the trace text.

Free each segment when its contents have been consumed.

◆ overflow()

int_type TraceBuffer::overflow ( int_type  ch)
inlineoverride

Called by std::ostream if the current segment is full.

Allocate a new segment and put 'ch' at the beginning of it.

◆ ToString()

std::string TraceBuffer::ToString ( ) const
inline

Return a copy of the contents as a string.

This may be expensive for large traces, and is only intended for unit tests.

Member Data Documentation

◆ kSegmentSize

constexpr size_t TraceBuffer::kSegmentSize = 4096
staticconstexpr

The size of each consecutive buffer.

◆ m_segments

DequeType TraceBuffer::m_segments
private

The sequence of segments.


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