QueryReportFormatter

QueryReportFormatter is used primarily by mk-query-digest to print reports.  The main sub is print_reports() which prints the various reports for mk-query-digest --report-format.  Each report is produced in a sub of the same name; e.g.  --report-format=query_report == sub query_report().  The given ea (EventAggregator object) is expected to be “complete”; i.e. fully aggregated and $ea->calculate_statistical_metrics() already called.  Subreports “profile” and “prepared” require the ReportFormatter module, which is also in mk-query-digest.

Functions

new

sub new

Parameters

%argsRequired arguments

Required Arguments

OptionParserOptionParser object
QueryRewriterQueryRewriter object
QuoterQuoter object

Optional arguments

QueryReviewQueryReview object used in query_report()
dbhdbh used in explain_report()
ExplainAnalyzerExplainAnalyzer object used in explain_report().  This causes a sparkline to be printed (issue 1141).

Returns

QueryReportFormatter object

set_report_formatter

sub set_report_formatter

Set a report formatter object for a report.  By default this package will instantiate ReportFormatter objects to format columnized reports (e.g. for profile and prepared reports).  Setting a caller-created formatter object (usually a ReportFormatter obj) is used for tested and also by <mk-query-digest> to extend the profile report line width to 82 for the --explain sparkline.

Parameters

%argsArguments

Required Arguments

reportReport name, e.g. profile, prepared, etc.
formatterFormatter object, usually a ReportFormatter obj

print_reports

sub print_reports

rusage

sub rusage

date

sub date

hostname

sub hostname

files

sub files

header

sub header

query_report

sub query_report

event_report

sub event_report

chart_distro

sub chart_distro

distro_sparkline

sub distro_sparkline

Make a sparkline of the chart_distro() graph.  The following character codes are used: _.-^ If a bucket doesn’t have a value, a space is used.  So _ buckets are the lowest lines on the full graph (chart_distro()), and ^ are the peaks on the full graph.  See QueryReportFormatter.t for several examples.

This sub isn’t the most optimized.  The first half is the same code as chart_distro().  Then the latter code, unique to this sub, essentially compresses the full chart further into 8 characters using the 4 char codes above.

Parameters

%argsArguments

Required Arguments

eaEventAggregator object
itemItem in results to chart
attribAttribute of item to chart

Returns

Sparkchart string

profile

sub profile

prepared

sub prepared

make_global_header

sub make_global_header

make_event_header

sub make_event_header

make_label

sub make_label

bool_percents

sub bool_percents

format_string_list

sub format_string_list

sort_attribs

sub sort_attribs

pref_sort

sub pref_sort

tables_report

sub tables_report

explain_report

sub explain_report

format_time_range

sub format_time_range

explain_sparkline

sub explain_sparkline

_d

sub _d
sub new
sub set_report_formatter
Set a report formatter object for a report.
sub print_reports
sub rusage
sub date
sub hostname
sub files
sub header
sub query_report
sub event_report
sub chart_distro
sub distro_sparkline
Make a sparkline of the chart_distro() graph.
sub profile
sub prepared
sub make_global_header
sub make_event_header
sub make_label
sub bool_percents
sub format_string_list
sub sort_attribs
sub pref_sort
sub tables_report
sub explain_report
sub format_time_range
sub explain_sparkline
sub _d
EventAggregator aggregates event values and calculates basic statistics.
OptionParser parses command line options from a tool’s POD.
QueryRewriter rewrites and transforms queries.
Quoter handles value quoting, unquoting, escaping, etc.
QueryReview is an API to a query review table.
ExplainAnalyzer contains utility methods for getting and manipulating EXPLAIN data.
ReportFormatter makes columnized reports given variable-width data lines.
Close