use of com.facebook.presto.operator.DriverYieldSignal in project presto by prestodb.
the class TestDictionaryAwarePageProjection method testProjectFastReturnIgnoreYield.
private static void testProjectFastReturnIgnoreYield(Block block, DictionaryAwarePageProjection projection) {
DriverYieldSignal yieldSignal = new DriverYieldSignal();
Work<List<Block>> work = projection.project(null, yieldSignal, new Page(block), SelectedPositions.positionsRange(5, 10));
yieldSignal.setWithDelay(1, executor);
yieldSignal.forceYieldForTesting();
// yield signal is ignored given the block has already been loaded
assertTrue(work.process());
Block result = work.getResult().get(0);
yieldSignal.reset();
assertBlockEquals(BIGINT, result, block.getRegion(5, 10));
assertInstanceOf(result, DictionaryBlock.class);
}
use of com.facebook.presto.operator.DriverYieldSignal in project presto by prestodb.
the class TestPageProcessor method testProjectEmptyPage.
@Test
public void testProjectEmptyPage() {
PageProcessor pageProcessor = new PageProcessor(Optional.of(new SelectAllFilter()), ImmutableList.of(createInputPageProjectionWithOutputs(0, BIGINT, 0)));
Page inputPage = new Page(createLongSequenceBlock(0, 0));
LocalMemoryContext memoryContext = newSimpleAggregatedMemoryContext().newLocalMemoryContext(PageProcessor.class.getSimpleName());
Iterator<Optional<Page>> output = pageProcessor.process(SESSION.getSqlFunctionProperties(), new DriverYieldSignal(), memoryContext, inputPage);
assertEquals(memoryContext.getBytes(), 0);
// output should be one page containing no columns (only a count)
List<Optional<Page>> outputPages = ImmutableList.copyOf(output);
assertEquals(outputPages.size(), 0);
}
use of com.facebook.presto.operator.DriverYieldSignal in project presto by prestodb.
the class TestMergeSortedPages method testMergeSortYieldingProgresses.
@Test
public void testMergeSortYieldingProgresses() throws Exception {
DriverYieldSignal yieldSignal = new DriverYieldSignal();
yieldSignal.forceYieldForTesting();
List<Type> types = ImmutableList.of(INTEGER);
WorkProcessor<Page> mergedPages = MergeSortedPages.mergeSortedPages(ImmutableList.of(WorkProcessor.fromIterable(rowPagesBuilder(types).build())), new SimplePageWithPositionComparator(types, ImmutableList.of(0), ImmutableList.of(DESC_NULLS_LAST)), ImmutableList.of(0), types, (pageBuilder, pageWithPosition) -> pageBuilder.isFull(), false, newSimpleAggregatedMemoryContext().newAggregatedMemoryContext(), yieldSignal);
// yield signal is on
assertFalse(mergedPages.process());
// processor finishes computations (yield signal is still on, but previous process() call yielded)
assertTrue(mergedPages.process());
assertTrue(mergedPages.isFinished());
}
use of com.facebook.presto.operator.DriverYieldSignal in project presto by prestodb.
the class TestMergeSortedPages method testSortingYields.
@Test
public void testSortingYields() throws Exception {
DriverYieldSignal yieldSignal = new DriverYieldSignal();
yieldSignal.forceYieldForTesting();
List<Type> types = ImmutableList.of(INTEGER);
WorkProcessor<Page> mergedPages = MergeSortedPages.mergeSortedPages(ImmutableList.of(WorkProcessor.fromIterable(rowPagesBuilder(types).row(1).build())), new SimplePageWithPositionComparator(types, ImmutableList.of(0), ImmutableList.of(DESC_NULLS_LAST)), ImmutableList.of(0), types, (pageBuilder, pageWithPosition) -> pageBuilder.isFull(), false, newSimpleAggregatedMemoryContext().newAggregatedMemoryContext(), yieldSignal);
// yield signal is on
assertFalse(mergedPages.process());
yieldSignal.resetYieldForTesting();
// page is produced
assertTrue(mergedPages.process());
assertFalse(mergedPages.isFinished());
Page page = mergedPages.getResult();
MaterializedResult expected = resultBuilder(TEST_SESSION, types).row(1).build();
assertEquals(toMaterializedResult(TEST_SESSION, types, ImmutableList.of(page)), expected);
// merge source finished
assertTrue(mergedPages.process());
assertTrue(mergedPages.isFinished());
}
use of com.facebook.presto.operator.DriverYieldSignal in project presto by prestodb.
the class TestPageProcessorCompiler method testSanityFilterOnRLE.
@Test
public void testSanityFilterOnRLE() {
FunctionAndTypeManager functionAndTypeManager = createTestMetadataManager().getFunctionAndTypeManager();
FunctionHandle lessThan = functionAndTypeManager.resolveOperator(LESS_THAN, fromTypes(BIGINT, BIGINT));
CallExpression filter = new CallExpression(LESS_THAN.name(), lessThan, BOOLEAN, ImmutableList.of(field(0, BIGINT), constant(10L, BIGINT)));
PageProcessor processor = compiler.compilePageProcessor(TEST_SESSION.getSqlFunctionProperties(), Optional.of(filter), ImmutableList.of(field(0, BIGINT)), false, MAX_BATCH_SIZE).get();
Page page = new Page(createRLEBlock(5L, 100));
Page outputPage = getOnlyElement(processor.process(null, new DriverYieldSignal(), newSimpleAggregatedMemoryContext().newLocalMemoryContext(PageProcessor.class.getSimpleName()), page)).orElseThrow(() -> new AssertionError("page is not present"));
assertEquals(outputPage.getPositionCount(), 100);
assertTrue(outputPage.getBlock(0) instanceof RunLengthEncodedBlock);
RunLengthEncodedBlock rle = (RunLengthEncodedBlock) outputPage.getBlock(0);
assertEquals(BIGINT.getLong(rle.getValue(), 0), 5L);
}
Aggregations