Returns maximum length and average length of the contents of a given column (in std::string bytes) */
| 1104 | Returns maximum length and average length of the contents of a given column (in std::string bytes) |
| 1105 | */ |
| 1106 | std::pair<int, int> CsvTable::maximumContentLength(table_index_t col, table_index_t max_probe_rows) { |
| 1107 | int max_length = 0, average_length = 0; |
| 1108 | uint64_t sum_length = 0; |
| 1109 | table_index_t probe_rows = getNumberRows(); |
| 1110 | if( max_probe_rows > 0 ) |
| 1111 | probe_rows = std::min(probe_rows, max_probe_rows); |
| 1112 | if( probe_rows > 0 ) { |
| 1113 | for(table_index_t r = 0; r < probe_rows; ++r) { |
| 1114 | int cell_length = getCell(r, col).length(); |
| 1115 | if( cell_length > max_length ) { |
| 1116 | max_length = cell_length; |
| 1117 | } |
| 1118 | sum_length += cell_length; |
| 1119 | } |
| 1120 | average_length = (int)(sum_length / probe_rows); |
| 1121 | } |
| 1122 | return std::make_pair(max_length, average_length); |
| 1123 | } |
| 1124 | |
| 1125 | |
| 1126 |