Search in sources :

Example 1 with ExceededMemoryLimitException

use of io.prestosql.ExceededMemoryLimitException in project hetu-core by openlookeng.

the class TestTopNOperator method testExceedMemoryLimit.

@Test
public void testExceedMemoryLimit() throws Exception {
    List<Page> input = rowPagesBuilder(BIGINT).row(1L).build();
    DriverContext smallDiverContext = createTaskContext(executor, scheduledExecutor, TEST_SESSION, new DataSize(1, BYTE)).addPipelineContext(0, true, true, false).addDriverContext();
    OperatorFactory operatorFactory = topNOperatorFactory(ImmutableList.of(BIGINT), 100, ImmutableList.of(0), ImmutableList.of(ASC_NULLS_LAST));
    try (Operator operator = operatorFactory.createOperator(smallDiverContext)) {
        operator.addInput(input.get(0));
        operator.getOutput();
        fail("must fail because of exceeding local memory limit");
    } catch (ExceededMemoryLimitException ignore) {
    // the exception could be ignored
    }
}
Also used : TopNOperatorFactory(io.prestosql.operator.TopNOperator.TopNOperatorFactory) DataSize(io.airlift.units.DataSize) Page(io.prestosql.spi.Page) ExceededMemoryLimitException(io.prestosql.ExceededMemoryLimitException) Test(org.testng.annotations.Test)

Example 2 with ExceededMemoryLimitException

use of io.prestosql.ExceededMemoryLimitException in project hetu-core by openlookeng.

the class TestMemoryTracking method testLocalTotalMemoryLimitExceeded.

@Test
public void testLocalTotalMemoryLimitExceeded() {
    LocalMemoryContext systemMemoryContext = operatorContext.newLocalSystemMemoryContext("test");
    systemMemoryContext.setBytes(100);
    assertOperatorMemoryAllocations(operatorContext.getOperatorMemoryContext(), 0, 100, 0);
    systemMemoryContext.setBytes(queryMaxTotalMemory.toBytes());
    assertOperatorMemoryAllocations(operatorContext.getOperatorMemoryContext(), 0, queryMaxTotalMemory.toBytes(), 0);
    try {
        systemMemoryContext.setBytes(queryMaxTotalMemory.toBytes() + 1);
        fail("allocation should hit the per-node total memory limit");
    } catch (ExceededMemoryLimitException e) {
        assertEquals(e.getMessage(), format("Query exceeded per-node total memory limit of %1$s [Allocated: %1$s, Delta: 1B, Top Consumers: {test=%1$s}]", queryMaxTotalMemory));
    }
}
Also used : LocalMemoryContext(io.prestosql.memory.context.LocalMemoryContext) ExceededMemoryLimitException(io.prestosql.ExceededMemoryLimitException) Test(org.testng.annotations.Test)

Aggregations

ExceededMemoryLimitException (io.prestosql.ExceededMemoryLimitException)2 Test (org.testng.annotations.Test)2 DataSize (io.airlift.units.DataSize)1 LocalMemoryContext (io.prestosql.memory.context.LocalMemoryContext)1 TopNOperatorFactory (io.prestosql.operator.TopNOperator.TopNOperatorFactory)1 Page (io.prestosql.spi.Page)1