Search in sources :

Example 1 with PagesIndex

use of com.facebook.presto.operator.PagesIndex in project presto by prestodb.

the class PagesSortBenchmark method runPagesIndexSortBenchmark.

@Benchmark
public List<Page> runPagesIndexSortBenchmark(PagesIndexSortBenchmarkData data) {
    PagesIndex.TestingFactory pagesIndexFactory = new PagesIndex.TestingFactory(false);
    PagesIndex pageIndex = pagesIndexFactory.newPagesIndex(data.getTypes(), data.getTotalPositions());
    for (Page page : data.getPages()) {
        pageIndex.addPage(page);
    }
    pageIndex.sort(data.getSortChannels(), data.getSortOrders());
    return Streams.stream(pageIndex.getSortedPages()).collect(toImmutableList());
}
Also used : Page(com.facebook.presto.common.Page) SequencePageBuilder.createSequencePage(com.facebook.presto.SequencePageBuilder.createSequencePage) PagesIndex(com.facebook.presto.operator.PagesIndex) Benchmark(org.openjdk.jmh.annotations.Benchmark)

Example 2 with PagesIndex

use of com.facebook.presto.operator.PagesIndex in project presto by prestodb.

the class PagesIndexPageSorter method sort.

@Override
public long[] sort(List<Type> types, List<Page> pages, List<Integer> sortChannels, List<SortOrder> sortOrders, int expectedPositions) {
    PagesIndex pagesIndex = pagesIndexFactory.newPagesIndex(types, expectedPositions);
    pages.forEach(pagesIndex::addPage);
    pagesIndex.sort(sortChannels, sortOrders);
    int positionCount = pagesIndex.getPositionCount();
    AdaptiveLongBigArray valueAddresses = pagesIndex.getValueAddresses();
    long[] result = new long[positionCount];
    for (int i = 0; i < positionCount; i++) {
        result[i] = valueAddresses.get(i);
    }
    return result;
}
Also used : PagesIndex(com.facebook.presto.operator.PagesIndex) AdaptiveLongBigArray(com.facebook.presto.common.array.AdaptiveLongBigArray)

Aggregations

PagesIndex (com.facebook.presto.operator.PagesIndex)2 SequencePageBuilder.createSequencePage (com.facebook.presto.SequencePageBuilder.createSequencePage)1 Page (com.facebook.presto.common.Page)1 AdaptiveLongBigArray (com.facebook.presto.common.array.AdaptiveLongBigArray)1 Benchmark (org.openjdk.jmh.annotations.Benchmark)1