Search in sources :

Example 1 with Transformation

use of io.trino.operator.WorkProcessor.Transformation in project trino by trinodb.

the class TestWorkProcessorPipelineSourceOperator method testMergePages.

@Test
public void testMergePages() {
    Transformation<Split, Page> sourceOperatorPages = split -> TransformationState.ofResult(createPage(1), false);
    Transformation<Page, Page> firstOperatorPages = page -> TransformationState.ofResult(getOnlyElement(rowPagesBuilder(BIGINT).addSequencePage(1, 0).build()));
    TestWorkProcessorSourceOperatorFactory sourceOperatorFactory = new TestWorkProcessorSourceOperatorFactory(1, new PlanNodeId("1"), sourceOperatorPages);
    TestWorkProcessorOperatorFactory firstOperatorFactory = new TestWorkProcessorOperatorFactory(2, firstOperatorPages);
    SourceOperatorFactory pipelineOperatorFactory = (SourceOperatorFactory) getOnlyElement(WorkProcessorPipelineSourceOperator.convertOperators(ImmutableList.of(new OperatorFactoryWithTypes(sourceOperatorFactory, ImmutableList.of(BIGINT)), new OperatorFactoryWithTypes(firstOperatorFactory, ImmutableList.of(BIGINT))), DataSize.ofBytes(100), 100));
    DriverContext driverContext = TestingOperatorContext.create(scheduledExecutor).getDriverContext();
    SourceOperator pipelineOperator = pipelineOperatorFactory.createOperator(driverContext);
    pipelineOperator.addSplit(createSplit());
    assertTrue(pipelineOperator.getOutput().getPositionCount() > 100);
}
Also used : Transform(io.trino.operator.WorkProcessorAssertion.Transform) MoreExecutors(com.google.common.util.concurrent.MoreExecutors) Assert.assertNull(org.testng.Assert.assertNull) NANOSECONDS(java.util.concurrent.TimeUnit.NANOSECONDS) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Page(io.trino.spi.Page) Assert.assertEquals(org.testng.Assert.assertEquals) Test(org.testng.annotations.Test) Lifespan.taskWide(io.trino.execution.Lifespan.taskWide) SettableFuture(com.google.common.util.concurrent.SettableFuture) MemoryTrackingContext(io.trino.memory.context.MemoryTrackingContext) LongCount(io.trino.plugin.base.metrics.LongCount) Supplier(java.util.function.Supplier) Duration(io.airlift.units.Duration) TransformationState(io.trino.operator.WorkProcessor.TransformationState) CatalogName(io.trino.connector.CatalogName) TestingTaskContext(io.trino.testing.TestingTaskContext) TestingSplit.createLocalSplit(io.trino.testing.TestingSplit.createLocalSplit) Executors.newSingleThreadScheduledExecutor(java.util.concurrent.Executors.newSingleThreadScheduledExecutor) ImmutableList(com.google.common.collect.ImmutableList) Metrics(io.trino.spi.metrics.Metrics) PlanNodeId(io.trino.sql.planner.plan.PlanNodeId) OperatorFactoryWithTypes(io.trino.sql.planner.LocalExecutionPlanner.OperatorFactoryWithTypes) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) TEST_SESSION(io.trino.SessionTestUtils.TEST_SESSION) WorkProcessorAssertion.transformationFrom(io.trino.operator.WorkProcessorAssertion.transformationFrom) RowPagesBuilder.rowPagesBuilder(io.trino.RowPagesBuilder.rowPagesBuilder) Assert.assertFalse(org.testng.Assert.assertFalse) AfterClass(org.testng.annotations.AfterClass) ImmutableMap(com.google.common.collect.ImmutableMap) BeforeClass(org.testng.annotations.BeforeClass) Iterables.getOnlyElement(com.google.common.collect.Iterables.getOnlyElement) DataSize(io.airlift.units.DataSize) List(java.util.List) BIGINT(io.trino.spi.type.BigintType.BIGINT) Split(io.trino.metadata.Split) Transformation(io.trino.operator.WorkProcessor.Transformation) UpdatablePageSource(io.trino.spi.connector.UpdatablePageSource) Optional(java.util.Optional) Assert.assertTrue(org.testng.Assert.assertTrue) DurationTiming(io.trino.plugin.base.metrics.DurationTiming) Session(io.trino.Session) PlanNodeId(io.trino.sql.planner.plan.PlanNodeId) OperatorFactoryWithTypes(io.trino.sql.planner.LocalExecutionPlanner.OperatorFactoryWithTypes) Page(io.trino.spi.Page) TestingSplit.createLocalSplit(io.trino.testing.TestingSplit.createLocalSplit) Split(io.trino.metadata.Split) Test(org.testng.annotations.Test)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 Iterables.getOnlyElement (com.google.common.collect.Iterables.getOnlyElement)1 MoreExecutors (com.google.common.util.concurrent.MoreExecutors)1 SettableFuture (com.google.common.util.concurrent.SettableFuture)1 DataSize (io.airlift.units.DataSize)1 Duration (io.airlift.units.Duration)1 RowPagesBuilder.rowPagesBuilder (io.trino.RowPagesBuilder.rowPagesBuilder)1 Session (io.trino.Session)1 TEST_SESSION (io.trino.SessionTestUtils.TEST_SESSION)1 CatalogName (io.trino.connector.CatalogName)1 Lifespan.taskWide (io.trino.execution.Lifespan.taskWide)1 MemoryTrackingContext (io.trino.memory.context.MemoryTrackingContext)1 Split (io.trino.metadata.Split)1 Transformation (io.trino.operator.WorkProcessor.Transformation)1 TransformationState (io.trino.operator.WorkProcessor.TransformationState)1 Transform (io.trino.operator.WorkProcessorAssertion.Transform)1 WorkProcessorAssertion.transformationFrom (io.trino.operator.WorkProcessorAssertion.transformationFrom)1 DurationTiming (io.trino.plugin.base.metrics.DurationTiming)1 LongCount (io.trino.plugin.base.metrics.LongCount)1