use of io.trino.operator.DriverYieldSignal in project trino by trinodb.
the class TestInputPageProjection method testLazyInputPage.
@Test
public void testLazyInputPage() {
InputPageProjection projection = new InputPageProjection(0, BIGINT);
Block block = createLongSequenceBlock(0, 100);
Block result = projection.project(SESSION, new DriverYieldSignal(), new Page(block), SelectedPositions.positionsRange(0, 100)).getResult();
assertFalse(result instanceof LazyBlock);
block = lazyWrapper(block);
result = projection.project(SESSION, new DriverYieldSignal(), new Page(block), SelectedPositions.positionsRange(0, 100)).getResult();
assertTrue(result instanceof LazyBlock);
assertFalse(result.isLoaded());
}
use of io.trino.operator.DriverYieldSignal in project trino by trinodb.
the class TestPageProcessor method testSelectNoneFilterLazyLoad.
@Test
public void testSelectNoneFilterLazyLoad() {
PageProcessor pageProcessor = new PageProcessor(Optional.of(new SelectNoneFilter()), ImmutableList.of(new InputPageProjection(1, BIGINT)));
// if channel 1 is loaded, test will fail
Page inputPage = new Page(createLongSequenceBlock(0, 100), new LazyBlock(100, () -> {
throw new AssertionError("Lazy block should not be loaded");
}));
LocalMemoryContext memoryContext = newSimpleAggregatedMemoryContext().newLocalMemoryContext(PageProcessor.class.getSimpleName());
Iterator<Optional<Page>> output = pageProcessor.process(SESSION, new DriverYieldSignal(), memoryContext, inputPage);
assertEquals(memoryContext.getBytes(), 0);
List<Optional<Page>> outputPages = ImmutableList.copyOf(output);
assertEquals(outputPages.size(), 0);
}
use of io.trino.operator.DriverYieldSignal in project trino by trinodb.
the class TestPageProcessor method testProjectEmptyPage.
@Test
public void testProjectEmptyPage() {
PageProcessor pageProcessor = new PageProcessor(Optional.of(new SelectAllFilter()), ImmutableList.of(new InputPageProjection(0, BIGINT)));
Page inputPage = new Page(createLongSequenceBlock(0, 0));
LocalMemoryContext memoryContext = newSimpleAggregatedMemoryContext().newLocalMemoryContext(PageProcessor.class.getSimpleName());
Iterator<Optional<Page>> output = pageProcessor.process(SESSION, 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 io.trino.operator.DriverYieldSignal in project trino by trinodb.
the class TestPageProcessor method testSelectNoneFilter.
@Test
public void testSelectNoneFilter() {
PageProcessor pageProcessor = new PageProcessor(Optional.of(new SelectNoneFilter()), ImmutableList.of(new InputPageProjection(0, BIGINT)));
Page inputPage = new Page(createLongSequenceBlock(0, 100));
LocalMemoryContext memoryContext = newSimpleAggregatedMemoryContext().newLocalMemoryContext(PageProcessor.class.getSimpleName());
Iterator<Optional<Page>> output = pageProcessor.process(SESSION, new DriverYieldSignal(), memoryContext, inputPage);
assertEquals(memoryContext.getBytes(), 0);
List<Optional<Page>> outputPages = ImmutableList.copyOf(output);
assertEquals(outputPages.size(), 0);
}
use of io.trino.operator.DriverYieldSignal in project trino by trinodb.
the class TestPageProcessor method testYieldProjection.
@Test
public void testYieldProjection() {
// each projection can finish without yield
// while between two projections, there is a yield
int rows = 128;
int columns = 20;
DriverYieldSignal yieldSignal = new DriverYieldSignal();
PageProcessor pageProcessor = new PageProcessor(Optional.empty(), Collections.nCopies(columns, new YieldPageProjection(new InputPageProjection(0, VARCHAR))), OptionalInt.of(MAX_BATCH_SIZE));
Slice[] slices = new Slice[rows];
Arrays.fill(slices, Slices.allocate(rows));
Page inputPage = new Page(createSlicesBlock(slices));
Iterator<Optional<Page>> output = processAndAssertRetainedPageSize(pageProcessor, yieldSignal, inputPage);
// Also, we would like to reset the yield signal before starting to process the next column in order NOT to yield per position inside the column.
for (int i = 0; i < columns - 1; i++) {
assertTrue(output.hasNext());
assertNull(output.next().orElse(null));
assertTrue(yieldSignal.isSet());
yieldSignal.reset();
}
assertTrue(output.hasNext());
Page actualPage = output.next().orElse(null);
assertNotNull(actualPage);
assertTrue(yieldSignal.isSet());
yieldSignal.reset();
Block[] blocks = new Block[columns];
Arrays.fill(blocks, createSlicesBlock(Arrays.copyOfRange(slices, 0, rows)));
Page expectedPage = new Page(blocks);
assertPageEquals(Collections.nCopies(columns, VARCHAR), actualPage, expectedPage);
assertFalse(output.hasNext());
}
Aggregations