/** * Reads a snapshot from the stream, performing resolving * * <p>This method reads snapshots written by {@link #writeVersionedSnapshot(DataOutputView, TypeSerializerSnapshot)}. */ static <T> TypeSerializerSnapshot<T> readVersionedSnapshot(DataInputView in, ClassLoader cl) throws IOException { final TypeSerializerSnapshot<T> snapshot = TypeSerializerSnapshotSerializationUtil.readAndInstantiateSnapshotClass(in, cl); final int version = in.readInt(); snapshot.readSnapshot(version, in, cl); return snapshot; } }
/** * Deserialization path for Flink versions in [1.4, 1.6]. */ @VisibleForTesting @SuppressWarnings("deprecation") static <T> TypeSerializerSnapshot<T> deserializeV1( DataInputView in, ClassLoader cl, @Nullable TypeSerializer<T> serializer) throws IOException { TypeSerializerSnapshot<T> snapshot = readAndInstantiateSnapshotClass(in, cl); // if the snapshot was created before Flink 1.7, we need to distinguish the following cases: // - old snapshot type that needs serializer from the outside // - new snapshot type that understands the old format and can produce a restore serializer from it if (snapshot instanceof TypeSerializerConfigSnapshot) { TypeSerializerConfigSnapshot<T> oldTypeSnapshot = (TypeSerializerConfigSnapshot<T>) snapshot; oldTypeSnapshot.setPriorSerializer(serializer); oldTypeSnapshot.setUserCodeClassLoader(cl); oldTypeSnapshot.read(in); } else { // new type, simple case int readVersion = in.readInt(); snapshot.readSnapshot(readVersion, in, cl); } return snapshot; }
/** * Reads a snapshot from the stream, performing resolving * * <p>This method reads snapshots written by {@link #writeVersionedSnapshot(DataOutputView, TypeSerializerSnapshot)}. */ static <T> TypeSerializerSnapshot<T> readVersionedSnapshot(DataInputView in, ClassLoader cl) throws IOException { final TypeSerializerSnapshot<T> snapshot = TypeSerializerSnapshotSerializationUtil.readAndInstantiateSnapshotClass(in, cl); final int version = in.readInt(); snapshot.readSnapshot(version, in, cl); return snapshot; } }
/** * Deserialization path for Flink versions in [1.4, 1.6]. */ @VisibleForTesting @SuppressWarnings("deprecation") static <T> TypeSerializerSnapshot<T> deserializeV1( DataInputView in, ClassLoader cl, @Nullable TypeSerializer<T> serializer) throws IOException { TypeSerializerSnapshot<T> snapshot = readAndInstantiateSnapshotClass(in, cl); // if the snapshot was created before Flink 1.7, we need to distinguish the following cases: // - old snapshot type that needs serializer from the outside // - new snapshot type that understands the old format and can produce a restore serializer from it if (snapshot instanceof TypeSerializerConfigSnapshot) { TypeSerializerConfigSnapshot<T> oldTypeSnapshot = (TypeSerializerConfigSnapshot<T>) snapshot; oldTypeSnapshot.setPriorSerializer(serializer); oldTypeSnapshot.setUserCodeClassLoader(cl); oldTypeSnapshot.read(in); } else { // new type, simple case int readVersion = in.readInt(); snapshot.readSnapshot(readVersion, in, cl); } return snapshot; }