azagrebin commented on a change in pull request #7163: [FLINK-10471][State TTL] State TTL cleanup using RocksDb compaction filter URL: https://github.com/apache/flink/pull/7163#discussion_r253942213
########## File path: flink-state-backends/flink-statebackend-rocksdb/src/main/java/org/apache/flink/contrib/streaming/state/ttl/RocksDbTtlCompactFiltersManager.java ########## @@ -0,0 +1,235 @@ +/* + * 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.contrib.streaming.state.ttl; + +import org.apache.flink.api.common.state.ListStateDescriptor; +import org.apache.flink.api.common.state.MapStateDescriptor; +import org.apache.flink.api.common.state.StateDescriptor; +import org.apache.flink.api.common.state.StateTtlConfig; +import org.apache.flink.api.common.typeutils.TypeSerializer; +import org.apache.flink.api.common.typeutils.TypeSerializerSnapshot; +import org.apache.flink.api.common.typeutils.base.ListSerializer; +import org.apache.flink.core.memory.DataInputDeserializer; +import org.apache.flink.runtime.state.RegisteredKeyValueStateBackendMetaInfo; +import org.apache.flink.runtime.state.RegisteredStateMetaInfoBase; +import org.apache.flink.runtime.state.metainfo.StateMetaInfoSnapshot; +import org.apache.flink.runtime.state.ttl.TtlStateFactory; +import org.apache.flink.runtime.state.ttl.TtlTimeProvider; +import org.apache.flink.runtime.state.ttl.TtlUtils; +import org.apache.flink.runtime.state.ttl.TtlValue; +import org.apache.flink.util.FlinkRuntimeException; +import org.apache.flink.util.IOUtils; +import org.apache.flink.util.Preconditions; + +import org.rocksdb.ColumnFamilyOptions; +import org.rocksdb.DBOptions; +import org.rocksdb.FlinkCompactionFilter; +import org.rocksdb.FlinkCompactionFilter.FlinkCompactionFilterFactory; +import org.rocksdb.InfoLogLevel; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.annotation.Nonnull; + +import java.io.IOException; +import java.util.LinkedHashMap; + +/** RocksDB compaction filter utils for state with TTL. */ +public class RocksDbTtlCompactFiltersManager { + private static final Logger LOG = LoggerFactory.getLogger(FlinkCompactionFilter.class); + + /** Enables RocksDb compaction filter for State with TTL. */ + private final boolean enableTtlCompactionFilter; + + /** Registered compaction filter factories */ + private final LinkedHashMap<String, FlinkCompactionFilterFactory> compactionFilterFactories; Review comment: It was part of `RocksDbKvStateInfo` all the time. I just changed it with the last commit. My reasoning was, as you also mentioned, to keep TTL stuff separated so that keyed backend code is cleaner. I do not see arguments to keep it together at the moment, also closing order in dispose method seems to be tricky. This was also the reason why it was not a separate commit initially because it was done all together, though I agree as of now it should a separate commit, sorry that I did not get to it :) ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
