org.rocksdb.FlinkCompactionFilter.FlinkCompactionFilterFactory Java Examples
The following examples show how to use
org.rocksdb.FlinkCompactionFilter.FlinkCompactionFilterFactory.
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 |
private void createAndSetCompactFilterFactory(String stateName, @Nonnull ColumnFamilyOptions options) { FlinkCompactionFilterFactory compactionFilterFactory = new FlinkCompactionFilterFactory(new TimeProviderWrapper(ttlTimeProvider), createRocksDbNativeLogger()); //noinspection resource options.setCompactionFilterFactory(compactionFilterFactory); compactionFilterFactories.put(stateName, compactionFilterFactory); }
Example #2
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 #3
Source File: RocksDbTtlCompactFiltersManager.java From flink with Apache License 2.0 | 5 votes |
private void createAndSetCompactFilterFactory(String stateName, @Nonnull ColumnFamilyOptions options) { FlinkCompactionFilterFactory compactionFilterFactory = new FlinkCompactionFilterFactory(new TimeProviderWrapper(ttlTimeProvider), createRocksDbNativeLogger()); //noinspection resource options.setCompactionFilterFactory(compactionFilterFactory); compactionFilterFactories.put(stateName, compactionFilterFactory); }
Example #4
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 #5
Source File: RocksDbTtlCompactFiltersManager.java From flink with Apache License 2.0 | 5 votes |
private void createAndSetCompactFilterFactory(String stateName, @Nonnull ColumnFamilyOptions options) { FlinkCompactionFilterFactory compactionFilterFactory = new FlinkCompactionFilterFactory(new TimeProviderWrapper(ttlTimeProvider), createRocksDbNativeLogger()); //noinspection resource options.setCompactionFilterFactory(compactionFilterFactory); compactionFilterFactories.put(stateName, compactionFilterFactory); }
Example #6
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); } }
Example #7
Source File: RocksDbTtlCompactFiltersManager.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
public void disposeAndClearRegisteredCompactionFactories() { for (FlinkCompactionFilterFactory factory : compactionFilterFactories.values()) { IOUtils.closeQuietly(factory); } compactionFilterFactories.clear(); }
Example #8
Source File: RocksDbTtlCompactFiltersManager.java From flink with Apache License 2.0 | 4 votes |
public void disposeAndClearRegisteredCompactionFactories() { for (FlinkCompactionFilterFactory factory : compactionFilterFactories.values()) { IOUtils.closeQuietly(factory); } compactionFilterFactories.clear(); }
Example #9
Source File: RocksDbTtlCompactFiltersManager.java From flink with Apache License 2.0 | 4 votes |
public void disposeAndClearRegisteredCompactionFactories() { for (FlinkCompactionFilterFactory factory : compactionFilterFactories.values()) { IOUtils.closeQuietly(factory); } compactionFilterFactories.clear(); }