flink icon indicating copy to clipboard operation
flink copied to clipboard

[FLINK-37771] Simplify getPartitionedState of AbstractKeyedStateBackend

Open beliefer opened this issue 7 months ago • 2 comments

What is the purpose of the change

This PR aims to simplify getPartitionedState of AbstractKeyedStateBackend. Why we can remove this code?The code show below covers the function this PR removed. final S state = getOrCreateKeyedState(namespaceSerializer, stateDescriptor); The detail of getOrCreateKeyedState.

    public <N, S extends State, V> S getOrCreateKeyedState(
            final TypeSerializer<N> namespaceSerializer, StateDescriptor<S, V> stateDescriptor)
            throws Exception {
        checkNotNull(namespaceSerializer, "Namespace serializer");
        checkNotNull(
                keySerializer,
                "State key serializer has not been configured in the config. "
                        + "This operation cannot use partitioned state.");

        InternalKvState<K, ?, ?> kvState = keyValueStatesByName.get(stateDescriptor.getName());
        if (kvState == null) {
            if (!stateDescriptor.isSerializerInitialized()) {
                stateDescriptor.initializeSerializerUnlessSet(executionConfig);
            }
            kvState =
                    LatencyTrackingStateFactory.createStateAndWrapWithLatencyTrackingIfEnabled(
                            TtlStateFactory.createStateAndWrapWithTtlIfEnabled(
                                    namespaceSerializer, stateDescriptor, this, ttlTimeProvider),
                            stateDescriptor,
                            latencyTrackingStateConfig);
            keyValueStatesByName.put(stateDescriptor.getName(), kvState);
            publishQueryableStateIfEnabled(stateDescriptor, kvState);
        }
        return (S) kvState;
    }

Brief change log

Simplify getPartitionedState of AbstractKeyedStateBackend.

Verifying this change

This change is a trivial rework / code cleanup without any test coverage.

Does this pull request potentially affect one of the following parts:

  • Dependencies (does it add or upgrade a dependency): (no)
  • The public API, i.e., is any changed class annotated with @Public(Evolving): (no)
  • The serializers: (no)
  • The runtime per-record code paths (performance sensitive): (no)
  • Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: (no)
  • The S3 file system connector: (no)

Documentation

  • Does this pull request introduce a new feature? (no)

beliefer avatar May 08 '25 09:05 beliefer

CI report:

  • 6533fa00fa0a6f9546b3f4b75ed95f531889b43c Azure: SUCCESS
Bot commands The @flinkbot bot supports the following commands:
  • @flinkbot run azure re-run the last Azure build

flinkbot avatar May 08 '25 09:05 flinkbot

ping @aljoscha @StephanEwen @kl0u cc @1996fanrui @davidradl @GOODBOY008

beliefer avatar May 09 '25 10:05 beliefer