fredia commented on code in PR #25918: URL: https://github.com/apache/flink/pull/25918#discussion_r1908294146
########## flink-runtime/src/main/java/org/apache/flink/runtime/state/v2/StateSerializerReference.java: ########## @@ -0,0 +1,107 @@ +/* + * 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.ExecutionConfig; +import org.apache.flink.api.common.functions.SerializerFactory; +import org.apache.flink.api.common.typeinfo.TypeInformation; +import org.apache.flink.api.common.typeutils.TypeSerializer; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.annotation.Nullable; + +import java.util.concurrent.atomic.AtomicReference; + +import static org.apache.flink.util.Preconditions.checkNotNull; +import static org.apache.flink.util.Preconditions.checkState; + +/** + * A reference to a serializer. This also provides functions for lazy initialization. + * + * @param <T> the type for serialization. + */ +public class StateSerializerReference<T> extends AtomicReference<TypeSerializer<T>> { + private static final Logger LOG = LoggerFactory.getLogger(StateSerializerReference.class); + + /** + * The type information describing the value type. Only used to if the serializer is created + * lazily. + */ + @Nullable private final TypeInformation<T> typeInfo; + + public StateSerializerReference(TypeInformation<T> typeInfo) { + super(null); + this.typeInfo = checkNotNull(typeInfo, "type information must not be null"); + } + + public StateSerializerReference(TypeSerializer<T> typeSerializer) { Review Comment: IIUC, this constructor is used for eager initialization, is it necessary to keep this interface? in other words, can all State Descriptors use lazy initialization? -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
