/** * Constructor to create the snapshot for writing. */ public EitherSerializerSnapshot( TypeSerializer<L> leftSerializer, TypeSerializer<R> rightSerializer) { this.nestedSnapshot = new NestedSerializersSnapshotDelegate(leftSerializer, rightSerializer); }
/** * Reads the composite snapshot of all the contained serializers in a way that is compatible * with Version 1 of the deprecated {@link CompositeTypeSerializerConfigSnapshot}. */ public static NestedSerializersSnapshotDelegate legacyReadNestedSerializerSnapshots(DataInputView in, ClassLoader cl) throws IOException { @SuppressWarnings("deprecation") final List<Tuple2<TypeSerializer<?>, TypeSerializerSnapshot<?>>> serializersAndSnapshots = TypeSerializerSerializationUtil.readSerializersAndConfigsWithResilience(in, cl); final TypeSerializerSnapshot<?>[] nestedSnapshots = serializersAndSnapshots.stream() .map(t -> t.f1) .toArray(TypeSerializerSnapshot<?>[]::new); return new NestedSerializersSnapshotDelegate(nestedSnapshots); }
/** * Constructor to be used for writing the snapshot. * * @param serializerInstance an instance of the originating serializer of this snapshot. */ @SuppressWarnings("unchecked") public CompositeTypeSerializerSnapshot(S serializerInstance) { Preconditions.checkNotNull(serializerInstance); this.nestedSerializersSnapshotDelegate = new NestedSerializersSnapshotDelegate(getNestedSerializers(serializerInstance)); this.correspondingSerializerClass = (Class<S>) serializerInstance.getClass(); }
/** * Constructor to create the snapshot for writing. */ public GenericArraySerializerConfigSnapshot(GenericArraySerializer<C> serializer) { this.componentClass = serializer.getComponentClass(); this.nestedSnapshot = new NestedSerializersSnapshotDelegate(serializer.getComponentSerializer()); }
/** * Reads the composite snapshot of all the contained serializers. */ public static NestedSerializersSnapshotDelegate readNestedSerializerSnapshots(DataInputView in, ClassLoader cl) throws IOException { final int magicNumber = in.readInt(); if (magicNumber != MAGIC_NUMBER) { throw new IOException(String.format("Corrupt data, magic number mismatch. Expected %8x, found %8x", MAGIC_NUMBER, magicNumber)); } final int version = in.readInt(); if (version != VERSION) { throw new IOException("Unrecognized version: " + version); } final int numSnapshots = in.readInt(); final TypeSerializerSnapshot<?>[] nestedSnapshots = new TypeSerializerSnapshot<?>[numSnapshots]; for (int i = 0; i < numSnapshots; i++) { nestedSnapshots[i] = TypeSerializerSnapshot.readVersionedSnapshot(in, cl); } return new NestedSerializersSnapshotDelegate(nestedSnapshots); }