new RegisteredPriorityQueueStateBackendMetaInfo<>(stateName, byteOrderedElementSerializer); (RegisteredPriorityQueueStateBackendMetaInfo<T>) metaInfoTuple.f1; TypeSerializer<T> previousElementSerializer = castedMetaInfo.getPreviousElementSerializer(); castedMetaInfo.updateElementSerializer(byteOrderedElementSerializer); new RegisteredPriorityQueueStateBackendMetaInfo<>(stateName, byteOrderedElementSerializer);
@SuppressWarnings("unchecked") @Nonnull @Override public <T extends HeapPriorityQueueElement & PriorityComparable & Keyed> KeyGroupedInternalPriorityQueue<T> create( @Nonnull String stateName, @Nonnull TypeSerializer<T> byteOrderedElementSerializer) { final HeapPriorityQueueSnapshotRestoreWrapper existingState = registeredPQStates.get(stateName); if (existingState != null) { // TODO we implement the simple way of supporting the current functionality, mimicking keyed state // because this should be reworked in FLINK-9376 and then we should have a common algorithm over // StateMetaInfoSnapshot that avoids this code duplication. TypeSerializerSchemaCompatibility<T> compatibilityResult = existingState.getMetaInfo().updateElementSerializer(byteOrderedElementSerializer); if (compatibilityResult.isIncompatible()) { throw new FlinkRuntimeException(new StateMigrationException("For heap backends, the new priority queue serializer must not be incompatible.")); } else { registeredPQStates.put( stateName, existingState.forUpdatedSerializer(byteOrderedElementSerializer)); } return existingState.getPriorityQueue(); } else { final RegisteredPriorityQueueStateBackendMetaInfo<T> metaInfo = new RegisteredPriorityQueueStateBackendMetaInfo<>(stateName, byteOrderedElementSerializer); return createInternal(metaInfo); } }
public RegisteredPriorityQueueStateBackendMetaInfo deepCopy() { return new RegisteredPriorityQueueStateBackendMetaInfo<>(name, getElementSerializer().duplicate()); } }
/** * Returns a deep copy of the snapshot, where the serializer is changed to the given serializer. */ public HeapPriorityQueueSnapshotRestoreWrapper<T> forUpdatedSerializer( @Nonnull TypeSerializer<T> updatedSerializer) { RegisteredPriorityQueueStateBackendMetaInfo<T> updatedMetaInfo = new RegisteredPriorityQueueStateBackendMetaInfo<>(metaInfo.getName(), updatedSerializer); return new HeapPriorityQueueSnapshotRestoreWrapper<>( priorityQueue, updatedMetaInfo, keyExtractorFunction, localKeyGroupRange, totalKeyGroups); } }
public static RegisteredStateMetaInfoBase fromMetaInfoSnapshot(@Nonnull StateMetaInfoSnapshot snapshot) { final StateMetaInfoSnapshot.BackendStateType backendStateType = snapshot.getBackendStateType(); switch (backendStateType) { case KEY_VALUE: return new RegisteredKeyValueStateBackendMetaInfo<>(snapshot); case OPERATOR: return new RegisteredOperatorStateBackendMetaInfo<>(snapshot); case BROADCAST: return new RegisteredBroadcastStateBackendMetaInfo<>(snapshot); case PRIORITY_QUEUE: return new RegisteredPriorityQueueStateBackendMetaInfo<>(snapshot); default: throw new IllegalArgumentException("Unknown backend state type: " + backendStateType); } } }
@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; }
@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)); }
@Nonnull @Override public StateMetaInfoSnapshot snapshot() { return computeSnapshot(); }
@Nonnull @Override public StateMetaInfoSnapshot getMetaInfoSnapshot() { return metaInfo.snapshot(); }
@SuppressWarnings("unchecked") @Nonnull @Override public StateSnapshot stateSnapshot() { final T[] queueDump = (T[]) priorityQueue.toArray(new HeapPriorityQueueElement[priorityQueue.size()]); return new HeapPriorityQueueStateSnapshot<>( queueDump, keyExtractorFunction, metaInfo.deepCopy(), localKeyGroupRange, totalKeyGroups); }
@SuppressWarnings("unchecked") @Nonnull @Override public <T extends HeapPriorityQueueElement & PriorityComparable & Keyed> KeyGroupedInternalPriorityQueue<T> create( @Nonnull String stateName, @Nonnull TypeSerializer<T> byteOrderedElementSerializer) { final HeapPriorityQueueSnapshotRestoreWrapper existingState = registeredPQStates.get(stateName); if (existingState != null) { // TODO we implement the simple way of supporting the current functionality, mimicking keyed state // because this should be reworked in FLINK-9376 and then we should have a common algorithm over // StateMetaInfoSnapshot that avoids this code duplication. TypeSerializerSchemaCompatibility<T> compatibilityResult = existingState.getMetaInfo().updateElementSerializer(byteOrderedElementSerializer); if (compatibilityResult.isIncompatible()) { throw new FlinkRuntimeException(new StateMigrationException("For heap backends, the new priority queue serializer must not be incompatible.")); } else { registeredPQStates.put( stateName, existingState.forUpdatedSerializer(byteOrderedElementSerializer)); } return existingState.getPriorityQueue(); } else { final RegisteredPriorityQueueStateBackendMetaInfo<T> metaInfo = new RegisteredPriorityQueueStateBackendMetaInfo<>(stateName, byteOrderedElementSerializer); return createInternal(metaInfo); } }
public RegisteredPriorityQueueStateBackendMetaInfo deepCopy() { return new RegisteredPriorityQueueStateBackendMetaInfo<>(name, getElementSerializer().duplicate()); } }
/** * Returns a deep copy of the snapshot, where the serializer is changed to the given serializer. */ public HeapPriorityQueueSnapshotRestoreWrapper<T> forUpdatedSerializer( @Nonnull TypeSerializer<T> updatedSerializer) { RegisteredPriorityQueueStateBackendMetaInfo<T> updatedMetaInfo = new RegisteredPriorityQueueStateBackendMetaInfo<>(metaInfo.getName(), updatedSerializer); return new HeapPriorityQueueSnapshotRestoreWrapper<>( priorityQueue, updatedMetaInfo, keyExtractorFunction, localKeyGroupRange, totalKeyGroups); } }
public static RegisteredStateMetaInfoBase fromMetaInfoSnapshot(@Nonnull StateMetaInfoSnapshot snapshot) { final StateMetaInfoSnapshot.BackendStateType backendStateType = snapshot.getBackendStateType(); switch (backendStateType) { case KEY_VALUE: return new RegisteredKeyValueStateBackendMetaInfo<>(snapshot); case OPERATOR: return new RegisteredOperatorStateBackendMetaInfo<>(snapshot); case BROADCAST: return new RegisteredBroadcastStateBackendMetaInfo<>(snapshot); case PRIORITY_QUEUE: return new RegisteredPriorityQueueStateBackendMetaInfo<>(snapshot); default: throw new IllegalArgumentException("Unknown backend state type: " + backendStateType); } } }
@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; }
@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)); }
@Nonnull @Override public StateMetaInfoSnapshot snapshot() { return computeSnapshot(); }
@Nonnull @Override public StateMetaInfoSnapshot getMetaInfoSnapshot() { return metaInfo.snapshot(); }
@SuppressWarnings("unchecked") @Nonnull @Override public StateSnapshot stateSnapshot() { final T[] queueDump = (T[]) priorityQueue.toArray(new HeapPriorityQueueElement[priorityQueue.size()]); return new HeapPriorityQueueStateSnapshot<>( queueDump, keyExtractorFunction, metaInfo.deepCopy(), localKeyGroupRange, totalKeyGroups); }
new RegisteredPriorityQueueStateBackendMetaInfo<>(stateName, byteOrderedElementSerializer); (RegisteredPriorityQueueStateBackendMetaInfo<T>) metaInfoTuple.f1; TypeSerializer<T> previousElementSerializer = castedMetaInfo.getPreviousElementSerializer(); castedMetaInfo.updateElementSerializer(byteOrderedElementSerializer); new RegisteredPriorityQueueStateBackendMetaInfo<>(stateName, byteOrderedElementSerializer);