use of io.trino.type.BlockTypeOperators in project trino by trinodb.
the class TestDistinctLimitOperator method setUp.
@BeforeMethod
public void setUp() {
executor = newCachedThreadPool(daemonThreadsNamed(getClass().getSimpleName() + "-%s"));
scheduledExecutor = newScheduledThreadPool(2, daemonThreadsNamed(getClass().getSimpleName() + "-scheduledExecutor-%s"));
driverContext = createTaskContext(executor, scheduledExecutor, TEST_SESSION).addPipelineContext(0, true, true, false).addDriverContext();
TypeOperators typeOperators = new TypeOperators();
blockTypeOperators = new BlockTypeOperators(typeOperators);
joinCompiler = new JoinCompiler(typeOperators);
}
use of io.trino.type.BlockTypeOperators in project trino by trinodb.
the class TestGroupedTopNRankBuilder method testYield.
@Test
public void testYield() {
TypeOperators typeOperators = new TypeOperators();
BlockTypeOperators blockTypeOperators = new BlockTypeOperators(typeOperators);
List<Type> types = ImmutableList.of(BIGINT, DOUBLE);
Page input = rowPagesBuilder(types).row(1L, 0.3).row(1L, 0.2).row(1L, 0.9).row(1L, 0.1).build().get(0);
input.compact();
AtomicBoolean unblock = new AtomicBoolean();
GroupByHash groupByHash = createGroupByHash(ImmutableList.of(types.get(0)), ImmutableList.of(0), unblock::get, typeOperators, blockTypeOperators);
GroupedTopNBuilder groupedTopNBuilder = new GroupedTopNRankBuilder(types, new SimplePageWithPositionComparator(types, ImmutableList.of(1), ImmutableList.of(ASC_NULLS_LAST), typeOperators), new SimplePageWithPositionEqualsAndHash(types, ImmutableList.of(1), blockTypeOperators), 5, false, groupByHash);
Work<?> work = groupedTopNBuilder.processPage(input);
assertFalse(work.process());
assertFalse(work.process());
unblock.set(true);
assertTrue(work.process());
List<Page> output = ImmutableList.copyOf(groupedTopNBuilder.buildResult());
assertEquals(output.size(), 1);
Page expected = rowPagesBuilder(types).row(1L, 0.1).row(1L, 0.2).row(1L, 0.3).row(1L, 0.9).build().get(0);
assertPageEquals(types, output.get(0), expected);
}
use of io.trino.type.BlockTypeOperators in project trino by trinodb.
the class TestGroupedTopNRankBuilder method testMultiGroupTopN.
@Test(dataProvider = "produceRanking")
public void testMultiGroupTopN(boolean produceRanking) {
TypeOperators typeOperators = new TypeOperators();
BlockTypeOperators blockTypeOperators = new BlockTypeOperators(typeOperators);
List<Type> types = ImmutableList.of(BIGINT, DOUBLE);
GroupByHash groupByHash = createGroupByHash(ImmutableList.of(types.get(0)), ImmutableList.of(0), NOOP, typeOperators, blockTypeOperators);
GroupedTopNBuilder groupedTopNBuilder = new GroupedTopNRankBuilder(types, new SimplePageWithPositionComparator(types, ImmutableList.of(1), ImmutableList.of(ASC_NULLS_LAST), typeOperators), new SimplePageWithPositionEqualsAndHash(types, ImmutableList.of(1), blockTypeOperators), 3, produceRanking, groupByHash);
// Expected effect:
// Group 0 [0.2 x 1 => rank=1, 0.3 x 3 => rank=2]
// Group 1 [0.2 x 1 => rank=1]
assertTrue(groupedTopNBuilder.processPage(rowPageBuilder(types).row(0L, 0.3).row(0L, 0.3).row(0L, 0.3).row(0L, 0.2).row(1L, 0.2).build()).process());
// Page should be dropped, because all values too large to be considered
assertTrue(groupedTopNBuilder.processPage(rowPageBuilder(types).row(0L, 0.4).row(1L, 0.4).build()).process());
// Next page should cause evict 0.3 from group 0, which should cause the first page to be compacted
// Expected effect:
// Group 0 [0.1 x 1 => rank=1, 0.2 x 2 => rank=2]
// Group 1 [0.2 x 2 => rank=1, 0.3 x 2 => rank=3]
assertTrue(groupedTopNBuilder.processPage(rowPageBuilder(types).row(0L, 0.1).row(1L, 0.2).row(0L, 0.3).row(0L, 0.2).row(1L, 0.5).row(1L, 0.4).row(1L, 0.3).row(1L, 0.3).build()).process());
List<Page> output = ImmutableList.copyOf(groupedTopNBuilder.buildResult());
assertEquals(output.size(), 1);
List<Type> outputTypes = ImmutableList.of(BIGINT, DOUBLE, BIGINT);
Page expected = rowPageBuilder(outputTypes).row(0, 0.1, 1).row(0, 0.2, 2).row(0, 0.2, 2).row(1, 0.2, 1).row(1, 0.2, 1).row(1, 0.3, 3).row(1, 0.3, 3).build();
if (!produceRanking) {
outputTypes = outputTypes.subList(0, outputTypes.size() - 1);
expected = dropLastColumn(expected);
}
assertPageEquals(outputTypes, getOnlyElement(output), expected);
}
use of io.trino.type.BlockTypeOperators in project trino by trinodb.
the class TestDynamicFilterSourceOperator method setUp.
@BeforeMethod
public void setUp() {
blockTypeOperators = new BlockTypeOperators(new TypeOperators());
executor = newCachedThreadPool(daemonThreadsNamed(getClass().getSimpleName() + "-%s"));
scheduledExecutor = newScheduledThreadPool(2, daemonThreadsNamed(getClass().getSimpleName() + "-scheduledExecutor-%s"));
pipelineContext = createTaskContext(executor, scheduledExecutor, TEST_SESSION).addPipelineContext(0, true, true, false);
partitions = ImmutableList.builder();
}
use of io.trino.type.BlockTypeOperators in project trino by trinodb.
the class TaskTestUtils method createTestingPlanner.
public static LocalExecutionPlanner createTestingPlanner() {
PageSourceManager pageSourceManager = new PageSourceManager();
pageSourceManager.addConnectorPageSourceProvider(CONNECTOR_ID, new TestingPageSourceProvider());
// we don't start the finalizer so nothing will be collected, which is ok for a test
FinalizerService finalizerService = new FinalizerService();
BlockTypeOperators blockTypeOperators = new BlockTypeOperators(PLANNER_CONTEXT.getTypeOperators());
NodeScheduler nodeScheduler = new NodeScheduler(new UniformNodeSelectorFactory(new InMemoryNodeManager(), new NodeSchedulerConfig().setIncludeCoordinator(true), new NodeTaskMap(finalizerService)));
NodePartitioningManager nodePartitioningManager = new NodePartitioningManager(nodeScheduler, blockTypeOperators);
PageFunctionCompiler pageFunctionCompiler = new PageFunctionCompiler(PLANNER_CONTEXT.getFunctionManager(), 0);
return new LocalExecutionPlanner(PLANNER_CONTEXT, createTestingTypeAnalyzer(PLANNER_CONTEXT), Optional.empty(), pageSourceManager, new IndexManager(), nodePartitioningManager, new PageSinkManager(), new MockDirectExchangeClientSupplier(), new ExpressionCompiler(PLANNER_CONTEXT.getFunctionManager(), pageFunctionCompiler), pageFunctionCompiler, new JoinFilterFunctionCompiler(PLANNER_CONTEXT.getFunctionManager()), new IndexJoinLookupStats(), new TaskManagerConfig(), new GenericSpillerFactory((types, spillContext, memoryContext) -> {
throw new UnsupportedOperationException();
}), (types, spillContext, memoryContext) -> {
throw new UnsupportedOperationException();
}, (types, partitionFunction, spillContext, memoryContext) -> {
throw new UnsupportedOperationException();
}, new PagesIndex.TestingFactory(false), new JoinCompiler(PLANNER_CONTEXT.getTypeOperators()), new TrinoOperatorFactories(), new OrderingCompiler(PLANNER_CONTEXT.getTypeOperators()), new DynamicFilterConfig(), blockTypeOperators, new TableExecuteContextManager(), new ExchangeManagerRegistry(new ExchangeHandleResolver()));
}
Aggregations