use of io.prestosql.operator.DriverYieldSignal in project hetu-core by openlookeng.
the class TestPageProcessor method testFilterNoColumns.
@Test
public void testFilterNoColumns() {
PageProcessor pageProcessor = new PageProcessor(Optional.of(new TestingPageFilter(positionsRange(0, 50))), ImmutableList.of());
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(), 1);
Page outputPage = outputPages.get(0).orElse(null);
assertEquals(outputPage.getChannelCount(), 0);
assertEquals(outputPage.getPositionCount(), 50);
}
use of io.prestosql.operator.DriverYieldSignal in project hetu-core by openlookeng.
the class TestPageProcessor method testAdaptiveBatchSize.
@Test
public void testAdaptiveBatchSize() {
PageProcessor pageProcessor = new PageProcessor(Optional.empty(), ImmutableList.of(new InputPageProjection(0, VARCHAR)), OptionalInt.of(MAX_BATCH_SIZE));
// process large page which will reduce batch size
Slice[] slices = new Slice[(int) (MAX_BATCH_SIZE * 2.5)];
Arrays.fill(slices, Slices.allocate(1024));
Page inputPage = new Page(createSlicesBlock(slices));
Iterator<Optional<Page>> output = processAndAssertRetainedPageSize(pageProcessor, new DriverYieldSignal(), inputPage);
List<Optional<Page>> outputPages = ImmutableList.copyOf(output);
int batchSize = MAX_BATCH_SIZE;
for (Optional<Page> actualPage : outputPages) {
Page expectedPage = new Page(createSlicesBlock(Arrays.copyOfRange(slices, 0, batchSize)));
assertPageEquals(ImmutableList.of(VARCHAR), actualPage.orElse(null), expectedPage);
if (actualPage.orElseThrow(() -> new AssertionError("page is not present")).getSizeInBytes() > MAX_PAGE_SIZE_IN_BYTES) {
batchSize = batchSize / 2;
}
}
// process small page which will increase batch size
Arrays.fill(slices, Slices.allocate(128));
inputPage = new Page(createSlicesBlock(slices));
output = processAndAssertRetainedPageSize(pageProcessor, new DriverYieldSignal(), inputPage);
outputPages = ImmutableList.copyOf(output);
int offset = 0;
for (Optional<Page> actualPage : outputPages) {
Page expectedPage = new Page(createSlicesBlock(Arrays.copyOfRange(slices, 0, Math.min(inputPage.getPositionCount() - offset, batchSize))));
assertPageEquals(ImmutableList.of(VARCHAR), actualPage.orElse(null), expectedPage);
offset += actualPage.orElseThrow(() -> new AssertionError("page is not present")).getPositionCount();
if (actualPage.orElseThrow(() -> new AssertionError("page is not present")).getSizeInBytes() < MIN_PAGE_SIZE_IN_BYTES) {
batchSize = batchSize * 2;
}
}
}
use of io.prestosql.operator.DriverYieldSignal in project hetu-core by openlookeng.
the class TestTupleFilterProcessor method testFilter.
@Test
public void testFilter() {
Page tuplePage = Iterables.getOnlyElement(rowPagesBuilder(BIGINT, VARCHAR, DOUBLE).row(1L, "a", 0.1).build());
List<Type> outputTypes = ImmutableList.of(VARCHAR, BIGINT, BOOLEAN, DOUBLE, DOUBLE);
Page inputPage = Iterables.getOnlyElement(rowPagesBuilder(outputTypes).row("a", 1L, true, 0.1, 0.0).row("b", 1L, true, 0.1, 2.0).row("a", 1L, false, 0.1, 2.0).row("a", 0L, false, 0.2, 0.2).build());
DynamicTupleFilterFactory filterFactory = new DynamicTupleFilterFactory(42, new PlanNodeId("42"), new int[] { 0, 1, 2 }, new int[] { 1, 0, 3 }, outputTypes, new PageFunctionCompiler(createTestMetadataManager(), 0));
PageProcessor tupleFilterProcessor = filterFactory.createPageProcessor(tuplePage, OptionalInt.of(MAX_BATCH_SIZE)).get();
Page actualPage = getOnlyElement(tupleFilterProcessor.process(SESSION, new DriverYieldSignal(), newSimpleAggregatedMemoryContext().newLocalMemoryContext(PageProcessor.class.getSimpleName()), inputPage)).orElseThrow(() -> new AssertionError("page is not present"));
Page expectedPage = Iterables.getOnlyElement(rowPagesBuilder(outputTypes).row("a", 1L, true, 0.1, 0.0).row("a", 1L, false, 0.1, 2.0).build());
assertPageEquals(outputTypes, actualPage, expectedPage);
}
use of io.prestosql.operator.DriverYieldSignal in project hetu-core by openlookeng.
the class TestDictionaryAwarePageProjection method testProjectList.
private static void testProjectList(Block block, Class<? extends Block> expectedResultType, DictionaryAwarePageProjection projection, boolean forceYield) {
DriverYieldSignal yieldSignal = new DriverYieldSignal();
int[] positions = { 0, 2, 4, 6, 8, 10 };
Work<Block> work = projection.project(null, yieldSignal, new Page(block), SelectedPositions.positionsList(positions, 0, positions.length));
Block result;
if (forceYield) {
result = projectWithYield(work, yieldSignal);
} else {
assertTrue(work.process());
result = work.getResult();
}
assertBlockEquals(BIGINT, result, block.copyPositions(positions, 0, positions.length));
assertInstanceOf(result, expectedResultType);
}
use of io.prestosql.operator.DriverYieldSignal in project hetu-core by openlookeng.
the class TestDictionaryAwarePageProjection method testProjectRange.
private static void testProjectRange(Block block, Class<? extends Block> expectedResultType, DictionaryAwarePageProjection projection, boolean forceYield) {
DriverYieldSignal yieldSignal = new DriverYieldSignal();
Work<Block> work = projection.project(null, yieldSignal, new Page(block), SelectedPositions.positionsRange(5, 10));
Block result;
if (forceYield) {
result = projectWithYield(work, yieldSignal);
} else {
assertTrue(work.process());
result = work.getResult();
}
assertBlockEquals(BIGINT, result, block.getRegion(5, 10));
assertInstanceOf(result, expectedResultType);
}
Aggregations