| 195 | } |
| 196 | |
| 197 | void printCoverageMap( |
| 198 | const std::vector<std::string>& scalarNames, |
| 199 | const std::vector<std::string>& aggNames, |
| 200 | const std::vector<std::string>& windowNames, |
| 201 | const std::unordered_set<std::string>& boltNames, |
| 202 | const std::unordered_set<std::string>& boltAggNames, |
| 203 | const std::unordered_set<std::string>& boltWindowNames, |
| 204 | const std::string& domain) { |
| 205 | const auto scalarCnt = scalarNames.size(); |
| 206 | const auto aggCnt = aggNames.size(); |
| 207 | const auto windowCnt = windowNames.size(); |
| 208 | |
| 209 | // Make sure there is enough space for the longest function name + :func: |
| 210 | // syntax that turns function name into a link to function's description. |
| 211 | const int columnSize = std::max( |
| 212 | {maxLength(scalarNames), |
| 213 | maxLength(aggNames), |
| 214 | maxLength(windowNames)}) + |
| 215 | toFuncLink("", domain).size(); |
| 216 | |
| 217 | const std::string indent(4, ' '); |
| 218 | |
| 219 | const int numScalarColumns = 5; |
| 220 | |
| 221 | // Split scalar functions into 'numScalarColumns' columns. Put all aggregate |
| 222 | // functions into one column. |
| 223 | auto numRows = std::max( |
| 224 | {(size_t)std::ceil((double)scalarCnt / numScalarColumns), |
| 225 | aggCnt, |
| 226 | windowCnt}); |
| 227 | |
| 228 | // Keep track of cells which contain functions available in Bolt. These cells |
| 229 | // need to be highlighted using CSS rules. |
| 230 | TableCellTracker boltCellTracker; |
| 231 | |
| 232 | auto printName = [&](int row, |
| 233 | int column, |
| 234 | const std::string& name, |
| 235 | const std::unordered_set<std::string>& boltNames) { |
| 236 | if (boltNames.count(name)) { |
| 237 | boltCellTracker.add(row, column); |
| 238 | return toFuncLink(name, domain); |
| 239 | } else { |
| 240 | return name; |
| 241 | } |
| 242 | }; |
| 243 | |
| 244 | std::ostringstream out; |
| 245 | TablePrinter printer(numScalarColumns, columnSize, indent, out); |
| 246 | printer.header(); |
| 247 | for (int i = 0; i < numRows; i++) { |
| 248 | printer.startRow(); |
| 249 | |
| 250 | // N columns of scalar functions. |
| 251 | for (int j = 0; j < numScalarColumns; j++) { |
| 252 | auto n = i + numRows * j; |
| 253 | n < scalarCnt |
| 254 | ? printer.addColumn(printName(i, j, scalarNames[n], boltNames)) |
no test coverage detected