Java Code Examples for org.apache.flink.runtime.state.KeyGroupPartitioner#createKeyGroupPartitionReader()
The following examples show how to use
org.apache.flink.runtime.state.KeyGroupPartitioner#createKeyGroupPartitionReader() .
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: HeapPriorityQueueSnapshotRestoreWrapper.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Nonnull @Override public StateSnapshotKeyGroupReader keyGroupReader(int readVersionHint) { final TypeSerializer<T> elementSerializer = metaInfo.getElementSerializer(); return KeyGroupPartitioner.createKeyGroupPartitionReader( elementSerializer::deserialize, //we know that this does not deliver nulls, because we never write nulls (element, keyGroupId) -> priorityQueue.add(element)); }
Example 2
Source File: StateTableByKeyGroupReaders.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
private static <K, N, S> StateSnapshotKeyGroupReader createV2PlusReader(StateTable<K, N, S> stateTable) { final TypeSerializer<K> keySerializer = stateTable.keyContext.getKeySerializer(); final TypeSerializer<N> namespaceSerializer = stateTable.getNamespaceSerializer(); final TypeSerializer<S> stateSerializer = stateTable.getStateSerializer(); final Tuple3<N, K, S> buffer = new Tuple3<>(); return KeyGroupPartitioner.createKeyGroupPartitionReader((in) -> { buffer.f0 = namespaceSerializer.deserialize(in); buffer.f1 = keySerializer.deserialize(in); buffer.f2 = stateSerializer.deserialize(in); return buffer; }, (element, keyGroupId1) -> stateTable.put(element.f1, keyGroupId1, element.f0, element.f2)); }
Example 3
Source File: HeapPriorityQueueSnapshotRestoreWrapper.java From flink with Apache License 2.0 | 5 votes |
@Nonnull @Override public StateSnapshotKeyGroupReader keyGroupReader(int readVersionHint) { final TypeSerializer<T> elementSerializer = metaInfo.getElementSerializer(); return KeyGroupPartitioner.createKeyGroupPartitionReader( elementSerializer::deserialize, //we know that this does not deliver nulls, because we never write nulls (element, keyGroupId) -> priorityQueue.add(element)); }
Example 4
Source File: StateTableByKeyGroupReaders.java From flink with Apache License 2.0 | 5 votes |
private static <K, N, S> StateSnapshotKeyGroupReader createV2PlusReader( StateTable<K, N, S> stateTable) { final TypeSerializer<N> namespaceSerializer = stateTable.getNamespaceSerializer(); final TypeSerializer<S> stateSerializer = stateTable.getStateSerializer(); final TypeSerializer<K> keySerializer = stateTable.keySerializer; final Tuple3<N, K, S> buffer = new Tuple3<>(); return KeyGroupPartitioner.createKeyGroupPartitionReader((in) -> { buffer.f0 = namespaceSerializer.deserialize(in); buffer.f1 = keySerializer.deserialize(in); buffer.f2 = stateSerializer.deserialize(in); return buffer; }, (element, keyGroupId1) -> stateTable.put(element.f1, keyGroupId1, element.f0, element.f2)); }
Example 5
Source File: HeapPriorityQueueSnapshotRestoreWrapper.java From flink with Apache License 2.0 | 5 votes |
@Nonnull @Override public StateSnapshotKeyGroupReader keyGroupReader(int readVersionHint) { final TypeSerializer<T> elementSerializer = metaInfo.getElementSerializer(); return KeyGroupPartitioner.createKeyGroupPartitionReader( elementSerializer::deserialize, //we know that this does not deliver nulls, because we never write nulls (element, keyGroupId) -> priorityQueue.add(element)); }
Example 6
Source File: StateTableByKeyGroupReaders.java From flink with Apache License 2.0 | 5 votes |
private static <K, N, S> StateSnapshotKeyGroupReader createV2PlusReader( StateTable<K, N, S> stateTable) { final TypeSerializer<N> namespaceSerializer = stateTable.getNamespaceSerializer(); final TypeSerializer<S> stateSerializer = stateTable.getStateSerializer(); final TypeSerializer<K> keySerializer = stateTable.keySerializer; final Tuple3<N, K, S> buffer = new Tuple3<>(); return KeyGroupPartitioner.createKeyGroupPartitionReader((in) -> { buffer.f0 = namespaceSerializer.deserialize(in); buffer.f1 = keySerializer.deserialize(in); buffer.f2 = stateSerializer.deserialize(in); return buffer; }, (element, keyGroupId1) -> stateTable.put(element.f1, keyGroupId1, element.f0, element.f2)); }