use of com.facebook.presto.operator.TopNOperator.TopNOperatorFactory in project presto by prestodb.
the class TestTopNOperator method testPartialMemoryFull.
@Test
public void testPartialMemoryFull() throws Exception {
List<Page> input = rowPagesBuilder(BIGINT).row(1L).pageBreak().row(2L).build();
DriverContext smallDiverContext = createTaskContext(executor, TEST_SESSION, new DataSize(1, BYTE)).addPipelineContext(0, true, true).addDriverContext();
TopNOperatorFactory operatorFactory = new TopNOperatorFactory(0, new PlanNodeId("test"), ImmutableList.of(BIGINT), 100, ImmutableList.of(0), ImmutableList.of(ASC_NULLS_LAST), true, new DataSize(0, MEGABYTE));
MaterializedResult expected = resultBuilder(driverContext.getSession(), BIGINT).row(1L).row(2L).build();
assertOperatorEquals(operatorFactory, smallDiverContext, input, expected);
}
use of com.facebook.presto.operator.TopNOperator.TopNOperatorFactory in project presto by prestodb.
the class Top100Benchmark method createOperatorFactories.
@Override
protected List<? extends OperatorFactory> createOperatorFactories() {
List<Type> tableScanTypes = getColumnTypes("orders", "totalprice");
OperatorFactory tableScanOperator = createTableScanOperator(0, new PlanNodeId("test"), "orders", "totalprice");
TopNOperatorFactory topNOperator = new TopNOperatorFactory(1, new PlanNodeId("test"), tableScanTypes, 100, ImmutableList.of(0), ImmutableList.of(ASC_NULLS_LAST));
return ImmutableList.of(tableScanOperator, topNOperator);
}
use of com.facebook.presto.operator.TopNOperator.TopNOperatorFactory in project presto by prestodb.
the class TestTopNOperator method testSingleFieldKey.
@Test
public void testSingleFieldKey() {
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(DESC_NULLS_LAST));
MaterializedResult expected = resultBuilder(driverContext.getSession(), BIGINT, DOUBLE).row(6L, 0.6).row(5L, 0.5).build();
assertOperatorEquals(operatorFactory, driverContext, input, expected);
}
use of com.facebook.presto.operator.TopNOperator.TopNOperatorFactory in project presto by prestodb.
the class TestTopNOperator method testLimitZero.
@Test
public void testLimitZero() throws Exception {
List<Page> input = rowPagesBuilder(BIGINT).row(1L).build();
TopNOperatorFactory factory = new TopNOperatorFactory(0, new PlanNodeId("test"), ImmutableList.of(BIGINT), 0, ImmutableList.of(0), ImmutableList.of(DESC_NULLS_LAST));
try (Operator operator = factory.createOperator(driverContext)) {
assertEquals(operator.isFinished(), true);
assertEquals(operator.needsInput(), false);
assertEquals(operator.getOutput(), null);
}
}
use of com.facebook.presto.operator.TopNOperator.TopNOperatorFactory in project presto by prestodb.
the class TestTopNOperator method testMultiFieldKey.
@Test
public void testMultiFieldKey() {
List<Page> input = rowPagesBuilder(VARCHAR, BIGINT).row("a", 1L).row("b", 2L).pageBreak().row("f", 3L).row("a", 4L).pageBreak().row("d", 5L).row("d", 7L).row("e", 6L).build();
TopNOperatorFactory operatorFactory = new TopNOperatorFactory(0, new PlanNodeId("test"), ImmutableList.of(VARCHAR, BIGINT), 3, ImmutableList.of(0, 1), ImmutableList.of(DESC_NULLS_LAST, DESC_NULLS_LAST));
MaterializedResult expected = MaterializedResult.resultBuilder(driverContext.getSession(), VARCHAR, BIGINT).row("f", 3L).row("e", 6L).row("d", 7L).build();
assertOperatorEquals(operatorFactory, driverContext, input, expected);
}
Aggregations