org.apache.flink.runtime.state.PriorityComparator Java Examples
The following examples show how to use
org.apache.flink.runtime.state.PriorityComparator.
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: HeapPriorityQueueSet.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
/** * 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 #2
Source File: KeyGroupPartitionedPriorityQueue.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@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 #3
Source File: KeyGroupPartitionedPriorityQueue.java From flink with Apache License 2.0 | 6 votes |
@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 #4
Source File: HeapPriorityQueueSet.java From flink with Apache License 2.0 | 6 votes |
/** * 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 #5
Source File: HeapPriorityQueueSet.java From flink with Apache License 2.0 | 6 votes |
/** * 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 #6
Source File: KeyGroupPartitionedPriorityQueue.java From flink with Apache License 2.0 | 6 votes |
@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 #7
Source File: HeapPriorityQueueSetFactory.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@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 #8
Source File: MockKeyedStateBackend.java From flink with Apache License 2.0 | 5 votes |
@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 #9
Source File: KeyGroupPartitionedPriorityQueueTest.java From flink with Apache License 2.0 | 5 votes |
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 #10
Source File: HeapPriorityQueue.java From flink with Apache License 2.0 | 5 votes |
/** * Creates an empty {@link HeapPriorityQueue} with the requested initial capacity. * * @param elementPriorityComparator comparator for the priority of contained elements. * @param minimumCapacity the minimum and initial capacity of this priority queue. */ @SuppressWarnings("unchecked") public HeapPriorityQueue( @Nonnull PriorityComparator<T> elementPriorityComparator, @Nonnegative int minimumCapacity) { super(minimumCapacity); this.elementPriorityComparator = elementPriorityComparator; }
Example #11
Source File: HeapPriorityQueueSetFactory.java From flink with Apache License 2.0 | 5 votes |
@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: RocksDBPriorityQueueSetFactory.java From flink with Apache License 2.0 | 5 votes |
@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 #13
Source File: MockKeyedStateBackend.java From flink with Apache License 2.0 | 5 votes |
@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: KeyGroupPartitionedPriorityQueueTest.java From flink with Apache License 2.0 | 5 votes |
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 #15
Source File: HeapPriorityQueue.java From flink with Apache License 2.0 | 5 votes |
/** * Creates an empty {@link HeapPriorityQueue} with the requested initial capacity. * * @param elementPriorityComparator comparator for the priority of contained elements. * @param minimumCapacity the minimum and initial capacity of this priority queue. */ @SuppressWarnings("unchecked") public HeapPriorityQueue( @Nonnull PriorityComparator<T> elementPriorityComparator, @Nonnegative int minimumCapacity) { super(minimumCapacity); this.elementPriorityComparator = elementPriorityComparator; }
Example #16
Source File: HeapPriorityQueueSetFactory.java From flink with Apache License 2.0 | 5 votes |
@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: RocksDBPriorityQueueSetFactory.java From flink with Apache License 2.0 | 5 votes |
@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 #18
Source File: MockKeyedStateBackend.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@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 #19
Source File: KeyGroupPartitionedPriorityQueueTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
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: HeapPriorityQueue.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
/** * Creates an empty {@link HeapPriorityQueue} with the requested initial capacity. * * @param elementPriorityComparator comparator for the priority of contained elements. * @param minimumCapacity the minimum and initial capacity of this priority queue. */ @SuppressWarnings("unchecked") public HeapPriorityQueue( @Nonnull PriorityComparator<T> elementPriorityComparator, @Nonnegative int minimumCapacity) { super(minimumCapacity); this.elementPriorityComparator = elementPriorityComparator; }
Example #21
Source File: RocksDBPriorityQueueSetFactory.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@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 #22
Source File: KeyGroupPartitionedPriorityQueue.java From flink with Apache License 2.0 | 4 votes |
InternalPriorityQueueComparator(@Nonnull PriorityComparator<T> elementPriorityComparator) { this.elementPriorityComparator = elementPriorityComparator; }
Example #23
Source File: KeyGroupPartitionedPriorityQueue.java From flink with Apache License 2.0 | 4 votes |
InternalPriorityQueueComparator(@Nonnull PriorityComparator<T> elementPriorityComparator) { this.elementPriorityComparator = elementPriorityComparator; }
Example #24
Source File: KeyGroupPartitionedPriorityQueue.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
InternalPriorityQueueComparator(@Nonnull PriorityComparator<T> elementPriorityComparator) { this.elementPriorityComparator = elementPriorityComparator; }
Example #25
Source File: KeyGroupPartitionedPriorityQueue.java From flink with Apache License 2.0 | 3 votes |
/** * Creates a new queue for a given key-group partition. * * @param keyGroupId the key-group of the elements managed by the produced queue. * @param numKeyGroups the total number of key-groups in the job. * @param elementPriorityComparator the comparator that determines the order of managed elements by priority. * @return a new queue for the given key-group. */ @Nonnull PQS create( @Nonnegative int keyGroupId, @Nonnegative int numKeyGroups, @Nonnull KeyExtractorFunction<T> keyExtractorFunction, @Nonnull PriorityComparator<T> elementPriorityComparator);
Example #26
Source File: KeyGroupPartitionedPriorityQueue.java From flink with Apache License 2.0 | 3 votes |
/** * Creates a new queue for a given key-group partition. * * @param keyGroupId the key-group of the elements managed by the produced queue. * @param numKeyGroups the total number of key-groups in the job. * @param elementPriorityComparator the comparator that determines the order of managed elements by priority. * @return a new queue for the given key-group. */ @Nonnull PQS create( @Nonnegative int keyGroupId, @Nonnegative int numKeyGroups, @Nonnull KeyExtractorFunction<T> keyExtractorFunction, @Nonnull PriorityComparator<T> elementPriorityComparator);
Example #27
Source File: KeyGroupPartitionedPriorityQueue.java From Flink-CEPplus with Apache License 2.0 | 3 votes |
/** * Creates a new queue for a given key-group partition. * * @param keyGroupId the key-group of the elements managed by the produced queue. * @param numKeyGroups the total number of key-groups in the job. * @param elementPriorityComparator the comparator that determines the order of managed elements by priority. * @return a new queue for the given key-group. */ @Nonnull PQS create( @Nonnegative int keyGroupId, @Nonnegative int numKeyGroups, @Nonnull KeyExtractorFunction<T> keyExtractorFunction, @Nonnull PriorityComparator<T> elementPriorityComparator);