Search in sources :

Example 6 with OrderingCompiler

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);
}
Also used : PlanNodeId(io.trino.sql.planner.plan.PlanNodeId) OrderByOperatorFactory(io.trino.operator.OrderByOperator.OrderByOperatorFactory) OrderingCompiler(io.trino.sql.gen.OrderingCompiler) Page(io.trino.spi.Page) MaterializedResult(io.trino.testing.MaterializedResult) OperatorAssertion.toMaterializedResult(io.trino.operator.OperatorAssertion.toMaterializedResult) Test(org.testng.annotations.Test)

Example 7 with OrderingCompiler

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);
}
Also used : PlanNodeId(io.trino.sql.planner.plan.PlanNodeId) OrderByOperatorFactory(io.trino.operator.OrderByOperator.OrderByOperatorFactory) OrderingCompiler(io.trino.sql.gen.OrderingCompiler) Page(io.trino.spi.Page) MaterializedResult(io.trino.testing.MaterializedResult) OperatorAssertion.toMaterializedResult(io.trino.operator.OperatorAssertion.toMaterializedResult) Test(org.testng.annotations.Test)

Example 8 with OrderingCompiler

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);
}
Also used : PlanNodeId(io.trino.sql.planner.plan.PlanNodeId) OrderByOperatorFactory(io.trino.operator.OrderByOperator.OrderByOperatorFactory) OrderingCompiler(io.trino.sql.gen.OrderingCompiler) Page(io.trino.spi.Page) MaterializedResult(io.trino.testing.MaterializedResult) OperatorAssertion.toMaterializedResult(io.trino.operator.OperatorAssertion.toMaterializedResult) Test(org.testng.annotations.Test)

Example 9 with OrderingCompiler

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);
}
Also used : PlanNodeId(io.trino.sql.planner.plan.PlanNodeId) Type(io.trino.spi.type.Type) LimitOperatorFactory(io.trino.operator.LimitOperator.LimitOperatorFactory) OrderByOperatorFactory(io.trino.operator.OrderByOperator.OrderByOperatorFactory) LimitOperatorFactory(io.trino.operator.LimitOperator.LimitOperatorFactory) OperatorFactory(io.trino.operator.OperatorFactory) OrderByOperatorFactory(io.trino.operator.OrderByOperator.OrderByOperatorFactory) OrderingCompiler(io.trino.sql.gen.OrderingCompiler) PagesIndex(io.trino.operator.PagesIndex)

Aggregations

OrderingCompiler (io.trino.sql.gen.OrderingCompiler)9 PlanNodeId (io.trino.sql.planner.plan.PlanNodeId)8 OrderByOperatorFactory (io.trino.operator.OrderByOperator.OrderByOperatorFactory)6 Page (io.trino.spi.Page)5 Test (org.testng.annotations.Test)5 OperatorAssertion.toMaterializedResult (io.trino.operator.OperatorAssertion.toMaterializedResult)4 PagesIndex (io.trino.operator.PagesIndex)3 MaterializedResult (io.trino.testing.MaterializedResult)3 ExchangeManagerRegistry (io.trino.exchange.ExchangeManagerRegistry)2 ExchangeHandleResolver (io.trino.metadata.ExchangeHandleResolver)2 Split (io.trino.metadata.Split)2 IndexJoinLookupStats (io.trino.operator.index.IndexJoinLookupStats)2 LocalExecutionPlanner (io.trino.sql.planner.LocalExecutionPlanner)2 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 TestingHttpClient (io.airlift.http.client.testing.TestingHttpClient)1 ObjectMapperProvider (io.airlift.json.ObjectMapperProvider)1 NodeInfo (io.airlift.node.NodeInfo)1 ExceededMemoryLimitException (io.trino.ExceededMemoryLimitException)1