use of io.prestosql.operator.DriverYieldSignal in project hetu-core by openlookeng.
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());
}
use of io.prestosql.operator.DriverYieldSignal in project hetu-core by openlookeng.
the class TestPageProcessor method testProjectLazyLoad.
@Test
public void testProjectLazyLoad() {
PageProcessor pageProcessor = new PageProcessor(Optional.of(new SelectAllFilter()), ImmutableList.of(new LazyPagePageProjection()), OptionalInt.of(MAX_BATCH_SIZE));
// if channel 1 is loaded, test will fail
Page inputPage = new Page(createLongSequenceBlock(0, 100), new LazyBlock(100, lazyBlock -> {
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);
List<Optional<Page>> outputPages = ImmutableList.copyOf(output);
assertEquals(outputPages.size(), 1);
assertPageEquals(ImmutableList.of(BIGINT), outputPages.get(0).orElse(null), new Page(createLongSequenceBlock(0, 100)));
}
use of io.prestosql.operator.DriverYieldSignal in project hetu-core by openlookeng.
the class TestDictionaryAwarePageProjection method testProjectFastReturnIgnoreYield.
private static void testProjectFastReturnIgnoreYield(Block block, DictionaryAwarePageProjection projection) {
DriverYieldSignal yieldSignal = new DriverYieldSignal();
Work<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();
yieldSignal.reset();
assertBlockEquals(BIGINT, result, block.getRegion(5, 10));
assertInstanceOf(result, DictionaryBlock.class);
}
use of io.prestosql.operator.DriverYieldSignal in project hetu-core by openlookeng.
the class TestPageProcessorCompiler method testSanityRLE.
@Test
public void testSanityRLE() {
PageProcessor processor = compiler.compilePageProcessor(Optional.empty(), ImmutableList.of(field(0, BIGINT), field(1, VARCHAR)), MAX_BATCH_SIZE).get();
Slice varcharValue = Slices.utf8Slice("hello");
Page page = new Page(RunLengthEncodedBlock.create(BIGINT, 123L, 100), RunLengthEncodedBlock.create(VARCHAR, varcharValue, 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);
assertTrue(outputPage.getBlock(1) instanceof RunLengthEncodedBlock);
RunLengthEncodedBlock rleBlock = (RunLengthEncodedBlock) outputPage.getBlock(0);
assertEquals(BIGINT.getLong(rleBlock.getValue(), 0), 123L);
RunLengthEncodedBlock rleBlock1 = (RunLengthEncodedBlock) outputPage.getBlock(1);
assertEquals(VARCHAR.getSlice(rleBlock1.getValue(), 0), varcharValue);
}
use of io.prestosql.operator.DriverYieldSignal in project hetu-core by openlookeng.
the class TestPageProcessorCompiler method testSanityColumnarDictionary.
@Test
public void testSanityColumnarDictionary() {
PageProcessor processor = compiler.compilePageProcessor(Optional.empty(), ImmutableList.of(field(0, VARCHAR)), MAX_BATCH_SIZE).get();
Page page = new Page(createDictionaryBlock(createExpectedValues(10), 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 DictionaryBlock);
DictionaryBlock dictionaryBlock = (DictionaryBlock) outputPage.getBlock(0);
assertEquals(dictionaryBlock.getDictionary().getPositionCount(), 10);
}
Aggregations