Package io.github.flink.gcp.protobuf
Class ProtobufGeneratedSerializerSnapshot<T extends com.google.protobuf.Message>
java.lang.Object
io.github.flink.gcp.protobuf.ProtobufGeneratedSerializerSnapshot<T>
- Type Parameters:
T- concrete generated message type
- All Implemented Interfaces:
org.apache.flink.api.common.typeutils.TypeSerializerSnapshot<T>
@Internal
public final class ProtobufGeneratedSerializerSnapshot<T extends com.google.protobuf.Message>
extends Object
implements org.apache.flink.api.common.typeutils.TypeSerializerSnapshot<T>
Version-1 metadata for restoring generated Protobuf value serializers.
The persisted class name and payload layout are state-format identities. Reading metadata does not load a generated class. Restoration uses Flink's supplied user-code classloader. Both compatibility resolution and restoration delegate to the directional schema evaluator, which accepts unchanged descriptors and the supported schema changes and permits only nondecreasing reader limits; deterministic writing and large-payload aliasing may change in either direction.
-
Constructor Summary
ConstructorsConstructorDescriptionCreates an empty snapshot for Flink's versioned metadata reader. -
Method Summary
Modifier and TypeMethodDescriptionintvoidreadSnapshot(int readVersion, org.apache.flink.core.memory.DataInputView in, ClassLoader userCodeClassLoader) Validates metadata without loading the saved generated class.org.apache.flink.api.common.typeutils.TypeSerializerSchemaCompatibility<T>resolveSchemaCompatibility(org.apache.flink.api.common.typeutils.TypeSerializerSnapshot<T> oldSerializerSnapshot) Checks whether this new configuration can read values permitted by an old configuration.org.apache.flink.api.common.typeutils.TypeSerializer<T>Resolves the generated class using the loader retained by this snapshot and checks that it can read the saved schema.voidwriteSnapshot(org.apache.flink.core.memory.DataOutputView out) Writes the fixed version-1 payload with deterministic descriptor bytes and their SHA-256.
-
Constructor Details
-
ProtobufGeneratedSerializerSnapshot
public ProtobufGeneratedSerializerSnapshot()Creates an empty snapshot for Flink's versioned metadata reader.
-
-
Method Details
-
getCurrentVersion
public int getCurrentVersion()- Specified by:
getCurrentVersionin interfaceorg.apache.flink.api.common.typeutils.TypeSerializerSnapshot<T extends com.google.protobuf.Message>- Returns:
- the version of the payload following Flink's class/version envelope
-
writeSnapshot
Writes the fixed version-1 payload with deterministic descriptor bytes and their SHA-256.- Specified by:
writeSnapshotin interfaceorg.apache.flink.api.common.typeutils.TypeSerializerSnapshot<T extends com.google.protobuf.Message>- Parameters:
out- destination immediately after Flink's snapshot version- Throws:
IOException- if metadata is uninitialized, exceeds format limits, or cannot be written
-
readSnapshot
public void readSnapshot(int readVersion, org.apache.flink.core.memory.DataInputView in, ClassLoader userCodeClassLoader) throws IOException Validates metadata without loading the saved generated class.- Specified by:
readSnapshotin interfaceorg.apache.flink.api.common.typeutils.TypeSerializerSnapshot<T extends com.google.protobuf.Message>- Parameters:
readVersion- version read from Flink's envelopein- source positioned at the snapshot payloaduserCodeClassLoader- loader to use later for serializer restoration- Throws:
IOException- for unsupported versions, malformed metadata, corruption, or truncation
-
restoreSerializer
Resolves the generated class using the loader retained by this snapshot and checks that it can read the saved schema.The class may declare a supported evolution of the saved schema; it need not be the class that wrote the state.
- Specified by:
restoreSerializerin interfaceorg.apache.flink.api.common.typeutils.TypeSerializerSnapshot<T extends com.google.protobuf.Message>- Returns:
- a reader of the resolved class with this snapshot's recorded settings
- Throws:
IllegalStateException- if metadata is uninitialized or the class is missing, unsupported, or cannot read the saved schema; the message names the first incompatibility
-
resolveSchemaCompatibility
public org.apache.flink.api.common.typeutils.TypeSerializerSchemaCompatibility<T> resolveSchemaCompatibility(org.apache.flink.api.common.typeutils.TypeSerializerSnapshot<T> oldSerializerSnapshot) Checks whether this new configuration can read values permitted by an old configuration.- Specified by:
resolveSchemaCompatibilityin interfaceorg.apache.flink.api.common.typeutils.TypeSerializerSnapshot<T extends com.google.protobuf.Message>- Parameters:
oldSerializerSnapshot- saved metadata, without requiring its generated class- Returns:
- compatible as is when the schema evaluator accepts the saved schema and settings, otherwise incompatible
- Throws:
IllegalStateException- if either Protobuf snapshot is uninitialized
-