Search in sources :

Example 6 with TopNOperatorFactory

use of com.facebook.presto.operator.TopNOperator.TopNOperatorFactory in project presto by prestodb.

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();
    TopNOperatorFactory operatorFactory = new TopNOperatorFactory(0, new PlanNodeId("test"), ImmutableList.of(BIGINT), 100, ImmutableList.of(0), ImmutableList.of(ASC_NULLS_LAST));
    try (Operator operator = operatorFactory.createOperator(smallDiverContext)) {
        operator.addInput(input.get(0));
        fail("must fail because of exceeding local memory limit");
    } catch (ExceededMemoryLimitException ignore) {
    }
}
Also used : PlanNodeId(com.facebook.presto.spi.plan.PlanNodeId) TopNOperatorFactory(com.facebook.presto.operator.TopNOperator.TopNOperatorFactory) DataSize(io.airlift.units.DataSize) Page(com.facebook.presto.common.Page) ExceededMemoryLimitException(com.facebook.presto.ExceededMemoryLimitException) Test(org.testng.annotations.Test)

Example 7 with TopNOperatorFactory

use of com.facebook.presto.operator.TopNOperator.TopNOperatorFactory in project presto by prestodb.

the class TestTopNOperator method testReverseOrder.

@Test
public void testReverseOrder() {
    List<Page> input = rowPagesBuilder(BIGINT, DOUBLE).row(1L, 0.1).row(2L, 0.2).pageBreak().row(-1L, -0.1).row(4L, 0.4).pageBreak().row(5L, 0.5).row(4L, 0.41).row(6L, 0.6).pageBreak().build();
    TopNOperatorFactory operatorFactory = new TopNOperatorFactory(0, new PlanNodeId("test"), ImmutableList.of(BIGINT, DOUBLE), 2, ImmutableList.of(0), ImmutableList.of(ASC_NULLS_LAST));
    MaterializedResult expected = resultBuilder(driverContext.getSession(), BIGINT, DOUBLE).row(-1L, -0.1).row(1L, 0.1).build();
    assertOperatorEquals(operatorFactory, driverContext, input, expected);
}
Also used : PlanNodeId(com.facebook.presto.spi.plan.PlanNodeId) TopNOperatorFactory(com.facebook.presto.operator.TopNOperator.TopNOperatorFactory) Page(com.facebook.presto.common.Page) MaterializedResult(com.facebook.presto.testing.MaterializedResult) Test(org.testng.annotations.Test)

Aggregations

TopNOperatorFactory (com.facebook.presto.operator.TopNOperator.TopNOperatorFactory)7 PlanNodeId (com.facebook.presto.spi.plan.PlanNodeId)6 Test (org.testng.annotations.Test)6 Page (com.facebook.presto.common.Page)5 MaterializedResult (com.facebook.presto.testing.MaterializedResult)4 DataSize (io.airlift.units.DataSize)2 ExceededMemoryLimitException (com.facebook.presto.ExceededMemoryLimitException)1 Type (com.facebook.presto.common.type.Type)1 OperatorFactory (com.facebook.presto.operator.OperatorFactory)1 Page (com.facebook.presto.spi.Page)1 PlanNodeId (com.facebook.presto.sql.planner.plan.PlanNodeId)1