Package io.github.flink.gcp.protobuf
Class ProtobufDynamicSerializerSnapshot
java.lang.Object
io.github.flink.gcp.protobuf.ProtobufDynamicSerializerSnapshot
- All Implemented Interfaces:
org.apache.flink.api.common.typeutils.TypeSerializerSnapshot<com.google.protobuf.DynamicMessage>
@Internal
public final class ProtobufDynamicSerializerSnapshot
extends Object
implements org.apache.flink.api.common.typeutils.TypeSerializerSnapshot<com.google.protobuf.DynamicMessage>
Version-1 metadata for restoring DynamicMessage value serializers from their saved descriptors.
The payload is the generated snapshot's version-1 layout without the class name: framing and normalization versions, the root's full name, the four settings, and the normalized descriptor closure with its SHA-256 fingerprint. Restoration rebuilds the saved descriptors without loading application classes or consulting the application's descriptor. Compatibility resolution delegates 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. A generated-message snapshot is never compatible.
-
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 and normalizes the saved descriptors against their root, without loading any application class.org.apache.flink.api.common.typeutils.TypeSerializerSchemaCompatibility<com.google.protobuf.DynamicMessage>resolveSchemaCompatibility(org.apache.flink.api.common.typeutils.TypeSerializerSnapshot<com.google.protobuf.DynamicMessage> oldSerializerSnapshot) Checks whether this new configuration can read values permitted by an old configuration.org.apache.flink.api.common.typeutils.TypeSerializer<com.google.protobuf.DynamicMessage>Rebuilds the saved descriptors and returns a reader with the saved settings.voidwriteSnapshot(org.apache.flink.core.memory.DataOutputView out) Writes the fixed version-1 payload with deterministic descriptor bytes and their SHA-256.
-
Constructor Details
-
ProtobufDynamicSerializerSnapshot
public ProtobufDynamicSerializerSnapshot()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<com.google.protobuf.DynamicMessage>- 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<com.google.protobuf.DynamicMessage>- 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 and normalizes the saved descriptors against their root, without loading any application class.- Specified by:
readSnapshotin interfaceorg.apache.flink.api.common.typeutils.TypeSerializerSnapshot<com.google.protobuf.DynamicMessage>- Parameters:
readVersion- version read from Flink's envelopein- source positioned at the snapshot payloaduserCodeClassLoader- unused; restoration needs no application class- Throws:
IOException- for unsupported versions, malformed metadata, corruption, or truncation
-
restoreSerializer
public org.apache.flink.api.common.typeutils.TypeSerializer<com.google.protobuf.DynamicMessage> restoreSerializer()Rebuilds the saved descriptors and returns a reader with the saved settings.- Specified by:
restoreSerializerin interfaceorg.apache.flink.api.common.typeutils.TypeSerializerSnapshot<com.google.protobuf.DynamicMessage>- Returns:
- a DynamicMessage serializer bound to the saved root descriptor
- Throws:
IllegalStateException- if metadata is uninitialized or the saved descriptors fail the construction rules; the message names the full name and the failed rule
-
resolveSchemaCompatibility
public org.apache.flink.api.common.typeutils.TypeSerializerSchemaCompatibility<com.google.protobuf.DynamicMessage> resolveSchemaCompatibility(org.apache.flink.api.common.typeutils.TypeSerializerSnapshot<com.google.protobuf.DynamicMessage> oldSerializerSnapshot) Checks whether this new configuration can read values permitted by an old configuration.- Specified by:
resolveSchemaCompatibilityin interfaceorg.apache.flink.api.common.typeutils.TypeSerializerSnapshot<com.google.protobuf.DynamicMessage>- Parameters:
oldSerializerSnapshot- saved metadata- Returns:
- compatible as is when the old snapshot is a DynamicMessage snapshot whose schema and settings the evaluator accepts, otherwise incompatible
- Throws:
IllegalStateException- if either Protobuf snapshot is uninitialized
-