use of io.prestosql.operator.PageWithPositionComparator 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.PageWithPositionComparator in project hetu-core by openlookeng.
the class OrderingCompiler method generatePageWithPositionComparatorClass.
private Class<? extends PageWithPositionComparator> generatePageWithPositionComparatorClass(List<Type> sortTypes, List<Integer> sortChannels, List<SortOrder> sortOrders) {
CallSiteBinder callSiteBinder = new CallSiteBinder();
ClassDefinition classDefinition = new ClassDefinition(a(PUBLIC, FINAL), makeClassName("PageWithPositionComparator"), type(Object.class), type(PageWithPositionComparator.class));
classDefinition.declareDefaultConstructor(a(PUBLIC));
generateMergeSortCompareTo(classDefinition, callSiteBinder, sortTypes, sortChannels, sortOrders);
return defineClass(classDefinition, PageWithPositionComparator.class, callSiteBinder.getBindings(), getClass().getClassLoader());
}
use of io.prestosql.operator.PageWithPositionComparator 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;
}
Aggregations