Search in sources :

Example 6 with LongCount

use of io.trino.plugin.base.metrics.LongCount in project trino by trinodb.

the class TestOperatorStats method assertExpectedOperatorStats.

public static void assertExpectedOperatorStats(OperatorStats actual) {
    assertEquals(actual.getStageId(), 0);
    assertEquals(actual.getOperatorId(), 41);
    assertEquals(actual.getOperatorType(), "test");
    assertEquals(actual.getTotalDrivers(), 1);
    assertEquals(actual.getAddInputCalls(), 2);
    assertEquals(actual.getAddInputWall(), new Duration(3, NANOSECONDS));
    assertEquals(actual.getAddInputCpu(), new Duration(4, NANOSECONDS));
    assertEquals(actual.getPhysicalInputDataSize(), DataSize.ofBytes(51));
    assertEquals(actual.getPhysicalInputPositions(), 511);
    assertEquals(actual.getInternalNetworkInputDataSize(), DataSize.ofBytes(52));
    assertEquals(actual.getInternalNetworkInputPositions(), 522);
    assertEquals(actual.getRawInputDataSize(), DataSize.ofBytes(5));
    assertEquals(actual.getInputDataSize(), DataSize.ofBytes(6));
    assertEquals(actual.getInputPositions(), 7);
    assertEquals(actual.getSumSquaredInputPositions(), 8.0);
    assertEquals(actual.getGetOutputCalls(), 9);
    assertEquals(actual.getGetOutputWall(), new Duration(10, NANOSECONDS));
    assertEquals(actual.getGetOutputCpu(), new Duration(11, NANOSECONDS));
    assertEquals(actual.getOutputDataSize(), DataSize.ofBytes(12));
    assertEquals(actual.getOutputPositions(), 13);
    assertEquals(actual.getDynamicFilterSplitsProcessed(), 533);
    assertEquals(actual.getMetrics().getMetrics(), ImmutableMap.of("metrics", new LongCount(42)));
    assertEquals(actual.getConnectorMetrics().getMetrics(), ImmutableMap.of("connectorMetrics", new LongCount(43)));
    assertEquals(actual.getPhysicalWrittenDataSize(), DataSize.ofBytes(14));
    assertEquals(actual.getBlockedWall(), new Duration(15, NANOSECONDS));
    assertEquals(actual.getFinishCalls(), 16);
    assertEquals(actual.getFinishWall(), new Duration(17, NANOSECONDS));
    assertEquals(actual.getFinishCpu(), new Duration(18, NANOSECONDS));
    assertEquals(actual.getUserMemoryReservation(), DataSize.ofBytes(19));
    assertEquals(actual.getRevocableMemoryReservation(), DataSize.ofBytes(20));
    assertEquals(actual.getPeakUserMemoryReservation(), DataSize.ofBytes(22));
    assertEquals(actual.getPeakRevocableMemoryReservation(), DataSize.ofBytes(24));
    assertEquals(actual.getPeakTotalMemoryReservation(), DataSize.ofBytes(25));
    assertEquals(actual.getSpilledDataSize(), DataSize.ofBytes(26));
    assertEquals(actual.getInfo().getClass(), SplitOperatorInfo.class);
    assertEquals(((SplitOperatorInfo) actual.getInfo()).getSplitInfo(), NON_MERGEABLE_INFO.getSplitInfo());
}
Also used : Duration(io.airlift.units.Duration) LongCount(io.trino.plugin.base.metrics.LongCount)

Example 7 with LongCount

use of io.trino.plugin.base.metrics.LongCount in project trino by trinodb.

the class TestOperatorStats method testAddMergeable.

@Test
public void testAddMergeable() {
    OperatorStats actual = MERGEABLE.add(ImmutableList.of(MERGEABLE, MERGEABLE));
    assertEquals(actual.getStageId(), 0);
    assertEquals(actual.getOperatorId(), 41);
    assertEquals(actual.getOperatorType(), "test");
    assertEquals(actual.getTotalDrivers(), 3 * 1);
    assertEquals(actual.getAddInputCalls(), 3 * 2);
    assertEquals(actual.getAddInputWall(), new Duration(3 * 3, NANOSECONDS));
    assertEquals(actual.getAddInputCpu(), new Duration(3 * 4, NANOSECONDS));
    assertEquals(actual.getPhysicalInputDataSize(), DataSize.ofBytes(3 * 51));
    assertEquals(actual.getPhysicalInputPositions(), 3 * 511);
    assertEquals(actual.getInternalNetworkInputDataSize(), DataSize.ofBytes(3 * 52));
    assertEquals(actual.getInternalNetworkInputPositions(), 3 * 522);
    assertEquals(actual.getRawInputDataSize(), DataSize.ofBytes(3 * 5));
    assertEquals(actual.getInputDataSize(), DataSize.ofBytes(3 * 6));
    assertEquals(actual.getInputPositions(), 3 * 7);
    assertEquals(actual.getSumSquaredInputPositions(), 3 * 8.0);
    assertEquals(actual.getGetOutputCalls(), 3 * 9);
    assertEquals(actual.getGetOutputWall(), new Duration(3 * 10, NANOSECONDS));
    assertEquals(actual.getGetOutputCpu(), new Duration(3 * 11, NANOSECONDS));
    assertEquals(actual.getOutputDataSize(), DataSize.ofBytes(3 * 12));
    assertEquals(actual.getOutputPositions(), 3 * 13);
    assertEquals(actual.getDynamicFilterSplitsProcessed(), 3 * 533);
    assertEquals(actual.getMetrics().getMetrics(), ImmutableMap.of("metrics", new LongCount(3 * 42)));
    assertEquals(actual.getConnectorMetrics().getMetrics(), ImmutableMap.of("connectorMetrics", new LongCount(3 * 43)));
    assertEquals(actual.getPhysicalWrittenDataSize(), DataSize.ofBytes(3 * 14));
    assertEquals(actual.getBlockedWall(), new Duration(3 * 15, NANOSECONDS));
    assertEquals(actual.getFinishCalls(), 3 * 16);
    assertEquals(actual.getFinishWall(), new Duration(3 * 17, NANOSECONDS));
    assertEquals(actual.getFinishCpu(), new Duration(3 * 18, NANOSECONDS));
    assertEquals(actual.getUserMemoryReservation(), DataSize.ofBytes(3 * 19));
    assertEquals(actual.getRevocableMemoryReservation(), DataSize.ofBytes(3 * 20));
    assertEquals(actual.getPeakUserMemoryReservation(), DataSize.ofBytes(22));
    assertEquals(actual.getPeakRevocableMemoryReservation(), DataSize.ofBytes(24));
    assertEquals(actual.getPeakTotalMemoryReservation(), DataSize.ofBytes(25));
    assertEquals(actual.getSpilledDataSize(), DataSize.ofBytes(3 * 26));
    assertEquals(actual.getInfo().getClass(), PartitionedOutputInfo.class);
    assertEquals(((PartitionedOutputInfo) actual.getInfo()).getPagesAdded(), 3 * MERGEABLE_INFO.getPagesAdded());
}
Also used : Duration(io.airlift.units.Duration) LongCount(io.trino.plugin.base.metrics.LongCount) Test(org.testng.annotations.Test)

Example 8 with LongCount

use of io.trino.plugin.base.metrics.LongCount in project trino by trinodb.

the class TestMemoryConnectorTest method testCustomMetricsScanOnly.

@Test
@Flaky(issue = "https://github.com/trinodb/trino/issues/8691", match = "ComparisonFailure: expected:<LongCount\\{total=\\[\\d+]}> but was:<(LongCount\\{total=\\[\\d+]}|null)>")
public void testCustomMetricsScanOnly() {
    Metrics metrics = collectCustomMetrics("SELECT partkey FROM part");
    assertThat(metrics.getMetrics().get("rows")).isEqualTo(new LongCount(PART_COUNT));
    assertThat(metrics.getMetrics().get("started")).isEqualTo(metrics.getMetrics().get("finished"));
    assertThat(((Count<?>) metrics.getMetrics().get("finished")).getTotal()).isGreaterThan(0);
}
Also used : Metrics(io.trino.spi.metrics.Metrics) LongCount(io.trino.plugin.base.metrics.LongCount) LongCount(io.trino.plugin.base.metrics.LongCount) Count(io.trino.spi.metrics.Count) Test(org.testng.annotations.Test) BaseConnectorTest(io.trino.testing.BaseConnectorTest) Flaky(io.trino.testng.services.Flaky)

Aggregations

LongCount (io.trino.plugin.base.metrics.LongCount)8 Test (org.testng.annotations.Test)7 Duration (io.airlift.units.Duration)5 DurationTiming (io.trino.plugin.base.metrics.DurationTiming)2 Count (io.trino.spi.metrics.Count)2 Metrics (io.trino.spi.metrics.Metrics)2 BaseConnectorTest (io.trino.testing.BaseConnectorTest)2 Flaky (io.trino.testng.services.Flaky)2 Split (io.trino.metadata.Split)1 AdapterWorkProcessorOperator (io.trino.operator.WorkProcessorOperatorAdapter.AdapterWorkProcessorOperator)1 AdapterWorkProcessorOperatorFactory (io.trino.operator.WorkProcessorOperatorAdapter.AdapterWorkProcessorOperatorFactory)1 WorkProcessorOperatorAdapter.createAdapterOperatorFactory (io.trino.operator.WorkProcessorOperatorAdapter.createAdapterOperatorFactory)1 Page (io.trino.spi.Page)1 OperatorFactoryWithTypes (io.trino.sql.planner.LocalExecutionPlanner.OperatorFactoryWithTypes)1 PlanNodeId (io.trino.sql.planner.plan.PlanNodeId)1 TestingSplit.createLocalSplit (io.trino.testing.TestingSplit.createLocalSplit)1