org.apache.flink.runtime.state.heap.InternalKeyContext Java Examples

The following examples show how to use org.apache.flink.runtime.state.heap.InternalKeyContext. 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: AbstractKeyedStateBackend.java    From flink with Apache License 2.0 6 votes vote down vote up
public AbstractKeyedStateBackend(
	TaskKvStateRegistry kvStateRegistry,
	TypeSerializer<K> keySerializer,
	ClassLoader userCodeClassLoader,
	ExecutionConfig executionConfig,
	TtlTimeProvider ttlTimeProvider,
	CloseableRegistry cancelStreamRegistry,
	InternalKeyContext<K> keyContext) {
	this(
		kvStateRegistry,
		keySerializer,
		userCodeClassLoader,
		executionConfig,
		ttlTimeProvider,
		cancelStreamRegistry,
		determineStreamCompression(executionConfig),
		keyContext
	);
}
 
Example #2
Source File: AbstractKeyedStateBackend.java    From flink with Apache License 2.0 6 votes vote down vote up
public AbstractKeyedStateBackend(
	TaskKvStateRegistry kvStateRegistry,
	TypeSerializer<K> keySerializer,
	ClassLoader userCodeClassLoader,
	ExecutionConfig executionConfig,
	TtlTimeProvider ttlTimeProvider,
	CloseableRegistry cancelStreamRegistry,
	StreamCompressionDecorator keyGroupCompressionDecorator,
	InternalKeyContext<K> keyContext) {
	this.keyContext = Preconditions.checkNotNull(keyContext);
	this.numberOfKeyGroups = keyContext.getNumberOfKeyGroups();
	this.keyGroupRange = Preconditions.checkNotNull(keyContext.getKeyGroupRange());
	Preconditions.checkArgument(numberOfKeyGroups >= 1, "NumberOfKeyGroups must be a positive number");
	Preconditions.checkArgument(numberOfKeyGroups >= keyGroupRange.getNumberOfKeyGroups(), "The total number of key groups must be at least the number in the key group range assigned to this backend");

	this.kvStateRegistry = kvStateRegistry;
	this.keySerializer = keySerializer;
	this.userCodeClassLoader = Preconditions.checkNotNull(userCodeClassLoader);
	this.cancelStreamRegistry = cancelStreamRegistry;
	this.keyValueStatesByName = new HashMap<>();
	this.executionConfig = executionConfig;
	this.keyGroupCompressionDecorator = keyGroupCompressionDecorator;
	this.ttlTimeProvider = Preconditions.checkNotNull(ttlTimeProvider);
	this.keySelectionListeners = new ArrayList<>(1);
}
 
Example #3
Source File: AbstractKeyedStateBackend.java    From flink with Apache License 2.0 6 votes vote down vote up
public AbstractKeyedStateBackend(
	TaskKvStateRegistry kvStateRegistry,
	TypeSerializer<K> keySerializer,
	ClassLoader userCodeClassLoader,
	ExecutionConfig executionConfig,
	TtlTimeProvider ttlTimeProvider,
	CloseableRegistry cancelStreamRegistry,
	InternalKeyContext<K> keyContext) {
	this(
		kvStateRegistry,
		keySerializer,
		userCodeClassLoader,
		executionConfig,
		ttlTimeProvider,
		cancelStreamRegistry,
		determineStreamCompression(executionConfig),
		keyContext
	);
}
 
Example #4
Source File: AbstractKeyedStateBackend.java    From flink with Apache License 2.0 6 votes vote down vote up
public AbstractKeyedStateBackend(
	TaskKvStateRegistry kvStateRegistry,
	TypeSerializer<K> keySerializer,
	ClassLoader userCodeClassLoader,
	ExecutionConfig executionConfig,
	TtlTimeProvider ttlTimeProvider,
	CloseableRegistry cancelStreamRegistry,
	StreamCompressionDecorator keyGroupCompressionDecorator,
	InternalKeyContext<K> keyContext) {
	this.keyContext = Preconditions.checkNotNull(keyContext);
	this.numberOfKeyGroups = keyContext.getNumberOfKeyGroups();
	this.keyGroupRange = Preconditions.checkNotNull(keyContext.getKeyGroupRange());
	Preconditions.checkArgument(numberOfKeyGroups >= 1, "NumberOfKeyGroups must be a positive number");
	Preconditions.checkArgument(numberOfKeyGroups >= keyGroupRange.getNumberOfKeyGroups(), "The total number of key groups must be at least the number in the key group range assigned to this backend");

	this.kvStateRegistry = kvStateRegistry;
	this.keySerializer = keySerializer;
	this.userCodeClassLoader = Preconditions.checkNotNull(userCodeClassLoader);
	this.cancelStreamRegistry = cancelStreamRegistry;
	this.keyValueStatesByName = new HashMap<>();
	this.executionConfig = executionConfig;
	this.keyGroupCompressionDecorator = keyGroupCompressionDecorator;
	this.ttlTimeProvider = Preconditions.checkNotNull(ttlTimeProvider);
	this.keySelectionListeners = new ArrayList<>(1);
}
 
Example #5
Source File: MockKeyedStateBackend.java    From flink with Apache License 2.0 5 votes vote down vote up
MockKeyedStateBackend(
	TaskKvStateRegistry kvStateRegistry,
	TypeSerializer<K> keySerializer,
	ClassLoader userCodeClassLoader,
	ExecutionConfig executionConfig,
	TtlTimeProvider ttlTimeProvider,
	Map<String, Map<K, Map<Object, Object>>> stateValues,
	Map<String, StateSnapshotTransformer<Object>> stateSnapshotFilters,
	CloseableRegistry cancelStreamRegistry,
	InternalKeyContext<K> keyContext) {
	super(kvStateRegistry, keySerializer, userCodeClassLoader,
		executionConfig, ttlTimeProvider, cancelStreamRegistry, keyContext);
	this.stateValues = stateValues;
	this.stateSnapshotFilters = stateSnapshotFilters;
}
 
Example #6
Source File: MockKeyedStateBackend.java    From flink with Apache License 2.0 5 votes vote down vote up
MockKeyedStateBackend(
	TaskKvStateRegistry kvStateRegistry,
	TypeSerializer<K> keySerializer,
	ClassLoader userCodeClassLoader,
	ExecutionConfig executionConfig,
	TtlTimeProvider ttlTimeProvider,
	Map<String, Map<K, Map<Object, Object>>> stateValues,
	Map<String, StateSnapshotTransformer<Object>> stateSnapshotFilters,
	CloseableRegistry cancelStreamRegistry,
	InternalKeyContext<K> keyContext) {
	super(kvStateRegistry, keySerializer, userCodeClassLoader,
		executionConfig, ttlTimeProvider, cancelStreamRegistry, keyContext);
	this.stateValues = stateValues;
	this.stateSnapshotFilters = stateSnapshotFilters;
}
 
Example #7
Source File: RocksDBKeyedStateBackend.java    From flink with Apache License 2.0 4 votes vote down vote up
public RocksDBKeyedStateBackend(
	ClassLoader userCodeClassLoader,
	File instanceBasePath,
	DBOptions dbOptions,
	Function<String, ColumnFamilyOptions> columnFamilyOptionsFactory,
	TaskKvStateRegistry kvStateRegistry,
	TypeSerializer<K> keySerializer,
	ExecutionConfig executionConfig,
	TtlTimeProvider ttlTimeProvider,
	RocksDB db,
	LinkedHashMap<String, RocksDbKvStateInfo> kvStateInformation,
	int keyGroupPrefixBytes,
	CloseableRegistry cancelStreamRegistry,
	StreamCompressionDecorator keyGroupCompressionDecorator,
	ResourceGuard rocksDBResourceGuard,
	RocksDBSnapshotStrategyBase<K> checkpointSnapshotStrategy,
	RocksDBSnapshotStrategyBase<K> savepointSnapshotStrategy,
	RocksDBWriteBatchWrapper writeBatchWrapper,
	ColumnFamilyHandle defaultColumnFamilyHandle,
	RocksDBNativeMetricMonitor nativeMetricMonitor,
	RocksDBSerializedCompositeKeyBuilder<K> sharedRocksKeyBuilder,
	PriorityQueueSetFactory priorityQueueFactory,
	RocksDbTtlCompactFiltersManager ttlCompactFiltersManager,
	InternalKeyContext<K> keyContext) {

	super(
		kvStateRegistry,
		keySerializer,
		userCodeClassLoader,
		executionConfig,
		ttlTimeProvider,
		cancelStreamRegistry,
		keyGroupCompressionDecorator,
		keyContext);

	this.ttlCompactFiltersManager = ttlCompactFiltersManager;

	// ensure that we use the right merge operator, because other code relies on this
	this.columnFamilyOptionsFactory = Preconditions.checkNotNull(columnFamilyOptionsFactory);

	this.dbOptions = Preconditions.checkNotNull(dbOptions);

	this.instanceBasePath = Preconditions.checkNotNull(instanceBasePath);

	this.keyGroupPrefixBytes = keyGroupPrefixBytes;
	this.kvStateInformation = kvStateInformation;

	this.writeOptions = new WriteOptions().setDisableWAL(true);
	this.db = db;
	this.rocksDBResourceGuard = rocksDBResourceGuard;
	this.checkpointSnapshotStrategy = checkpointSnapshotStrategy;
	this.savepointSnapshotStrategy = savepointSnapshotStrategy;
	this.writeBatchWrapper = writeBatchWrapper;
	this.defaultColumnFamily = defaultColumnFamilyHandle;
	this.nativeMetricMonitor = nativeMetricMonitor;
	this.sharedRocksKeyBuilder = sharedRocksKeyBuilder;
	this.priorityQueueFactory = priorityQueueFactory;
}
 
Example #8
Source File: RocksDBKeyedStateBackend.java    From flink with Apache License 2.0 4 votes vote down vote up
public RocksDBKeyedStateBackend(
	ClassLoader userCodeClassLoader,
	File instanceBasePath,
	RocksDBResourceContainer optionsContainer,
	Function<String, ColumnFamilyOptions> columnFamilyOptionsFactory,
	TaskKvStateRegistry kvStateRegistry,
	TypeSerializer<K> keySerializer,
	ExecutionConfig executionConfig,
	TtlTimeProvider ttlTimeProvider,
	RocksDB db,
	LinkedHashMap<String, RocksDbKvStateInfo> kvStateInformation,
	int keyGroupPrefixBytes,
	CloseableRegistry cancelStreamRegistry,
	StreamCompressionDecorator keyGroupCompressionDecorator,
	ResourceGuard rocksDBResourceGuard,
	RocksDBSnapshotStrategyBase<K> checkpointSnapshotStrategy,
	RocksDBSnapshotStrategyBase<K> savepointSnapshotStrategy,
	RocksDBWriteBatchWrapper writeBatchWrapper,
	ColumnFamilyHandle defaultColumnFamilyHandle,
	RocksDBNativeMetricMonitor nativeMetricMonitor,
	RocksDBSerializedCompositeKeyBuilder<K> sharedRocksKeyBuilder,
	PriorityQueueSetFactory priorityQueueFactory,
	RocksDbTtlCompactFiltersManager ttlCompactFiltersManager,
	InternalKeyContext<K> keyContext,
	@Nonnegative long writeBatchSize) {

	super(
		kvStateRegistry,
		keySerializer,
		userCodeClassLoader,
		executionConfig,
		ttlTimeProvider,
		cancelStreamRegistry,
		keyGroupCompressionDecorator,
		keyContext);

	this.ttlCompactFiltersManager = ttlCompactFiltersManager;

	// ensure that we use the right merge operator, because other code relies on this
	this.columnFamilyOptionsFactory = Preconditions.checkNotNull(columnFamilyOptionsFactory);

	this.optionsContainer = Preconditions.checkNotNull(optionsContainer);

	this.instanceBasePath = Preconditions.checkNotNull(instanceBasePath);

	this.keyGroupPrefixBytes = keyGroupPrefixBytes;
	this.kvStateInformation = kvStateInformation;

	this.writeOptions = optionsContainer.getWriteOptions();
	this.readOptions = optionsContainer.getReadOptions();
	checkArgument(writeBatchSize >= 0, "Write batch size have to be no negative value.");
	this.writeBatchSize = writeBatchSize;
	this.db = db;
	this.rocksDBResourceGuard = rocksDBResourceGuard;
	this.checkpointSnapshotStrategy = checkpointSnapshotStrategy;
	this.savepointSnapshotStrategy = savepointSnapshotStrategy;
	this.writeBatchWrapper = writeBatchWrapper;
	this.defaultColumnFamily = defaultColumnFamilyHandle;
	this.nativeMetricMonitor = nativeMetricMonitor;
	this.sharedRocksKeyBuilder = sharedRocksKeyBuilder;
	this.priorityQueueFactory = priorityQueueFactory;
}