Java Code Examples for org.apache.flink.runtime.state.KeyExtractorFunction#forKeyedObjects()

The following examples show how to use org.apache.flink.runtime.state.KeyExtractorFunction#forKeyedObjects() . 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: HeapKeyedStateBackend.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Nonnull
private <T extends HeapPriorityQueueElement & PriorityComparable & Keyed> KeyGroupedInternalPriorityQueue<T> createInternal(
	RegisteredPriorityQueueStateBackendMetaInfo<T> metaInfo) {

	final String stateName = metaInfo.getName();
	final HeapPriorityQueueSet<T> priorityQueue = priorityQueueSetFactory.create(
		stateName,
		metaInfo.getElementSerializer());

	HeapPriorityQueueSnapshotRestoreWrapper<T> wrapper =
		new HeapPriorityQueueSnapshotRestoreWrapper<>(
			priorityQueue,
			metaInfo,
			KeyExtractorFunction.forKeyedObjects(),
			keyGroupRange,
			numberOfKeyGroups);

	registeredPQStates.put(stateName, wrapper);
	return priorityQueue;
}
 
Example 2
Source File: HeapRestoreOperation.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
private <T extends HeapPriorityQueueElement & PriorityComparable & Keyed> void createInternal(
	RegisteredPriorityQueueStateBackendMetaInfo<T> metaInfo) {

	final String stateName = metaInfo.getName();
	final HeapPriorityQueueSet<T> priorityQueue = priorityQueueSetFactory.create(
		stateName,
		metaInfo.getElementSerializer());

	HeapPriorityQueueSnapshotRestoreWrapper<T> wrapper =
		new HeapPriorityQueueSnapshotRestoreWrapper<>(
			priorityQueue,
			metaInfo,
			KeyExtractorFunction.forKeyedObjects(),
			keyGroupRange,
			numberOfKeyGroups);

	registeredPQStates.put(stateName, wrapper);
}
 
Example 3
Source File: HeapKeyedStateBackend.java    From flink with Apache License 2.0 6 votes vote down vote up
@Nonnull
private <T extends HeapPriorityQueueElement & PriorityComparable & Keyed> KeyGroupedInternalPriorityQueue<T> createInternal(
	RegisteredPriorityQueueStateBackendMetaInfo<T> metaInfo) {

	final String stateName = metaInfo.getName();
	final HeapPriorityQueueSet<T> priorityQueue = priorityQueueSetFactory.create(
		stateName,
		metaInfo.getElementSerializer());

	HeapPriorityQueueSnapshotRestoreWrapper<T> wrapper =
		new HeapPriorityQueueSnapshotRestoreWrapper<>(
			priorityQueue,
			metaInfo,
			KeyExtractorFunction.forKeyedObjects(),
			keyGroupRange,
			numberOfKeyGroups);

	registeredPQStates.put(stateName, wrapper);
	return priorityQueue;
}
 
Example 4
Source File: HeapRestoreOperation.java    From flink with Apache License 2.0 6 votes vote down vote up
private <T extends HeapPriorityQueueElement & PriorityComparable & Keyed> void createInternal(
	RegisteredPriorityQueueStateBackendMetaInfo<T> metaInfo) {

	final String stateName = metaInfo.getName();
	final HeapPriorityQueueSet<T> priorityQueue = priorityQueueSetFactory.create(
		stateName,
		metaInfo.getElementSerializer());

	HeapPriorityQueueSnapshotRestoreWrapper<T> wrapper =
		new HeapPriorityQueueSnapshotRestoreWrapper<>(
			priorityQueue,
			metaInfo,
			KeyExtractorFunction.forKeyedObjects(),
			keyGroupRange,
			numberOfKeyGroups);

	registeredPQStates.put(stateName, wrapper);
}
 
Example 5
Source File: HeapKeyedStateBackend.java    From flink with Apache License 2.0 6 votes vote down vote up
@Nonnull
private <T extends HeapPriorityQueueElement & PriorityComparable & Keyed> KeyGroupedInternalPriorityQueue<T> createInternal(
	RegisteredPriorityQueueStateBackendMetaInfo<T> metaInfo) {

	final String stateName = metaInfo.getName();
	final HeapPriorityQueueSet<T> priorityQueue = priorityQueueSetFactory.create(
		stateName,
		metaInfo.getElementSerializer());

	HeapPriorityQueueSnapshotRestoreWrapper<T> wrapper =
		new HeapPriorityQueueSnapshotRestoreWrapper<>(
			priorityQueue,
			metaInfo,
			KeyExtractorFunction.forKeyedObjects(),
			keyGroupRange,
			numberOfKeyGroups);

	registeredPQStates.put(stateName, wrapper);
	return priorityQueue;
}
 
Example 6
Source File: HeapRestoreOperation.java    From flink with Apache License 2.0 6 votes vote down vote up
private <T extends HeapPriorityQueueElement & PriorityComparable & Keyed> void createInternal(
	RegisteredPriorityQueueStateBackendMetaInfo<T> metaInfo) {

	final String stateName = metaInfo.getName();
	final HeapPriorityQueueSet<T> priorityQueue = priorityQueueSetFactory.create(
		stateName,
		metaInfo.getElementSerializer());

	HeapPriorityQueueSnapshotRestoreWrapper<T> wrapper =
		new HeapPriorityQueueSnapshotRestoreWrapper<>(
			priorityQueue,
			metaInfo,
			KeyExtractorFunction.forKeyedObjects(),
			keyGroupRange,
			numberOfKeyGroups);

	registeredPQStates.put(stateName, wrapper);
}
 
Example 7
Source File: RocksDBPriorityQueueSetFactory.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public <T extends HeapPriorityQueueElement & PriorityComparable & Keyed> KeyGroupedInternalPriorityQueue<T>
create(@Nonnull String stateName, @Nonnull TypeSerializer<T> byteOrderedElementSerializer) {

	final RocksDBKeyedStateBackend.RocksDbKvStateInfo stateCFHandle =
		tryRegisterPriorityQueueMetaInfo(stateName, byteOrderedElementSerializer);

	final ColumnFamilyHandle columnFamilyHandle = stateCFHandle.columnFamilyHandle;

	return new KeyGroupPartitionedPriorityQueue<>(
		KeyExtractorFunction.forKeyedObjects(),
		PriorityComparator.forPriorityComparableObjects(),
		new KeyGroupPartitionedPriorityQueue.PartitionQueueSetFactory<T, RocksDBCachingPriorityQueueSet<T>>() {
			@Nonnull
			@Override
			public RocksDBCachingPriorityQueueSet<T> create(
				int keyGroupId,
				int numKeyGroups,
				@Nonnull KeyExtractorFunction<T> keyExtractor,
				@Nonnull PriorityComparator<T> elementPriorityComparator) {
				TreeOrderedSetCache orderedSetCache = new TreeOrderedSetCache(DEFAULT_CACHES_SIZE);
				return new RocksDBCachingPriorityQueueSet<>(
					keyGroupId,
					keyGroupPrefixBytes,
					db,
					columnFamilyHandle,
					byteOrderedElementSerializer,
					sharedElementOutView,
					sharedElementInView,
					writeBatchWrapper,
					orderedSetCache
				);
			}
		},
		keyGroupRange,
		numberOfKeyGroups);
}
 
Example 8
Source File: HeapPriorityQueueSetFactory.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public <T extends HeapPriorityQueueElement & PriorityComparable & Keyed> HeapPriorityQueueSet<T> create(
	@Nonnull String stateName,
	@Nonnull TypeSerializer<T> byteOrderedElementSerializer) {

	return new HeapPriorityQueueSet<>(
		PriorityComparator.forPriorityComparableObjects(),
		KeyExtractorFunction.forKeyedObjects(),
		minimumCapacity,
		keyGroupRange,
		totalKeyGroups);
}
 
Example 9
Source File: MockKeyedStateBackend.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public <T extends HeapPriorityQueueElement & PriorityComparable & Keyed> KeyGroupedInternalPriorityQueue<T>
create(
	@Nonnull String stateName,
	@Nonnull TypeSerializer<T> byteOrderedElementSerializer) {
	return new HeapPriorityQueueSet<>(
		PriorityComparator.forPriorityComparableObjects(),
		KeyExtractorFunction.forKeyedObjects(),
		0,
		keyGroupRange,
		0);
}
 
Example 10
Source File: RocksDBPriorityQueueSetFactory.java    From flink with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public <T extends HeapPriorityQueueElement & PriorityComparable & Keyed> KeyGroupedInternalPriorityQueue<T>
create(@Nonnull String stateName, @Nonnull TypeSerializer<T> byteOrderedElementSerializer) {

	final RocksDBKeyedStateBackend.RocksDbKvStateInfo stateCFHandle =
		tryRegisterPriorityQueueMetaInfo(stateName, byteOrderedElementSerializer);

	final ColumnFamilyHandle columnFamilyHandle = stateCFHandle.columnFamilyHandle;

	return new KeyGroupPartitionedPriorityQueue<>(
		KeyExtractorFunction.forKeyedObjects(),
		PriorityComparator.forPriorityComparableObjects(),
		new KeyGroupPartitionedPriorityQueue.PartitionQueueSetFactory<T, RocksDBCachingPriorityQueueSet<T>>() {
			@Nonnull
			@Override
			public RocksDBCachingPriorityQueueSet<T> create(
				int keyGroupId,
				int numKeyGroups,
				@Nonnull KeyExtractorFunction<T> keyExtractor,
				@Nonnull PriorityComparator<T> elementPriorityComparator) {
				TreeOrderedSetCache orderedSetCache = new TreeOrderedSetCache(DEFAULT_CACHES_SIZE);
				return new RocksDBCachingPriorityQueueSet<>(
					keyGroupId,
					keyGroupPrefixBytes,
					db,
					columnFamilyHandle,
					byteOrderedElementSerializer,
					sharedElementOutView,
					sharedElementInView,
					writeBatchWrapper,
					orderedSetCache
				);
			}
		},
		keyGroupRange,
		numberOfKeyGroups);
}
 
Example 11
Source File: HeapPriorityQueueSetFactory.java    From flink with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public <T extends HeapPriorityQueueElement & PriorityComparable & Keyed> HeapPriorityQueueSet<T> create(
	@Nonnull String stateName,
	@Nonnull TypeSerializer<T> byteOrderedElementSerializer) {

	return new HeapPriorityQueueSet<>(
		PriorityComparator.forPriorityComparableObjects(),
		KeyExtractorFunction.forKeyedObjects(),
		minimumCapacity,
		keyGroupRange,
		totalKeyGroups);
}
 
Example 12
Source File: MockKeyedStateBackend.java    From flink with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public <T extends HeapPriorityQueueElement & PriorityComparable & Keyed> KeyGroupedInternalPriorityQueue<T>
create(
	@Nonnull String stateName,
	@Nonnull TypeSerializer<T> byteOrderedElementSerializer) {
	return new HeapPriorityQueueSet<>(
		PriorityComparator.forPriorityComparableObjects(),
		KeyExtractorFunction.forKeyedObjects(),
		0,
		keyGroupRange,
		0);
}
 
Example 13
Source File: RocksDBPriorityQueueSetFactory.java    From flink with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public <T extends HeapPriorityQueueElement & PriorityComparable & Keyed> KeyGroupedInternalPriorityQueue<T>
create(@Nonnull String stateName, @Nonnull TypeSerializer<T> byteOrderedElementSerializer) {

	final RocksDBKeyedStateBackend.RocksDbKvStateInfo stateCFHandle =
		tryRegisterPriorityQueueMetaInfo(stateName, byteOrderedElementSerializer);

	final ColumnFamilyHandle columnFamilyHandle = stateCFHandle.columnFamilyHandle;

	return new KeyGroupPartitionedPriorityQueue<>(
		KeyExtractorFunction.forKeyedObjects(),
		PriorityComparator.forPriorityComparableObjects(),
		new KeyGroupPartitionedPriorityQueue.PartitionQueueSetFactory<T, RocksDBCachingPriorityQueueSet<T>>() {
			@Nonnull
			@Override
			public RocksDBCachingPriorityQueueSet<T> create(
				int keyGroupId,
				int numKeyGroups,
				@Nonnull KeyExtractorFunction<T> keyExtractor,
				@Nonnull PriorityComparator<T> elementPriorityComparator) {
				TreeOrderedSetCache orderedSetCache = new TreeOrderedSetCache(DEFAULT_CACHES_SIZE);
				return new RocksDBCachingPriorityQueueSet<>(
					keyGroupId,
					keyGroupPrefixBytes,
					db,
					readOptions,
					columnFamilyHandle,
					byteOrderedElementSerializer,
					sharedElementOutView,
					sharedElementInView,
					writeBatchWrapper,
					orderedSetCache
				);
			}
		},
		keyGroupRange,
		numberOfKeyGroups);
}
 
Example 14
Source File: HeapPriorityQueueSetFactory.java    From flink with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public <T extends HeapPriorityQueueElement & PriorityComparable & Keyed> HeapPriorityQueueSet<T> create(
	@Nonnull String stateName,
	@Nonnull TypeSerializer<T> byteOrderedElementSerializer) {

	return new HeapPriorityQueueSet<>(
		PriorityComparator.forPriorityComparableObjects(),
		KeyExtractorFunction.forKeyedObjects(),
		minimumCapacity,
		keyGroupRange,
		totalKeyGroups);
}
 
Example 15
Source File: MockKeyedStateBackend.java    From flink with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public <T extends HeapPriorityQueueElement & PriorityComparable & Keyed> KeyGroupedInternalPriorityQueue<T>
create(
	@Nonnull String stateName,
	@Nonnull TypeSerializer<T> byteOrderedElementSerializer) {
	return new HeapPriorityQueueSet<>(
		PriorityComparator.forPriorityComparableObjects(),
		KeyExtractorFunction.forKeyedObjects(),
		0,
		keyGroupRange,
		0);
}