Java Code Examples for org.apache.flink.api.common.state.StateTtlConfig#RocksdbCompactFilterCleanupStrategy
The following examples show how to use
org.apache.flink.api.common.state.StateTtlConfig#RocksdbCompactFilterCleanupStrategy .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RocksDbTtlCompactFiltersManager.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
public void configCompactFilter( @Nonnull StateDescriptor<?, ?> stateDesc, TypeSerializer<?> stateSerializer) { StateTtlConfig ttlConfig = stateDesc.getTtlConfig(); if (ttlConfig.isEnabled() && ttlConfig.getCleanupStrategies().inRocksdbCompactFilter()) { if (!enableTtlCompactionFilter) { LOG.warn("Cannot configure RocksDB TTL compaction filter for state <{}>: " + "feature is disabled for the state backend.", stateDesc.getName()); return; } FlinkCompactionFilterFactory compactionFilterFactory = compactionFilterFactories.get(stateDesc.getName()); Preconditions.checkNotNull(compactionFilterFactory); long ttl = ttlConfig.getTtl().toMilliseconds(); StateTtlConfig.RocksdbCompactFilterCleanupStrategy rocksdbCompactFilterCleanupStrategy = ttlConfig.getCleanupStrategies().getRocksdbCompactFilterCleanupStrategy(); Preconditions.checkNotNull(rocksdbCompactFilterCleanupStrategy); long queryTimeAfterNumEntries = rocksdbCompactFilterCleanupStrategy.getQueryTimeAfterNumEntries(); FlinkCompactionFilter.Config config; if (stateDesc instanceof ListStateDescriptor) { TypeSerializer<?> elemSerializer = ((ListSerializer<?>) stateSerializer).getElementSerializer(); int len = elemSerializer.getLength(); if (len > 0) { config = FlinkCompactionFilter.Config.createForFixedElementList( ttl, queryTimeAfterNumEntries, len + 1); // plus one byte for list element delimiter } else { config = FlinkCompactionFilter.Config.createForList( ttl, queryTimeAfterNumEntries, new ListElementFilterFactory<>(elemSerializer.duplicate())); } } else if (stateDesc instanceof MapStateDescriptor) { config = FlinkCompactionFilter.Config.createForMap(ttl, queryTimeAfterNumEntries); } else { config = FlinkCompactionFilter.Config.createForValue(ttl, queryTimeAfterNumEntries); } compactionFilterFactory.configure(config); } }
Example 2
Source File: RocksDbTtlCompactFiltersManager.java From flink with Apache License 2.0 | 5 votes |
public void configCompactFilter( @Nonnull StateDescriptor<?, ?> stateDesc, TypeSerializer<?> stateSerializer) { StateTtlConfig ttlConfig = stateDesc.getTtlConfig(); if (ttlConfig.isEnabled() && ttlConfig.getCleanupStrategies().inRocksdbCompactFilter()) { if (!enableTtlCompactionFilter) { LOG.warn("Cannot configure RocksDB TTL compaction filter for state <{}>: " + "feature is disabled for the state backend.", stateDesc.getName()); return; } FlinkCompactionFilterFactory compactionFilterFactory = compactionFilterFactories.get(stateDesc.getName()); Preconditions.checkNotNull(compactionFilterFactory); long ttl = ttlConfig.getTtl().toMilliseconds(); StateTtlConfig.RocksdbCompactFilterCleanupStrategy rocksdbCompactFilterCleanupStrategy = ttlConfig.getCleanupStrategies().getRocksdbCompactFilterCleanupStrategy(); Preconditions.checkNotNull(rocksdbCompactFilterCleanupStrategy); long queryTimeAfterNumEntries = rocksdbCompactFilterCleanupStrategy.getQueryTimeAfterNumEntries(); FlinkCompactionFilter.Config config; if (stateDesc instanceof ListStateDescriptor) { TypeSerializer<?> elemSerializer = ((ListSerializer<?>) stateSerializer).getElementSerializer(); int len = elemSerializer.getLength(); if (len > 0) { config = FlinkCompactionFilter.Config.createForFixedElementList( ttl, queryTimeAfterNumEntries, len + 1); // plus one byte for list element delimiter } else { config = FlinkCompactionFilter.Config.createForList( ttl, queryTimeAfterNumEntries, new ListElementFilterFactory<>(elemSerializer.duplicate())); } } else if (stateDesc instanceof MapStateDescriptor) { config = FlinkCompactionFilter.Config.createForMap(ttl, queryTimeAfterNumEntries); } else { config = FlinkCompactionFilter.Config.createForValue(ttl, queryTimeAfterNumEntries); } compactionFilterFactory.configure(config); } }
Example 3
Source File: RocksDbTtlCompactFiltersManager.java From flink with Apache License 2.0 | 5 votes |
public void configCompactFilter( @Nonnull StateDescriptor<?, ?> stateDesc, TypeSerializer<?> stateSerializer) { StateTtlConfig ttlConfig = stateDesc.getTtlConfig(); if (ttlConfig.isEnabled() && ttlConfig.getCleanupStrategies().inRocksdbCompactFilter()) { FlinkCompactionFilterFactory compactionFilterFactory = compactionFilterFactories.get(stateDesc.getName()); Preconditions.checkNotNull(compactionFilterFactory); long ttl = ttlConfig.getTtl().toMilliseconds(); StateTtlConfig.RocksdbCompactFilterCleanupStrategy rocksdbCompactFilterCleanupStrategy = ttlConfig.getCleanupStrategies().getRocksdbCompactFilterCleanupStrategy(); Preconditions.checkNotNull(rocksdbCompactFilterCleanupStrategy); long queryTimeAfterNumEntries = rocksdbCompactFilterCleanupStrategy.getQueryTimeAfterNumEntries(); FlinkCompactionFilter.Config config; if (stateDesc instanceof ListStateDescriptor) { TypeSerializer<?> elemSerializer = ((ListSerializer<?>) stateSerializer).getElementSerializer(); int len = elemSerializer.getLength(); if (len > 0) { config = FlinkCompactionFilter.Config.createForFixedElementList( ttl, queryTimeAfterNumEntries, len + 1); // plus one byte for list element delimiter } else { config = FlinkCompactionFilter.Config.createForList( ttl, queryTimeAfterNumEntries, new ListElementFilterFactory<>(elemSerializer.duplicate())); } } else if (stateDesc instanceof MapStateDescriptor) { config = FlinkCompactionFilter.Config.createForMap(ttl, queryTimeAfterNumEntries); } else { config = FlinkCompactionFilter.Config.createForValue(ttl, queryTimeAfterNumEntries); } compactionFilterFactory.configure(config); } }