use of io.ordinate.engine.builder.PhysicalSortProperty in project Mycat2 by MyCATApache.
the class HeapTopNPlan method execute.
@Override
public Observable<VectorSchemaRoot> execute(RootContext rootContext) {
Comparator<Record> recordComparator;
if (physicalSortProperties.size() == 1) {
recordComparator = physicalSortProperties.get(0).evaluateToSortComparator();
} else {
recordComparator = physicalSortProperties.get(0).evaluateToSortComparator();
for (PhysicalSortProperty physicalSortProperty : physicalSortProperties.subList(1, physicalSortProperties.size())) {
recordComparator = recordComparator.thenComparing(physicalSortProperty.evaluateToSortComparator());
}
}
OutputLinq4jPhysicalPlan midPlan = OutputLinq4jPhysicalPlan.create(input);
Observable<Object[]> observable = midPlan.executeToObject(rootContext);
@NonNull Iterable<Record> objects = MycatRxJavaUtl.blockingIterable(observable.map(i -> RecordImpl.create(i)));
Enumerable<Record> records = EnumerableDefaults.orderBy(Linq4j.asEnumerable(objects), i -> i, recordComparator, offset.getInt(null), fetch.getInt(null));
return InputRecordPhysicalPlan.create(schema(), Observable.fromIterable(records)).execute(rootContext);
}
Aggregations