Zakelly commented on code in PR #27025: URL: https://github.com/apache/flink/pull/27025#discussion_r2386569141
########## flink-runtime/src/test/java/org/apache/flink/runtime/state/ttl/TtlListStateWithKryoTestContext.java: ########## @@ -0,0 +1,92 @@ +/* + * 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.ttl; + +import org.apache.flink.api.common.serialization.SerializerConfig; +import org.apache.flink.api.common.serialization.SerializerConfigImpl; +import org.apache.flink.api.java.typeutils.runtime.kryo.KryoSerializer; +import org.apache.flink.configuration.Configuration; +import org.apache.flink.configuration.PipelineOptions; + +import java.util.Arrays; +import java.util.Collections; + +/** Test suite for {@link TtlListState} with elements of serialized by kryo. */ +public class TtlListStateWithKryoTestContext + extends TtlListStateTestContextBase<TtlListStateWithKryoTestContext.NotPojoElement> { + TtlListStateWithKryoTestContext() { + super(new KryoSerializer<>(NotPojoElement.class, getForceKryoSerializerConfig())); + } + + private static SerializerConfig getForceKryoSerializerConfig() { + Configuration config = new Configuration(); + config.set(PipelineOptions.FORCE_KRYO, true); + return new SerializerConfigImpl(config); + } + + @Override + NotPojoElement generateRandomElement(int i) { + return new NotPojoElement(RANDOM.nextInt(100)); + } + + @Override + void initTestValues() { + emptyValue = Collections.emptyList(); + + updateEmpty = + Arrays.asList(new NotPojoElement(5), new NotPojoElement(7), new NotPojoElement(10)); + updateUnexpired = + Arrays.asList(new NotPojoElement(8), new NotPojoElement(9), new NotPojoElement(11)); + updateExpired = Arrays.asList(new NotPojoElement(1), new NotPojoElement(4)); + + getUpdateEmpty = updateEmpty; + getUnexpired = updateUnexpired; + getUpdateExpired = updateExpired; + } + + public static class NotPojoElement { Review Comment: I think it's ok we define it here. It is expected that we use the same classloader to run deserialization with the one to define the kryo serializer and/or the user job. The `RocksDBTtlStateTestBase::testCompactFilter` does require the contextClassLoader should know the class, otherwise an error would be thrown from the kyro serializer. -- 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]
