Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
|
#include <table-printer.h>
Public Member Functions | |
TablePrinter () | |
void | AddColumn (const std::string &label, bool left_align) |
void | set_max_output_width (int width) |
void | AddRow (const std::vector< std::string > &row) |
Add a row to the table. This must have the same width as labels. More... | |
std::string | ToString (const std::string &prefix="") const |
Print to a table with prefix coming before the output. More... | |
Private Member Functions | |
void | PrintRow (std::stringstream *ss, const std::vector< std::string > &row, const std::vector< int > &widths) const |
Helper function to print one row to ss. More... | |
Private Attributes | |
std::vector< std::string > | labels_ |
std::vector< bool > | left_align_ |
For each column, true if the value should be left aligned, right aligned otherwise. More... | |
int | max_output_width_ |
-1 to indicate unlimited. More... | |
std::vector< std::vector < std::string > > | rows_ |
std::vector< int > | max_col_widths_ |
Utility class to pretty print tables. Rows can be added and at the end printed with fixed with spacing.
Definition at line 27 of file table-printer.h.
TablePrinter::TablePrinter | ( | ) |
Definition at line 28 of file table-printer.cc.
void TablePrinter::AddColumn | ( | const std::string & | label, |
bool | left_align | ||
) |
Add a column to the table. All calls to AddColumn() must come before any calls to AddRow().
Definition at line 31 of file table-printer.cc.
References labels_, left_align_, and max_col_widths_.
Referenced by impala::PrintExecSummary().
void TablePrinter::AddRow | ( | const std::vector< std::string > & | row | ) |
Add a row to the table. This must have the same width as labels.
Definition at line 42 of file table-printer.cc.
References labels_, max_col_widths_, and rows_.
Referenced by impala::PrintExecSummary().
|
private |
Helper function to print one row to ss.
Definition at line 50 of file table-printer.cc.
References COLUMN_PAD, labels_, and left_align_.
Referenced by ToString().
void TablePrinter::set_max_output_width | ( | int | width | ) |
Sets the max per column output width (otherwise, columns will be as wide as the largest value). Values longer than this will be cut off.
Definition at line 37 of file table-printer.cc.
References max_output_width_.
Referenced by impala::PrintExecSummary().
string TablePrinter::ToString | ( | const std::string & | prefix = "" | ) | const |
Print to a table with prefix coming before the output.
Definition at line 73 of file table-printer.cc.
References COLUMN_PAD, labels_, max_col_widths_, max_output_width_, PrintRow(), and rows_.
Referenced by impala::PrintExecSummary().
|
private |
Definition at line 46 of file table-printer.h.
Referenced by AddColumn(), AddRow(), PrintRow(), and ToString().
|
private |
For each column, true if the value should be left aligned, right aligned otherwise.
Definition at line 48 of file table-printer.h.
Referenced by AddColumn(), and PrintRow().
|
private |
Definition at line 54 of file table-printer.h.
Referenced by AddColumn(), AddRow(), and ToString().
|
private |
-1 to indicate unlimited.
Definition at line 51 of file table-printer.h.
Referenced by set_max_output_width(), and ToString().
|
private |
Definition at line 53 of file table-printer.h.
Referenced by AddRow(), and ToString().