Search in sources :

Example 31 with TypeOperators

use of io.trino.spi.type.TypeOperators in project trino by trinodb.

the class TestHashJoinOperator method setUp.

@BeforeMethod
public void setUp() {
    // Before/AfterMethod is chosen here because the executor needs to be shutdown
    // after every single test case to terminate outstanding threads, if any.
    // The line below is the same as newCachedThreadPool(daemonThreadsNamed(...)) except RejectionExecutionHandler.
    // RejectionExecutionHandler is set to DiscardPolicy (instead of the default AbortPolicy) here.
    // Otherwise, a large number of RejectedExecutionException will flood logging, resulting in Travis failure.
    executor = new ThreadPoolExecutor(0, Integer.MAX_VALUE, 60L, SECONDS, new SynchronousQueue<>(), daemonThreadsNamed("test-executor-%s"), new ThreadPoolExecutor.DiscardPolicy());
    scheduledExecutor = newScheduledThreadPool(2, daemonThreadsNamed(getClass().getSimpleName() + "-scheduledExecutor-%s"));
    NodeScheduler nodeScheduler = new NodeScheduler(new UniformNodeSelectorFactory(new InMemoryNodeManager(), new NodeSchedulerConfig().setIncludeCoordinator(true), new NodeTaskMap(new FinalizerService())));
    nodePartitioningManager = new NodePartitioningManager(nodeScheduler, new BlockTypeOperators(new TypeOperators()));
}
Also used : BlockTypeOperators(io.trino.type.BlockTypeOperators) NodeTaskMap(io.trino.execution.NodeTaskMap) FinalizerService(io.trino.util.FinalizerService) UniformNodeSelectorFactory(io.trino.execution.scheduler.UniformNodeSelectorFactory) SynchronousQueue(java.util.concurrent.SynchronousQueue) NodeScheduler(io.trino.execution.scheduler.NodeScheduler) NodeSchedulerConfig(io.trino.execution.scheduler.NodeSchedulerConfig) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) NodePartitioningManager(io.trino.sql.planner.NodePartitioningManager) InMemoryNodeManager(io.trino.metadata.InMemoryNodeManager) TypeOperators(io.trino.spi.type.TypeOperators) BlockTypeOperators(io.trino.type.BlockTypeOperators) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 32 with TypeOperators

use of io.trino.spi.type.TypeOperators in project trino by trinodb.

the class TestValueStore method setUp.

@BeforeMethod(alwaysRun = true)
public void setUp() {
    VarcharType type = VarcharType.createVarcharType(100);
    BlockTypeOperators blockTypeOperators = new BlockTypeOperators(new TypeOperators());
    BlockPositionEqual equalOperator = blockTypeOperators.getEqualOperator(type);
    hashCodeOperator = blockTypeOperators.getHashCodeOperator(type);
    BlockBuilder blockBuilder = type.createBlockBuilder(null, 100, 10);
    valueStore = new ValueStore(type, equalOperator, 100, blockBuilder);
    valueStoreSmall = new ValueStore(type, equalOperator, 1, blockBuilder);
    block = BlockAssertions.createStringsBlock("a", "b", "c", "d");
}
Also used : BlockPositionEqual(io.trino.type.BlockTypeOperators.BlockPositionEqual) BlockTypeOperators(io.trino.type.BlockTypeOperators) VarcharType(io.trino.spi.type.VarcharType) BlockTypeOperators(io.trino.type.BlockTypeOperators) TypeOperators(io.trino.spi.type.TypeOperators) BlockBuilder(io.trino.spi.block.BlockBuilder) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 33 with TypeOperators

use of io.trino.spi.type.TypeOperators in project trino by trinodb.

the class TestMergeOperator method setUp.

@BeforeMethod
public void setUp() {
    executor = newSingleThreadScheduledExecutor(daemonThreadsNamed("test-merge-operator-%s"));
    serdeFactory = new TestingPagesSerdeFactory();
    taskBuffers = buildNonEvictableCache(CacheBuilder.newBuilder(), CacheLoader.from(TestingTaskBuffer::new));
    httpClient = new TestingHttpClient(new TestingExchangeHttpClientHandler(taskBuffers), executor);
    exchangeClientFactory = new DirectExchangeClientFactory(new NodeInfo("test"), new FeaturesConfig(), new DirectExchangeClientConfig(), httpClient, executor, new ExchangeManagerRegistry(new ExchangeHandleResolver()));
    orderingCompiler = new OrderingCompiler(new TypeOperators());
}
Also used : TestingPagesSerdeFactory(io.trino.execution.buffer.TestingPagesSerdeFactory) NodeInfo(io.airlift.node.NodeInfo) FeaturesConfig(io.trino.FeaturesConfig) TestingHttpClient(io.airlift.http.client.testing.TestingHttpClient) OrderingCompiler(io.trino.sql.gen.OrderingCompiler) ExchangeManagerRegistry(io.trino.exchange.ExchangeManagerRegistry) ExchangeHandleResolver(io.trino.metadata.ExchangeHandleResolver) TypeOperators(io.trino.spi.type.TypeOperators) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 34 with TypeOperators

use of io.trino.spi.type.TypeOperators in project trino by trinodb.

the class TestHashSemiJoinOperator method setUp.

@BeforeMethod
public void setUp() {
    executor = newCachedThreadPool(daemonThreadsNamed(getClass().getSimpleName() + "-%s"));
    scheduledExecutor = newScheduledThreadPool(2, daemonThreadsNamed(getClass().getSimpleName() + "-scheduledExecutor-%s"));
    taskContext = createTaskContext(executor, scheduledExecutor, TEST_SESSION);
    typeOperators = new TypeOperators();
    blockTypeOperators = new BlockTypeOperators(typeOperators);
}
Also used : BlockTypeOperators(io.trino.type.BlockTypeOperators) TypeOperators(io.trino.spi.type.TypeOperators) BlockTypeOperators(io.trino.type.BlockTypeOperators) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 35 with TypeOperators

use of io.trino.spi.type.TypeOperators in project trino by trinodb.

the class TestGroupedTopNRankBuilder method testSingleGroupTopN.

@Test(dataProvider = "produceRanking")
public void testSingleGroupTopN(boolean produceRanking) {
    TypeOperators typeOperators = new TypeOperators();
    BlockTypeOperators blockTypeOperators = new BlockTypeOperators(typeOperators);
    List<Type> types = ImmutableList.of(DOUBLE);
    GroupedTopNBuilder groupedTopNBuilder = new GroupedTopNRankBuilder(types, new SimplePageWithPositionComparator(types, ImmutableList.of(0), ImmutableList.of(ASC_NULLS_LAST), typeOperators), new SimplePageWithPositionEqualsAndHash(types, ImmutableList.of(0), blockTypeOperators), 3, produceRanking, new NoChannelGroupByHash());
    // Expected effect: [0.2 x 1 => rank=1, 0.3 x 2 => rank=2]
    assertTrue(groupedTopNBuilder.processPage(rowPageBuilder(types).row(0.3).row(0.3).row(0.2).build()).process());
    // Page should be dropped, because single value 0.4 is too large to be considered
    assertTrue(groupedTopNBuilder.processPage(rowPageBuilder(types).row(0.4).build()).process());
    // Next page should cause 0.3 values to be evicted (first page will be compacted)
    // Expected effect: [0.1 x 2 => rank 1, 0.2 x 3 => rank 3]
    assertTrue(groupedTopNBuilder.processPage(rowPageBuilder(types).row(0.1).row(0.2).row(0.3).row(0.2).row(0.1).build()).process());
    List<Page> output = ImmutableList.copyOf(groupedTopNBuilder.buildResult());
    assertEquals(output.size(), 1);
    List<Type> outputTypes = ImmutableList.of(DOUBLE, BIGINT);
    Page expected = rowPageBuilder(outputTypes).row(0.1, 1).row(0.1, 1).row(0.2, 3).row(0.2, 3).row(0.2, 3).build();
    if (!produceRanking) {
        outputTypes = outputTypes.subList(0, outputTypes.size() - 1);
        expected = dropLastColumn(expected);
    }
    assertPageEquals(outputTypes, getOnlyElement(output), expected);
}
Also used : Type(io.trino.spi.type.Type) BlockTypeOperators(io.trino.type.BlockTypeOperators) Page(io.trino.spi.Page) TypeOperators(io.trino.spi.type.TypeOperators) BlockTypeOperators(io.trino.type.BlockTypeOperators) Test(org.testng.annotations.Test)

Aggregations

TypeOperators (io.trino.spi.type.TypeOperators)37 BlockTypeOperators (io.trino.type.BlockTypeOperators)23 Test (org.testng.annotations.Test)18 MapType (io.trino.spi.type.MapType)10 Type (io.trino.spi.type.Type)9 BeforeMethod (org.testng.annotations.BeforeMethod)9 Page (io.trino.spi.Page)8 JoinCompiler (io.trino.sql.gen.JoinCompiler)6 PlanNodeId (io.trino.sql.planner.plan.PlanNodeId)6 ImmutableList (com.google.common.collect.ImmutableList)4 FeaturesConfig (io.trino.FeaturesConfig)4 Driver (io.trino.operator.Driver)3 DriverFactory (io.trino.operator.DriverFactory)3 GroupByHashPageIndexerFactory (io.trino.operator.GroupByHashPageIndexerFactory)3 OperatorFactory (io.trino.operator.OperatorFactory)3 PagesIndex (io.trino.operator.PagesIndex)3 HashBuilderOperatorFactory (io.trino.operator.join.HashBuilderOperator.HashBuilderOperatorFactory)3 PartitionedLookupSourceFactory (io.trino.operator.join.PartitionedLookupSourceFactory)3 Block (io.trino.spi.block.Block)3 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)2