Search in sources :

Example 1 with Metric

use of io.trino.spi.metrics.Metric in project trino by trinodb.

the class TestMetrics method testMergeCount.

@Test
public void testMergeCount() {
    Metrics m1 = new Metrics(ImmutableMap.of("a", new LongCount(1), "b", new LongCount(2)));
    Metrics m2 = new Metrics(ImmutableMap.of("b", new LongCount(3), "c", new LongCount(4)));
    Metrics merged = merge(m1, m2);
    Map<String, Metric<?>> expectedMap = ImmutableMap.of("a", new LongCount(1), "b", new LongCount(5), "c", new LongCount(4));
    assertThat(merged.getMetrics()).isEqualTo(expectedMap);
}
Also used : Metrics(io.trino.spi.metrics.Metrics) Metric(io.trino.spi.metrics.Metric) Test(org.testng.annotations.Test)

Example 2 with Metric

use of io.trino.spi.metrics.Metric in project trino by trinodb.

the class TextRenderer method printMetrics.

private void printMetrics(StringBuilder output, String label, Function<BasicOperatorStats, Metrics> metricsGetter, PlanNodeStats stats) {
    if (!verbose) {
        return;
    }
    Map<String, String> translatedOperatorTypes = translateOperatorTypes(stats.getOperatorTypes());
    for (String operator : translatedOperatorTypes.keySet()) {
        String translatedOperatorType = translatedOperatorTypes.get(operator);
        Metrics metrics = metricsGetter.apply(stats.getOperatorStats().get(operator));
        if (metrics.getMetrics().isEmpty()) {
            continue;
        }
        output.append(translatedOperatorType + label).append("\n");
        Map<String, Metric<?>> sortedMap = new TreeMap<>(metrics.getMetrics());
        sortedMap.forEach((name, metric) -> output.append(format("  '%s' = %s\n", name, metric)));
    }
}
Also used : Metrics(io.trino.spi.metrics.Metrics) Metric(io.trino.spi.metrics.Metric) TreeMap(java.util.TreeMap)

Aggregations

Metric (io.trino.spi.metrics.Metric)2 Metrics (io.trino.spi.metrics.Metrics)2 TreeMap (java.util.TreeMap)1 Test (org.testng.annotations.Test)1