Search in sources :

Example 1 with PagesIndexComparator

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

the class OrderingCompiler method compilePagesIndexComparator.

private Class<? extends PagesIndexComparator> compilePagesIndexComparator(List<Type> sortTypes, List<Integer> sortChannels, List<SortOrder> sortOrders) {
    CallSiteBinder callSiteBinder = new CallSiteBinder();
    ClassDefinition classDefinition = new ClassDefinition(a(PUBLIC, FINAL), makeClassName("PagesIndexComparator"), type(Object.class), type(PagesIndexComparator.class));
    classDefinition.declareDefaultConstructor(a(PUBLIC));
    generatePageIndexCompareTo(classDefinition, callSiteBinder, sortTypes, sortChannels, sortOrders);
    return defineClass(classDefinition, PagesIndexComparator.class, callSiteBinder.getBindings(), getClass().getClassLoader());
}
Also used : CallSiteBinder(com.facebook.presto.bytecode.CallSiteBinder) PagesIndexComparator(com.facebook.presto.operator.PagesIndexComparator) SimplePagesIndexComparator(com.facebook.presto.operator.SimplePagesIndexComparator) ClassDefinition(com.facebook.presto.bytecode.ClassDefinition)

Example 2 with PagesIndexComparator

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

the class OrderingCompiler method internalCompilePagesIndexOrdering.

@VisibleForTesting
public PagesIndexOrdering internalCompilePagesIndexOrdering(List<Type> sortTypes, List<Integer> sortChannels, List<SortOrder> sortOrders) {
    requireNonNull(sortChannels, "sortChannels is null");
    requireNonNull(sortOrders, "sortOrders is null");
    PagesIndexComparator comparator;
    try {
        Class<? extends PagesIndexComparator> pagesHashStrategyClass = compilePagesIndexComparator(sortTypes, sortChannels, sortOrders);
        comparator = pagesHashStrategyClass.getConstructor().newInstance();
    } catch (Throwable e) {
        log.error(e, "Error compiling comparator for channels %s with order %s", sortChannels, sortOrders);
        comparator = new SimplePagesIndexComparator(sortTypes, sortChannels, sortOrders);
    }
    // we may want to load a separate PagesIndexOrdering for each comparator
    return new PagesIndexOrdering(comparator);
}
Also used : SimplePagesIndexComparator(com.facebook.presto.operator.SimplePagesIndexComparator) PagesIndexComparator(com.facebook.presto.operator.PagesIndexComparator) SimplePagesIndexComparator(com.facebook.presto.operator.SimplePagesIndexComparator) PagesIndexOrdering(com.facebook.presto.operator.PagesIndexOrdering) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

PagesIndexComparator (com.facebook.presto.operator.PagesIndexComparator)2 SimplePagesIndexComparator (com.facebook.presto.operator.SimplePagesIndexComparator)2 CallSiteBinder (com.facebook.presto.bytecode.CallSiteBinder)1 ClassDefinition (com.facebook.presto.bytecode.ClassDefinition)1 PagesIndexOrdering (com.facebook.presto.operator.PagesIndexOrdering)1 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1