use of io.prestosql.operator.SimplePageWithPositionComparator in project hetu-core by openlookeng.
the class TestMergeSortedPages method testMergeSortYieldingProgresses.
@Test
public void testMergeSortYieldingProgresses() {
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 io.prestosql.operator.SimplePageWithPositionComparator in project hetu-core by openlookeng.
the class TestMergeSortedPages method mergeSortedPages.
private static MaterializedResult mergeSortedPages(List<Type> types, List<Integer> sortChannels, List<SortOrder> sortOrder, List<List<Page>> sortedPages) {
List<WorkProcessor<Page>> pageProducers = sortedPages.stream().map(WorkProcessor::fromIterable).collect(toImmutableList());
PageWithPositionComparator comparator = new SimplePageWithPositionComparator(types, sortChannels, sortOrder);
AggregatedMemoryContext memoryContext = newSimpleAggregatedMemoryContext().newAggregatedMemoryContext();
WorkProcessor<Page> mergedPages = MergeSortedPages.mergeSortedPages(pageProducers, comparator, types, memoryContext, new DriverYieldSignal());
assertTrue(mergedPages.process());
if (mergedPages.isFinished()) {
return toMaterializedResult(TEST_SESSION, types, ImmutableList.of());
}
Page page = mergedPages.getResult();
assertTrue(mergedPages.process());
assertTrue(mergedPages.isFinished());
assertEquals(memoryContext.getBytes(), 0L);
return toMaterializedResult(TEST_SESSION, types, ImmutableList.of(page));
}
use of io.prestosql.operator.SimplePageWithPositionComparator in project hetu-core by openlookeng.
the class OrderingCompiler method internalCompilePageWithPositionComparator.
private PageWithPositionComparator internalCompilePageWithPositionComparator(List<Type> types, List<Integer> sortChannels, List<SortOrder> sortOrders) {
PageWithPositionComparator comparator;
try {
Class<? extends PageWithPositionComparator> pageWithPositionsComparatorClass = generatePageWithPositionComparatorClass(types, sortChannels, sortOrders);
comparator = pageWithPositionsComparatorClass.getConstructor().newInstance();
} catch (Throwable t) {
log.error(t, "Error compiling comparator for channels %s with order %s", sortChannels, sortChannels);
comparator = new SimplePageWithPositionComparator(types, sortChannels, sortOrders);
}
return comparator;
}
use of io.prestosql.operator.SimplePageWithPositionComparator in project hetu-core by openlookeng.
the class TestMergeSortedPages method testSortingYields.
@Test
public void testSortingYields() {
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());
}
Aggregations