use of io.trino.sql.gen.OrderingCompiler in project trino by trinodb.
the class TestOrderByOperator method testReverseOrder.
@Test(dataProvider = "spillEnabled")
public void testReverseOrder(boolean spillEnabled, boolean revokeMemoryWhenAddingPages, long memoryLimit) {
List<Page> input = rowPagesBuilder(BIGINT, DOUBLE).row(1L, 0.1).row(2L, 0.2).pageBreak().row(-1L, -0.1).row(4L, 0.4).build();
OrderByOperatorFactory operatorFactory = new OrderByOperatorFactory(0, new PlanNodeId("test"), ImmutableList.of(BIGINT, DOUBLE), ImmutableList.of(0), 10, ImmutableList.of(0), ImmutableList.of(DESC_NULLS_LAST), new PagesIndex.TestingFactory(false), spillEnabled, Optional.of(spillerFactory), new OrderingCompiler(typeOperators));
DriverContext driverContext = createDriverContext(memoryLimit);
MaterializedResult expected = resultBuilder(driverContext.getSession(), BIGINT).row(4L).row(2L).row(1L).row(-1L).build();
assertOperatorEquals(operatorFactory, driverContext, input, expected, revokeMemoryWhenAddingPages);
}
use of io.trino.sql.gen.OrderingCompiler in project trino by trinodb.
the class TestOrderByOperator method testMultiFieldKey.
@Test(dataProvider = "spillEnabled")
public void testMultiFieldKey(boolean spillEnabled, boolean revokeMemoryWhenAddingPages, long memoryLimit) {
List<Page> input = rowPagesBuilder(VARCHAR, BIGINT).row("a", 1L).row("b", 2L).pageBreak().row("b", 3L).row("a", 4L).build();
OrderByOperatorFactory operatorFactory = new OrderByOperatorFactory(0, new PlanNodeId("test"), ImmutableList.of(VARCHAR, BIGINT), ImmutableList.of(0, 1), 10, ImmutableList.of(0, 1), ImmutableList.of(ASC_NULLS_LAST, DESC_NULLS_LAST), new PagesIndex.TestingFactory(false), spillEnabled, Optional.of(spillerFactory), new OrderingCompiler(typeOperators));
DriverContext driverContext = createDriverContext(memoryLimit);
MaterializedResult expected = MaterializedResult.resultBuilder(driverContext.getSession(), VARCHAR, BIGINT).row("a", 4L).row("a", 1L).row("b", 3L).row("b", 2L).build();
assertOperatorEquals(operatorFactory, driverContext, input, expected, revokeMemoryWhenAddingPages);
}
use of io.trino.sql.gen.OrderingCompiler in project trino by trinodb.
the class TestOrderByOperator method testSingleFieldKey.
@Test(dataProvider = "spillEnabled")
public void testSingleFieldKey(boolean spillEnabled, boolean revokeMemoryWhenAddingPages, long memoryLimit) {
List<Page> input = rowPagesBuilder(BIGINT, DOUBLE).row(1L, 0.1).row(2L, 0.2).pageBreak().row(-1L, -0.1).row(4L, 0.4).build();
OrderByOperatorFactory operatorFactory = new OrderByOperatorFactory(0, new PlanNodeId("test"), ImmutableList.of(BIGINT, DOUBLE), ImmutableList.of(1), 10, ImmutableList.of(0), ImmutableList.of(ASC_NULLS_LAST), new PagesIndex.TestingFactory(false), spillEnabled, Optional.of(spillerFactory), new OrderingCompiler(typeOperators));
DriverContext driverContext = createDriverContext(memoryLimit);
MaterializedResult expected = resultBuilder(driverContext.getSession(), DOUBLE).row(-0.1).row(0.1).row(0.2).row(0.4).build();
assertOperatorEquals(operatorFactory, driverContext, input, expected, revokeMemoryWhenAddingPages);
}
use of io.trino.sql.gen.OrderingCompiler in project trino by trinodb.
the class OrderByBenchmark method createOperatorFactories.
@Override
protected List<? extends OperatorFactory> createOperatorFactories() {
List<Type> tableScanTypes = getColumnTypes("orders", "totalprice", "clerk");
OperatorFactory tableScanOperator = createTableScanOperator(0, new PlanNodeId("test"), "orders", "totalprice", "clerk");
LimitOperatorFactory limitOperator = new LimitOperatorFactory(1, new PlanNodeId("test"), ROWS);
OrderByOperatorFactory orderByOperator = new OrderByOperatorFactory(2, new PlanNodeId("test"), tableScanTypes, ImmutableList.of(1), ROWS, ImmutableList.of(0), ImmutableList.of(ASC_NULLS_LAST), new PagesIndex.TestingFactory(false), false, Optional.empty(), new OrderingCompiler(localQueryRunner.getTypeOperators()));
return ImmutableList.of(tableScanOperator, limitOperator, orderByOperator);
}
Aggregations