24#ifndef SQL_JOIN_OPTIMIZER_OPTIMIZER_TRACE_H_
25#define SQL_JOIN_OPTIMIZER_OPTIMIZER_TRACE_H_ 1
53 using Segment = std::array<char, kSegmentSize>;
62 assert(max_bytes >= 0);
70 int_type
overflow(int_type ch)
override;
77 template <
typename Sink>
80 (pptr() ==
nullptr && pbase() ==
nullptr && epptr() ==
nullptr));
90 setp(
nullptr,
nullptr);
114 for (
const char &ch : *segment) {
116 if (segment + 1 ==
m_segments.cend() && &ch == pptr()) {
UnstructuredTrace * unstructured_trace()
Definition: opt_trace_context.h:276
bool is_started() const
Returns whether there is a current trace.
Definition: opt_trace_context.h:148
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:36
Opt_trace_context opt_trace
optimizer trace of current statement
Definition: sql_class.h:4069
This class is used for storing unstructured optimizer trace text (as used by the Hypergraph optimizer...
Definition: optimizer_trace.h:46
TraceBuffer(int64_t max_bytes)
Definition: optimizer_trace.h:58
std::array< char, kSegmentSize > Segment
A consecutive buffer.
Definition: optimizer_trace.h:53
std::unique_ptr< Segment > m_excess_segment
If we fill m_max_segments, allocate a single extra segment that is repeatedly overwritten with any ad...
Definition: optimizer_trace.h:136
std::deque< Segment > m_segments
The sequence of segments.
Definition: optimizer_trace.h:131
std::string ToString() const
Return a copy of the contents as a string.
Definition: optimizer_trace.h:109
static constexpr int64_t kSegmentSize
The size of each consecutive buffer.
Definition: optimizer_trace.h:49
int64_t m_full_excess_segments
The number of full segments that did not fit in m_segments.
Definition: optimizer_trace.h:139
void Consume(Sink sink)
Apply 'sink' to each character in the trace text.
Definition: optimizer_trace.h:78
int_type overflow(int_type ch) override
Called by std::ostream if the current segment is full.
Definition: optimizer_trace.cc:27
int64_t excess_bytes() const
Get the number of bytes that did not fit in m_segments.
Definition: optimizer_trace.h:100
int64_t m_max_segments
Max number of segments (as given by the optimizer_trace_max_mem_size system variable).
Definition: optimizer_trace.h:128
Trace in the form of plain text (i.e.
Definition: optimizer_trace.h:146
std::ostream m_stream
The stream that formats text and appends it to m_buffer.
Definition: optimizer_trace.h:164
TraceBuffer m_buffer
The trace text.
Definition: optimizer_trace.h:161
TraceBuffer & contents()
Definition: optimizer_trace.h:156
UnstructuredTrace(int64_t max_bytes)
Definition: optimizer_trace.h:150
const TraceBuffer & contents() const
Definition: optimizer_trace.h:157
std::ostream & stream()
Get the stream in which to put the trace text.
Definition: optimizer_trace.h:154
This contains the declaration of class Opt_trace_context, which is needed to declare THD.
std::ostream & Trace(THD *thd)
Fetch the ostream that we write optimizer trace into.
Definition: optimizer_trace.h:170
bool TraceStarted(THD *thd)
Definition: optimizer_trace.h:176
struct result result
Definition: result.h:34