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

The following examples show how to use org.apache.flink.runtime.state.heap.KeyGroupPartitionedPriorityQueue. 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: KeyGroupPartitionedPriorityQueueWithRocksDBStoreTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
private KeyGroupPartitionedPriorityQueue.PartitionQueueSetFactory<
	TestElement, RocksDBCachingPriorityQueueSet<TestElement>> newFactory() {

	return (keyGroupId, numKeyGroups, keyExtractorFunction, elementComparator) -> {
		DataOutputSerializer outputStreamWithPos = new DataOutputSerializer(128);
		DataInputDeserializer inputStreamWithPos = new DataInputDeserializer();
		int keyGroupPrefixBytes = RocksDBKeySerializationUtils.computeRequiredBytesInKeyGroupPrefix(numKeyGroups);
		TreeOrderedSetCache orderedSetCache = new TreeOrderedSetCache(32);
		return new RocksDBCachingPriorityQueueSet<>(
			keyGroupId,
			keyGroupPrefixBytes,
			rocksDBResource.getRocksDB(),
			rocksDBResource.getDefaultColumnFamily(),
			TestElementSerializer.INSTANCE,
			outputStreamWithPos,
			inputStreamWithPos,
			rocksDBResource.getBatchWrapper(),
			orderedSetCache);
	};
}
 
Example #2
Source File: KeyGroupPartitionedPriorityQueueWithRocksDBStoreTest.java    From flink with Apache License 2.0 6 votes vote down vote up
private KeyGroupPartitionedPriorityQueue.PartitionQueueSetFactory<
	TestElement, RocksDBCachingPriorityQueueSet<TestElement>> newFactory() {

	return (keyGroupId, numKeyGroups, keyExtractorFunction, elementComparator) -> {
		DataOutputSerializer outputStreamWithPos = new DataOutputSerializer(128);
		DataInputDeserializer inputStreamWithPos = new DataInputDeserializer();
		int keyGroupPrefixBytes = RocksDBKeySerializationUtils.computeRequiredBytesInKeyGroupPrefix(numKeyGroups);
		TreeOrderedSetCache orderedSetCache = new TreeOrderedSetCache(32);
		return new RocksDBCachingPriorityQueueSet<>(
			keyGroupId,
			keyGroupPrefixBytes,
			rocksDBResource.getRocksDB(),
			rocksDBResource.getDefaultColumnFamily(),
			TestElementSerializer.INSTANCE,
			outputStreamWithPos,
			inputStreamWithPos,
			rocksDBResource.getBatchWrapper(),
			orderedSetCache);
	};
}
 
Example #3
Source File: KeyGroupPartitionedPriorityQueueWithRocksDBStoreTest.java    From flink with Apache License 2.0 6 votes vote down vote up
private KeyGroupPartitionedPriorityQueue.PartitionQueueSetFactory<
	TestElement, RocksDBCachingPriorityQueueSet<TestElement>> newFactory() {

	return (keyGroupId, numKeyGroups, keyExtractorFunction, elementComparator) -> {
		DataOutputSerializer outputStreamWithPos = new DataOutputSerializer(128);
		DataInputDeserializer inputStreamWithPos = new DataInputDeserializer();
		int keyGroupPrefixBytes = RocksDBKeySerializationUtils.computeRequiredBytesInKeyGroupPrefix(numKeyGroups);
		TreeOrderedSetCache orderedSetCache = new TreeOrderedSetCache(32);
		return new RocksDBCachingPriorityQueueSet<>(
			keyGroupId,
			keyGroupPrefixBytes,
			rocksDBResource.getRocksDB(),
			rocksDBResource.getReadOptions(),
			rocksDBResource.getDefaultColumnFamily(),
			TestElementSerializer.INSTANCE,
			outputStreamWithPos,
			inputStreamWithPos,
			rocksDBResource.getBatchWrapper(),
			orderedSetCache);
	};
}
 
Example #4
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 #5
Source File: KeyGroupPartitionedPriorityQueueWithRocksDBStoreTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
protected InternalPriorityQueue<TestElement> newPriorityQueue(int initialCapacity) {
	return new KeyGroupPartitionedPriorityQueue<>(
		KEY_EXTRACTOR_FUNCTION,
		TEST_ELEMENT_PRIORITY_COMPARATOR,
		newFactory(),
		KEY_GROUP_RANGE, KEY_GROUP_RANGE.getNumberOfKeyGroups());
}
 
Example #6
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 #7
Source File: KeyGroupPartitionedPriorityQueueWithRocksDBStoreTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
protected InternalPriorityQueue<TestElement> newPriorityQueue(int initialCapacity) {
	return new KeyGroupPartitionedPriorityQueue<>(
		KEY_EXTRACTOR_FUNCTION,
		TEST_ELEMENT_PRIORITY_COMPARATOR,
		newFactory(),
		KEY_GROUP_RANGE, KEY_GROUP_RANGE.getNumberOfKeyGroups());
}
 
Example #8
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 #9
Source File: KeyGroupPartitionedPriorityQueueWithRocksDBStoreTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
protected InternalPriorityQueue<TestElement> newPriorityQueue(int initialCapacity) {
	return new KeyGroupPartitionedPriorityQueue<>(
		KEY_EXTRACTOR_FUNCTION,
		TEST_ELEMENT_PRIORITY_COMPARATOR,
		newFactory(),
		KEY_GROUP_RANGE, KEY_GROUP_RANGE.getNumberOfKeyGroups());
}