@Override
    public void initializeState(FunctionInitializationContext context) throws Exception {
        if (this.inLongMetric != null) {
            this.metricStateListState = context.getOperatorStateStore().getUnionListState(
                    new ListStateDescriptor<>(
                            INLONG_METRIC_STATE_NAME, TypeInformation.of(new TypeHint<MetricState>() {
                            })));
        }

        if (context.isRestored()) {
            metricState = MetricStateUtils.restoreMetricState(metricStateListState,
                    getRuntimeContext().getIndexOfThisSubtask(), getRuntimeContext().getNumberOfParallelSubtasks());
        }

        final ListStateDescriptor<OUT> stateDescriptor = new ListStateDescriptor<>(
                "rowState", outputType);
        this.listState = context.getOperatorStateStore().getListState(stateDescriptor);
        if (context.isRestored()) {
            if (listState != null) {
                listState.get().forEach(rows::add);
            }
        }
    }
The stop watch to measure time duration.
inlong-sort/sort-flink/sort-flink-v1.15/sort-connectors/redis/src/main/java/org/apache/inlong/sort/redis/sink/AbstractRedisSinkFunction.java