Aggregates the various stats from the lower to upper levels. This includes calculating max and average time values for stats marked as time based.
()
| 468 | * calculating max and average time values for stats marked as time based. |
| 469 | */ |
| 470 | public void aggQueryStats() { |
| 471 | // These are overall aggregations |
| 472 | final Map<QueryStat, Pair<Long, Long>> overall_cumulations = |
| 473 | new HashMap<QueryStat, Pair<Long, Long>>(); |
| 474 | |
| 475 | // scanner aggs |
| 476 | for (final Entry<Integer, Map<Integer, Map<QueryStat, Long>>> entry : |
| 477 | scanner_stats.entrySet()) { |
| 478 | final int query_index = entry.getKey(); |
| 479 | |
| 480 | final Map<QueryStat, Pair<Long, Long>> cumulations = |
| 481 | new HashMap<QueryStat, Pair<Long, Long>>(); |
| 482 | |
| 483 | for (final Entry<Integer, Map<QueryStat, Long>> scanner : |
| 484 | entry.getValue().entrySet()) { |
| 485 | |
| 486 | for (final Entry<QueryStat, Long> stat : scanner.getValue().entrySet()) { |
| 487 | if (stat.getKey().is_time) { |
| 488 | if (!AGG_MAP.containsKey(stat.getKey())) { |
| 489 | // we're not aggregating this value |
| 490 | continue; |
| 491 | } |
| 492 | |
| 493 | // per query aggs |
| 494 | Pair<Long, Long> pair = cumulations.get(stat.getKey()); |
| 495 | if (pair == null) { |
| 496 | pair = new Pair<Long, Long>(0L, Long.MIN_VALUE); |
| 497 | cumulations.put(stat.getKey(), pair); |
| 498 | } |
| 499 | pair.setKey(pair.getKey() + stat.getValue()); |
| 500 | if (stat.getValue() > pair.getValue()) { |
| 501 | pair.setValue(stat.getValue()); |
| 502 | } |
| 503 | |
| 504 | // overall aggs required here for proper time averaging |
| 505 | pair = overall_cumulations.get(stat.getKey()); |
| 506 | if (pair == null) { |
| 507 | pair = new Pair<Long, Long>(0L, Long.MIN_VALUE); |
| 508 | overall_cumulations.put(stat.getKey(), pair); |
| 509 | } |
| 510 | pair.setKey(pair.getKey() + stat.getValue()); |
| 511 | if (stat.getValue() > pair.getValue()) { |
| 512 | pair.setValue(stat.getValue()); |
| 513 | } |
| 514 | } else { |
| 515 | // only add counters for the per query maps as they'll be rolled |
| 516 | // up below into the overall |
| 517 | updateStat(query_index, stat.getKey(), stat.getValue()); |
| 518 | } |
| 519 | } |
| 520 | } |
| 521 | |
| 522 | // per query aggs |
| 523 | for (final Entry<QueryStat, Pair<Long, Long>> cumulation : |
| 524 | cumulations.entrySet()) { |
| 525 | // names can't be null as we validate above that it exists |
| 526 | final Pair<QueryStat, QueryStat> names = AGG_MAP.get(cumulation.getKey()); |
| 527 | addStat(query_index, names.getKey(), |
no test coverage detected