org.apache.flink.runtime.state.KeyExtractorFunction Java Examples

The following examples show how to use org.apache.flink.runtime.state.KeyExtractorFunction. 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: 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 #2
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 #3
Source File: HeapPriorityQueueSet.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
/**
 * Creates an empty {@link HeapPriorityQueueSet} with the requested initial capacity.
 *
 * @param elementPriorityComparator comparator for the priority of contained elements.
 * @param keyExtractor function to extract a key from the contained elements.
 * @param minimumCapacity the minimum and initial capacity of this priority queue.
 * @param keyGroupRange the key-group range of the elements in this set.
 * @param totalNumberOfKeyGroups the total number of key-groups of the job.
 */
@SuppressWarnings("unchecked")
public HeapPriorityQueueSet(
	@Nonnull PriorityComparator<T> elementPriorityComparator,
	@Nonnull KeyExtractorFunction<T> keyExtractor,
	@Nonnegative int minimumCapacity,
	@Nonnull KeyGroupRange keyGroupRange,
	@Nonnegative int totalNumberOfKeyGroups) {

	super(elementPriorityComparator, minimumCapacity);

	this.keyExtractor = keyExtractor;

	this.totalNumberOfKeyGroups = totalNumberOfKeyGroups;
	this.keyGroupRange = keyGroupRange;

	final int keyGroupsInLocalRange = keyGroupRange.getNumberOfKeyGroups();
	final int deduplicationSetSize = 1 + minimumCapacity / keyGroupsInLocalRange;
	this.deduplicationMapsByKeyGroup = new HashMap[keyGroupsInLocalRange];
	for (int i = 0; i < keyGroupsInLocalRange; ++i) {
		deduplicationMapsByKeyGroup[i] = new HashMap<>(deduplicationSetSize);
	}
}
 
Example #4
Source File: KeyGroupPartitionedPriorityQueue.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
public KeyGroupPartitionedPriorityQueue(
	@Nonnull KeyExtractorFunction<T> keyExtractor,
	@Nonnull PriorityComparator<T> elementPriorityComparator,
	@Nonnull PartitionQueueSetFactory<T, PQ> orderedCacheFactory,
	@Nonnull KeyGroupRange keyGroupRange,
	@Nonnegative int totalKeyGroups) {

	this.keyExtractor = keyExtractor;
	this.totalKeyGroups = totalKeyGroups;
	this.firstKeyGroup = keyGroupRange.getStartKeyGroup();
	this.keyGroupedHeaps = (PQ[]) new InternalPriorityQueue[keyGroupRange.getNumberOfKeyGroups()];
	this.heapOfKeyGroupedHeaps = new HeapPriorityQueue<>(
		new InternalPriorityQueueComparator<>(elementPriorityComparator),
		keyGroupRange.getNumberOfKeyGroups());
	for (int i = 0; i < keyGroupedHeaps.length; i++) {
		final PQ keyGroupSubHeap =
			orderedCacheFactory.create(firstKeyGroup + i, totalKeyGroups, keyExtractor, elementPriorityComparator);
		keyGroupedHeaps[i] = keyGroupSubHeap;
		heapOfKeyGroupedHeaps.add(keyGroupSubHeap);
	}
}
 
Example #5
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 #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: KeyGroupPartitionedPriorityQueue.java    From flink with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
public KeyGroupPartitionedPriorityQueue(
	@Nonnull KeyExtractorFunction<T> keyExtractor,
	@Nonnull PriorityComparator<T> elementPriorityComparator,
	@Nonnull PartitionQueueSetFactory<T, PQ> orderedCacheFactory,
	@Nonnull KeyGroupRange keyGroupRange,
	@Nonnegative int totalKeyGroups) {

	this.keyExtractor = keyExtractor;
	this.totalKeyGroups = totalKeyGroups;
	this.firstKeyGroup = keyGroupRange.getStartKeyGroup();
	this.keyGroupedHeaps = (PQ[]) new InternalPriorityQueue[keyGroupRange.getNumberOfKeyGroups()];
	this.heapOfKeyGroupedHeaps = new HeapPriorityQueue<>(
		new InternalPriorityQueueComparator<>(elementPriorityComparator),
		keyGroupRange.getNumberOfKeyGroups());
	for (int i = 0; i < keyGroupedHeaps.length; i++) {
		final PQ keyGroupSubHeap =
			orderedCacheFactory.create(firstKeyGroup + i, totalKeyGroups, keyExtractor, elementPriorityComparator);
		keyGroupedHeaps[i] = keyGroupSubHeap;
		heapOfKeyGroupedHeaps.add(keyGroupSubHeap);
	}
}
 
Example #8
Source File: HeapPriorityQueueSet.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Creates an empty {@link HeapPriorityQueueSet} with the requested initial capacity.
 *
 * @param elementPriorityComparator comparator for the priority of contained elements.
 * @param keyExtractor function to extract a key from the contained elements.
 * @param minimumCapacity the minimum and initial capacity of this priority queue.
 * @param keyGroupRange the key-group range of the elements in this set.
 * @param totalNumberOfKeyGroups the total number of key-groups of the job.
 */
@SuppressWarnings("unchecked")
public HeapPriorityQueueSet(
	@Nonnull PriorityComparator<T> elementPriorityComparator,
	@Nonnull KeyExtractorFunction<T> keyExtractor,
	@Nonnegative int minimumCapacity,
	@Nonnull KeyGroupRange keyGroupRange,
	@Nonnegative int totalNumberOfKeyGroups) {

	super(elementPriorityComparator, minimumCapacity);

	this.keyExtractor = keyExtractor;

	this.totalNumberOfKeyGroups = totalNumberOfKeyGroups;
	this.keyGroupRange = keyGroupRange;

	final int keyGroupsInLocalRange = keyGroupRange.getNumberOfKeyGroups();
	final int deduplicationSetSize = 1 + minimumCapacity / keyGroupsInLocalRange;
	this.deduplicationMapsByKeyGroup = new HashMap[keyGroupsInLocalRange];
	for (int i = 0; i < keyGroupsInLocalRange; ++i) {
		deduplicationMapsByKeyGroup[i] = new HashMap<>(deduplicationSetSize);
	}
}
 
Example #9
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 #10
Source File: KeyGroupPartitionedPriorityQueue.java    From flink with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
public KeyGroupPartitionedPriorityQueue(
	@Nonnull KeyExtractorFunction<T> keyExtractor,
	@Nonnull PriorityComparator<T> elementPriorityComparator,
	@Nonnull PartitionQueueSetFactory<T, PQ> orderedCacheFactory,
	@Nonnull KeyGroupRange keyGroupRange,
	@Nonnegative int totalKeyGroups) {

	this.keyExtractor = keyExtractor;
	this.totalKeyGroups = totalKeyGroups;
	this.firstKeyGroup = keyGroupRange.getStartKeyGroup();
	this.keyGroupedHeaps = (PQ[]) new InternalPriorityQueue[keyGroupRange.getNumberOfKeyGroups()];
	this.heapOfKeyGroupedHeaps = new HeapPriorityQueue<>(
		new InternalPriorityQueueComparator<>(elementPriorityComparator),
		keyGroupRange.getNumberOfKeyGroups());
	for (int i = 0; i < keyGroupedHeaps.length; i++) {
		final PQ keyGroupSubHeap =
			orderedCacheFactory.create(firstKeyGroup + i, totalKeyGroups, keyExtractor, elementPriorityComparator);
		keyGroupedHeaps[i] = keyGroupSubHeap;
		heapOfKeyGroupedHeaps.add(keyGroupSubHeap);
	}
}
 
Example #11
Source File: HeapPriorityQueueSet.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Creates an empty {@link HeapPriorityQueueSet} with the requested initial capacity.
 *
 * @param elementPriorityComparator comparator for the priority of contained elements.
 * @param keyExtractor function to extract a key from the contained elements.
 * @param minimumCapacity the minimum and initial capacity of this priority queue.
 * @param keyGroupRange the key-group range of the elements in this set.
 * @param totalNumberOfKeyGroups the total number of key-groups of the job.
 */
@SuppressWarnings("unchecked")
public HeapPriorityQueueSet(
	@Nonnull PriorityComparator<T> elementPriorityComparator,
	@Nonnull KeyExtractorFunction<T> keyExtractor,
	@Nonnegative int minimumCapacity,
	@Nonnull KeyGroupRange keyGroupRange,
	@Nonnegative int totalNumberOfKeyGroups) {

	super(elementPriorityComparator, minimumCapacity);

	this.keyExtractor = keyExtractor;

	this.totalNumberOfKeyGroups = totalNumberOfKeyGroups;
	this.keyGroupRange = keyGroupRange;

	final int keyGroupsInLocalRange = keyGroupRange.getNumberOfKeyGroups();
	final int deduplicationSetSize = 1 + minimumCapacity / keyGroupsInLocalRange;
	this.deduplicationMapsByKeyGroup = new HashMap[keyGroupsInLocalRange];
	for (int i = 0; i < keyGroupsInLocalRange; ++i) {
		deduplicationMapsByKeyGroup[i] = new HashMap<>(deduplicationSetSize);
	}
}
 
Example #12
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 #13
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 #14
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 #15
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 #16
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 #17
Source File: HeapPriorityQueueSnapshotRestoreWrapper.java    From flink with Apache License 2.0 5 votes vote down vote up
public HeapPriorityQueueSnapshotRestoreWrapper(
	@Nonnull HeapPriorityQueueSet<T> priorityQueue,
	@Nonnull RegisteredPriorityQueueStateBackendMetaInfo<T> metaInfo,
	@Nonnull KeyExtractorFunction<T> keyExtractorFunction,
	@Nonnull KeyGroupRange localKeyGroupRange,
	int totalKeyGroups) {

	this.priorityQueue = priorityQueue;
	this.keyExtractorFunction = keyExtractorFunction;
	this.metaInfo = metaInfo;
	this.localKeyGroupRange = localKeyGroupRange;
	this.totalKeyGroups = totalKeyGroups;
}
 
Example #18
Source File: HeapPriorityQueueStateSnapshot.java    From flink with Apache License 2.0 5 votes vote down vote up
HeapPriorityQueueStateSnapshot(
	@Nonnull T[] heapArrayCopy,
	@Nonnull KeyExtractorFunction<T> keyExtractor,
	@Nonnull RegisteredPriorityQueueStateBackendMetaInfo<T> metaInfo,
	@Nonnull KeyGroupRange keyGroupRange,
	@Nonnegative int totalKeyGroups) {

	this.keyExtractor = keyExtractor;
	this.heapArrayCopy = heapArrayCopy;
	this.metaInfo = metaInfo;
	this.keyGroupRange = keyGroupRange;
	this.totalKeyGroups = totalKeyGroups;
}
 
Example #19
Source File: KeyGroupPartitionedPriorityQueueTest.java    From flink with Apache License 2.0 5 votes vote down vote up
public KeyGroupHeapPQSet(
	@Nonnull PriorityComparator<T> elementPriorityComparator,
	@Nonnull KeyExtractorFunction<T> keyExtractor,
	int minimumCapacity,
	@Nonnull KeyGroupRange keyGroupRange,
	int totalNumberOfKeyGroups) {
	super(elementPriorityComparator, keyExtractor, minimumCapacity, keyGroupRange, totalNumberOfKeyGroups);
	this.internalIndex = HeapPriorityQueueElement.NOT_CONTAINED;
}
 
Example #20
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 #21
Source File: KeyGroupPartitionedPriorityQueueTest.java    From flink with Apache License 2.0 5 votes vote down vote up
public KeyGroupHeapPQSet(
	@Nonnull PriorityComparator<T> elementPriorityComparator,
	@Nonnull KeyExtractorFunction<T> keyExtractor,
	int minimumCapacity,
	@Nonnull KeyGroupRange keyGroupRange,
	int totalNumberOfKeyGroups) {
	super(elementPriorityComparator, keyExtractor, minimumCapacity, keyGroupRange, totalNumberOfKeyGroups);
	this.internalIndex = HeapPriorityQueueElement.NOT_CONTAINED;
}
 
Example #22
Source File: HeapPriorityQueueStateSnapshot.java    From flink with Apache License 2.0 5 votes vote down vote up
HeapPriorityQueueStateSnapshot(
	@Nonnull T[] heapArrayCopy,
	@Nonnull KeyExtractorFunction<T> keyExtractor,
	@Nonnull RegisteredPriorityQueueStateBackendMetaInfo<T> metaInfo,
	@Nonnull KeyGroupRange keyGroupRange,
	@Nonnegative int totalKeyGroups) {

	this.keyExtractor = keyExtractor;
	this.heapArrayCopy = heapArrayCopy;
	this.metaInfo = metaInfo;
	this.keyGroupRange = keyGroupRange;
	this.totalKeyGroups = totalKeyGroups;
}
 
Example #23
Source File: HeapPriorityQueueSnapshotRestoreWrapper.java    From flink with Apache License 2.0 5 votes vote down vote up
public HeapPriorityQueueSnapshotRestoreWrapper(
	@Nonnull HeapPriorityQueueSet<T> priorityQueue,
	@Nonnull RegisteredPriorityQueueStateBackendMetaInfo<T> metaInfo,
	@Nonnull KeyExtractorFunction<T> keyExtractorFunction,
	@Nonnull KeyGroupRange localKeyGroupRange,
	int totalKeyGroups) {

	this.priorityQueue = priorityQueue;
	this.keyExtractorFunction = keyExtractorFunction;
	this.metaInfo = metaInfo;
	this.localKeyGroupRange = localKeyGroupRange;
	this.totalKeyGroups = totalKeyGroups;
}
 
Example #24
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 #25
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 #26
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 #27
Source File: KeyGroupPartitionedPriorityQueueTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
public KeyGroupHeapPQSet(
	@Nonnull PriorityComparator<T> elementPriorityComparator,
	@Nonnull KeyExtractorFunction<T> keyExtractor,
	int minimumCapacity,
	@Nonnull KeyGroupRange keyGroupRange,
	int totalNumberOfKeyGroups) {
	super(elementPriorityComparator, keyExtractor, minimumCapacity, keyGroupRange, totalNumberOfKeyGroups);
	this.internalIndex = HeapPriorityQueueElement.NOT_CONTAINED;
}
 
Example #28
Source File: HeapPriorityQueueStateSnapshot.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
HeapPriorityQueueStateSnapshot(
	@Nonnull T[] heapArrayCopy,
	@Nonnull KeyExtractorFunction<T> keyExtractor,
	@Nonnull RegisteredPriorityQueueStateBackendMetaInfo<T> metaInfo,
	@Nonnull KeyGroupRange keyGroupRange,
	@Nonnegative int totalKeyGroups) {

	this.keyExtractor = keyExtractor;
	this.heapArrayCopy = heapArrayCopy;
	this.metaInfo = metaInfo;
	this.keyGroupRange = keyGroupRange;
	this.totalKeyGroups = totalKeyGroups;
}
 
Example #29
Source File: HeapPriorityQueueSnapshotRestoreWrapper.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
public HeapPriorityQueueSnapshotRestoreWrapper(
	@Nonnull HeapPriorityQueueSet<T> priorityQueue,
	@Nonnull RegisteredPriorityQueueStateBackendMetaInfo<T> metaInfo,
	@Nonnull KeyExtractorFunction<T> keyExtractorFunction,
	@Nonnull KeyGroupRange localKeyGroupRange,
	int totalKeyGroups) {

	this.priorityQueue = priorityQueue;
	this.keyExtractorFunction = keyExtractorFunction;
	this.metaInfo = metaInfo;
	this.localKeyGroupRange = localKeyGroupRange;
	this.totalKeyGroups = totalKeyGroups;
}
 
Example #30
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);
}