Search in sources :

Example 1 with EmptyRowDataKeySelector

use of org.apache.flink.table.runtime.keyselector.EmptyRowDataKeySelector in project flink by apache.

the class StreamExecTemporalSort method createSortProcTime.

/**
 * Create Sort logic based on processing time.
 */
private Transformation<RowData> createSortProcTime(RowType inputType, Transformation<RowData> inputTransform, ExecNodeConfig config) {
    // if the order has secondary sorting fields in addition to the proctime
    if (sortSpec.getFieldSize() > 1) {
        // skip the first field which is the proctime field and would be ordered by timer.
        SortSpec specExcludeTime = sortSpec.createSubSortSpec(1);
        GeneratedRecordComparator rowComparator = ComparatorCodeGenerator.gen(config.getTableConfig(), "ProcTimeSortComparator", inputType, specExcludeTime);
        ProcTimeSortOperator sortOperator = new ProcTimeSortOperator(InternalTypeInfo.of(inputType), rowComparator);
        OneInputTransformation<RowData, RowData> transform = ExecNodeUtil.createOneInputTransformation(inputTransform, createTransformationMeta(TEMPORAL_SORT_TRANSFORMATION, config), sortOperator, InternalTypeInfo.of(inputType), inputTransform.getParallelism());
        // as input node is singleton exchange, its parallelism is 1.
        if (inputsContainSingleton()) {
            transform.setParallelism(1);
            transform.setMaxParallelism(1);
        }
        EmptyRowDataKeySelector selector = EmptyRowDataKeySelector.INSTANCE;
        transform.setStateKeySelector(selector);
        transform.setStateKeyType(selector.getProducedType());
        return transform;
    } else {
        // if the order is done only on proctime we only need to forward the elements
        return inputTransform;
    }
}
Also used : RowData(org.apache.flink.table.data.RowData) ProcTimeSortOperator(org.apache.flink.table.runtime.operators.sort.ProcTimeSortOperator) GeneratedRecordComparator(org.apache.flink.table.runtime.generated.GeneratedRecordComparator) EmptyRowDataKeySelector(org.apache.flink.table.runtime.keyselector.EmptyRowDataKeySelector) SortSpec(org.apache.flink.table.planner.plan.nodes.exec.spec.SortSpec)

Example 2 with EmptyRowDataKeySelector

use of org.apache.flink.table.runtime.keyselector.EmptyRowDataKeySelector in project flink by apache.

the class StreamExecTemporalSort method createSortRowTime.

/**
 * Create Sort logic based on row time.
 */
private Transformation<RowData> createSortRowTime(RowType inputType, Transformation<RowData> inputTransform, ExecNodeConfig config) {
    GeneratedRecordComparator rowComparator = null;
    if (sortSpec.getFieldSize() > 1) {
        // skip the first field which is the rowtime field and would be ordered by timer.
        SortSpec specExcludeTime = sortSpec.createSubSortSpec(1);
        rowComparator = ComparatorCodeGenerator.gen(config.getTableConfig(), "RowTimeSortComparator", inputType, specExcludeTime);
    }
    RowTimeSortOperator sortOperator = new RowTimeSortOperator(InternalTypeInfo.of(inputType), sortSpec.getFieldSpec(0).getFieldIndex(), rowComparator);
    OneInputTransformation<RowData, RowData> transform = ExecNodeUtil.createOneInputTransformation(inputTransform, createTransformationMeta(TEMPORAL_SORT_TRANSFORMATION, config), sortOperator, InternalTypeInfo.of(inputType), inputTransform.getParallelism());
    if (inputsContainSingleton()) {
        transform.setParallelism(1);
        transform.setMaxParallelism(1);
    }
    EmptyRowDataKeySelector selector = EmptyRowDataKeySelector.INSTANCE;
    transform.setStateKeySelector(selector);
    transform.setStateKeyType(selector.getProducedType());
    return transform;
}
Also used : RowData(org.apache.flink.table.data.RowData) RowTimeSortOperator(org.apache.flink.table.runtime.operators.sort.RowTimeSortOperator) GeneratedRecordComparator(org.apache.flink.table.runtime.generated.GeneratedRecordComparator) EmptyRowDataKeySelector(org.apache.flink.table.runtime.keyselector.EmptyRowDataKeySelector) SortSpec(org.apache.flink.table.planner.plan.nodes.exec.spec.SortSpec)

Aggregations

RowData (org.apache.flink.table.data.RowData)2 SortSpec (org.apache.flink.table.planner.plan.nodes.exec.spec.SortSpec)2 GeneratedRecordComparator (org.apache.flink.table.runtime.generated.GeneratedRecordComparator)2 EmptyRowDataKeySelector (org.apache.flink.table.runtime.keyselector.EmptyRowDataKeySelector)2 ProcTimeSortOperator (org.apache.flink.table.runtime.operators.sort.ProcTimeSortOperator)1 RowTimeSortOperator (org.apache.flink.table.runtime.operators.sort.RowTimeSortOperator)1