Search in sources :

Example 1 with SortLimitOperator

use of org.apache.flink.table.runtime.operators.sort.SortLimitOperator in project flink by apache.

the class BatchExecSortLimit method translateToPlanInternal.

@SuppressWarnings("unchecked")
@Override
protected Transformation<RowData> translateToPlanInternal(PlannerBase planner, ExecNodeConfig config) {
    if (limitEnd == Long.MAX_VALUE) {
        throw new TableException("Not support limitEnd is max value now!");
    }
    ExecEdge inputEdge = getInputEdges().get(0);
    Transformation<RowData> inputTransform = (Transformation<RowData>) inputEdge.translateToPlan(planner);
    RowType inputType = (RowType) inputEdge.getOutputType();
    // generate comparator
    GeneratedRecordComparator genComparator = ComparatorCodeGenerator.gen(config.getTableConfig(), "SortLimitComparator", inputType, sortSpec);
    // TODO If input is ordered, there is no need to use the heap.
    SortLimitOperator operator = new SortLimitOperator(isGlobal, limitStart, limitEnd, genComparator);
    return ExecNodeUtil.createOneInputTransformation(inputTransform, createTransformationName(config), createTransformationDescription(config), SimpleOperatorFactory.of(operator), InternalTypeInfo.of(inputType), inputTransform.getParallelism());
}
Also used : TableException(org.apache.flink.table.api.TableException) RowData(org.apache.flink.table.data.RowData) Transformation(org.apache.flink.api.dag.Transformation) ExecEdge(org.apache.flink.table.planner.plan.nodes.exec.ExecEdge) RowType(org.apache.flink.table.types.logical.RowType) GeneratedRecordComparator(org.apache.flink.table.runtime.generated.GeneratedRecordComparator) SortLimitOperator(org.apache.flink.table.runtime.operators.sort.SortLimitOperator)

Aggregations

Transformation (org.apache.flink.api.dag.Transformation)1 TableException (org.apache.flink.table.api.TableException)1 RowData (org.apache.flink.table.data.RowData)1 ExecEdge (org.apache.flink.table.planner.plan.nodes.exec.ExecEdge)1 GeneratedRecordComparator (org.apache.flink.table.runtime.generated.GeneratedRecordComparator)1 SortLimitOperator (org.apache.flink.table.runtime.operators.sort.SortLimitOperator)1 RowType (org.apache.flink.table.types.logical.RowType)1