Zakelly commented on code in PR #24651:
URL: https://github.com/apache/flink/pull/24651#discussion_r1565148947


##########
flink-runtime/src/main/java/org/apache/flink/runtime/state/v2/InternalKeyedState.java:
##########
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.runtime.state.v2;
+
+import org.apache.flink.annotation.Internal;
+import org.apache.flink.api.common.state.v2.State;
+import org.apache.flink.api.common.state.v2.StateFuture;
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+import org.apache.flink.runtime.asyncprocessing.AsyncExecutionController;
+import org.apache.flink.runtime.asyncprocessing.StateRequestType;
+
+/**
+ * The {@code InternalKvState} is the root of the internal state type 
hierarchy, similar to the

Review Comment:
   nit. replace all `InternalKvState` with `InternalKeyedState`.



##########
flink-runtime/src/main/java/org/apache/flink/runtime/state/v2/StateDescriptor.java:
##########
@@ -0,0 +1,167 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.runtime.state.v2;
+
+import org.apache.flink.annotation.Internal;
+import org.apache.flink.api.common.serialization.SerializerConfig;
+import org.apache.flink.api.common.serialization.SerializerConfigImpl;
+import org.apache.flink.api.common.state.StateTtlConfig;
+import org.apache.flink.api.common.typeinfo.TypeInformation;
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+import org.apache.flink.util.Preconditions;
+
+import javax.annotation.Nonnull;
+
+import java.io.Serializable;
+
+import static org.apache.flink.util.Preconditions.checkNotNull;
+
+/**
+ * Base class for state descriptors. A {@code StateDescriptor} is used for 
creating partitioned
+ * State in stateful operations internally.
+ *
+ * @param <T> The type of the value of the state object described by this 
state descriptor.
+ */
+@Internal
+public abstract class StateDescriptor<T> implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /** An enumeration of the types of supported states. */
+    public enum Type {
+        VALUE,
+        LIST,
+        REDUCING,
+        FOLDING,
+        AGGREGATING,
+        MAP
+    }
+
+    /** ID that uniquely identifies state created from this StateDescriptor. */
+    @Nonnull private final String stateId;
+
+    /** The serializer for the type. */
+    @Nonnull private final TypeSerializer<T> typeSerializer;
+
+    /**
+     * The type information describing the value type. Remain this since it 
could provide more
+     * information which could be used internally in the future.
+     */
+    @Nonnull private final TypeInformation<T> typeInfo;

Review Comment:
   IIUC, we don't need this?



##########
flink-runtime/src/main/java/org/apache/flink/runtime/state/v2/StateDescriptor.java:
##########
@@ -0,0 +1,167 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.runtime.state.v2;
+
+import org.apache.flink.annotation.Internal;
+import org.apache.flink.api.common.serialization.SerializerConfig;
+import org.apache.flink.api.common.serialization.SerializerConfigImpl;
+import org.apache.flink.api.common.state.StateTtlConfig;
+import org.apache.flink.api.common.typeinfo.TypeInformation;
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+import org.apache.flink.util.Preconditions;
+
+import javax.annotation.Nonnull;
+
+import java.io.Serializable;
+
+import static org.apache.flink.util.Preconditions.checkNotNull;
+
+/**
+ * Base class for state descriptors. A {@code StateDescriptor} is used for 
creating partitioned
+ * State in stateful operations internally.
+ *
+ * @param <T> The type of the value of the state object described by this 
state descriptor.
+ */
+@Internal
+public abstract class StateDescriptor<T> implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /** An enumeration of the types of supported states. */
+    public enum Type {
+        VALUE,
+        LIST,
+        REDUCING,
+        FOLDING,
+        AGGREGATING,
+        MAP
+    }
+
+    /** ID that uniquely identifies state created from this StateDescriptor. */
+    @Nonnull private final String stateId;
+
+    /** The serializer for the type. */
+    @Nonnull private final TypeSerializer<T> typeSerializer;
+
+    /**
+     * The type information describing the value type. Remain this since it 
could provide more
+     * information which could be used internally in the future.
+     */
+    @Nonnull private final TypeInformation<T> typeInfo;
+
+    /** The configuration of state time-to-live(TTL), it is disabled by 
default. */
+    @Nonnull private StateTtlConfig ttlConfig = StateTtlConfig.DISABLED;
+
+    // ------------------------------------------------------------------------
+
+    /**
+     * Create a new {@code StateDescriptor} with the given stateId and the 
given type information.
+     *
+     * @param stateId The stateId of the {@code StateDescriptor}.
+     * @param typeInfo The type information for the values in the state.
+     */
+    protected StateDescriptor(@Nonnull String stateId, TypeInformation<T> 
typeInfo) {
+        this(stateId, typeInfo, new SerializerConfigImpl());
+    }
+
+    /**
+     * Create a new {@code StateDescriptor} with the given stateId and the 
given type information.
+     *
+     * @param stateId The stateId of the {@code StateDescriptor}.
+     * @param typeInfo The type information for the values in the state.
+     * @param serializerConfig The serializer related config used to generate 
{@code
+     *     TypeSerializer}.
+     */
+    protected StateDescriptor(
+            @Nonnull String stateId,
+            @Nonnull TypeInformation<T> typeInfo,
+            SerializerConfig serializerConfig) {
+        this.stateId = checkNotNull(stateId, "stateId must not be null");
+        this.typeInfo = checkNotNull(typeInfo, "type information must not be 
null");
+        this.typeSerializer = typeInfo.createSerializer(serializerConfig);
+    }
+
+    // ------------------------------------------------------------------------
+
+    /**
+     * Configures optional activation of state time-to-live (TTL).
+     *
+     * <p>State user value will expire, become unavailable and be cleaned up 
in storage depending on
+     * configured {@link StateTtlConfig}.
+     *
+     * @param ttlConfig configuration of state TTL
+     */
+    public void enableTimeToLive(StateTtlConfig ttlConfig) {
+        this.ttlConfig = Preconditions.checkNotNull(ttlConfig);

Review Comment:
   Since you have `import static Preconditions.checkNotNull`, how about remove 
the `Preconditions`?



##########
flink-runtime/src/main/java/org/apache/flink/runtime/state/v2/ValueStateImpl.java:
##########
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.runtime.state.v2;
+
+import org.apache.flink.api.common.state.v2.StateFuture;
+import org.apache.flink.api.common.state.v2.ValueState;
+import org.apache.flink.runtime.asyncprocessing.AsyncExecutionController;
+import org.apache.flink.runtime.asyncprocessing.StateRequestType;
+
+/**
+ * A default implementation of {@link ValueState} which delegates all async 
requests to {@link
+ * AsyncExecutionController}.
+ *
+ * @param <K> The type of key the state is associated to.
+ * @param <V> The type of values kept internally in state.
+ */
+public class ValueStateImpl<K, V> extends InternalKeyedState<K, V> implements 
ValueState<V> {

Review Comment:
   I'd prefer the name of `InternalValueState` here.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to