@Override public TypeSerializerSchemaCompatibility<T> resolveSchemaCompatibility( TypeSerializer<T> newSerializer) { // in prior versions, the compatibility check was in the serializer itself, so we // delegate this call to the serializer. final CompatibilityResult<T> compatibility = newSerializer.ensureCompatibility(this); return compatibility.isRequiresMigration() ? TypeSerializerSchemaCompatibility.incompatible() : TypeSerializerSchemaCompatibility.compatibleAsIs(); } }
private CompatibilityResult<T> createMigrationCompatResult(TypeSerializer<Object>[] convertSerializers) { PrecomputedParameters precomputed = PrecomputedParameters.precompute(this.precomputed.immutableTargetType, convertSerializers); return CompatibilityResult.requiresMigration(createSerializerInstance(precomputed, convertSerializers)); }
@Override public void read(DataInputView in) throws IOException { super.read(in); this.nestedSerializersAndConfigs = TypeSerializerSerializationUtil.readSerializersAndConfigsWithResilience(in, getUserCodeClassLoader()); }
protected void writeSortedData(T value, TestOutputView out) throws IOException { TypeSerializer<T> serializer = getSerializer(); // Write data into a outputView serializer.serialize(value, out); // This are the same tests like in the serializer // Just look if the data is really there after serialization, before testing comparator on it TestInputView in = out.getInputView(); assertTrue("No data available during deserialization.", in.available() > 0); T deserialized = serializer.deserialize(serializer.createInstance(), in); deepEquals("Deserialized value is wrong.", value, deserialized); }
public static <T> CompatibilityResult<T> resolveCompatibilityResult( TypeSerializerSnapshot<T> precedingSerializerConfigSnapshot, TypeSerializer<T> newSerializer) { TypeSerializerSchemaCompatibility<T> compatibility = precedingSerializerConfigSnapshot.resolveSchemaCompatibility(newSerializer); // everything except "compatible" maps to "requires migration". // at the entry point of the new-to-old-bridge (in the TypeSerializerConfigSnapshot), we // interpret "requiresMigration" as 'incompatible'. That is a precaution because // serializers could previously not specify the 'incompatible' case. return compatibility.isCompatibleAsIs() ? CompatibilityResult.compatible() : CompatibilityResult.requiresMigration(); } }
@Override public T createInstance() { Object[] fields = new Object[fieldSerializers.length]; for (int index = 0; index < fieldSerializers.length; index++) { fields[index] = fieldSerializers[index].createInstance(); } return createInstance(fields); }
@Override public void write(DataOutputView out) throws IOException { super.write(out); TypeSerializerSerializationUtil.writeSerializersAndConfigsWithResilience(out, nestedSerializersAndConfigs); }
@Override public int compare(IN o1, IN o2) { return comparator.compare(o1, o2); } });
@Override public TypeSerializerSchemaCompatibility<T> resolveSchemaCompatibility(TypeSerializer<T> newSerializer) { // if there is no configuration snapshot to check against, // then we can only assume that the new serializer is compatible as is return TypeSerializerSchemaCompatibility.compatibleAsIs(); }
public TestSpecification<T> withNewSerializerProvider(Supplier<? extends TypeSerializer<T>> serializerProvider) { return withNewSerializerProvider(serializerProvider, TypeSerializerSchemaCompatibility.compatibleAsIs()); }
@Override public final void readSnapshot(int readVersion, DataInputView in, ClassLoader userCodeClassLoader) throws IOException { if (readVersion > HIGHEST_LEGACY_READ_VERSION) { internalReadOuterSnapshot(in, userCodeClassLoader); } else { legacyInternalReadOuterSnapshot(readVersion, in, userCodeClassLoader); } this.nestedSerializersSnapshotDelegate = NestedSerializersSnapshotDelegate.readNestedSerializerSnapshots(in, userCodeClassLoader); }
@Override public final void writeSnapshot(DataOutputView out) throws IOException { internalWriteOuterSnapshot(out); nestedSerializersSnapshotDelegate.writeNestedSerializerSnapshots(out); }
@Override public final TypeSerializer<T> restoreSerializer() { @SuppressWarnings("unchecked") TypeSerializer<T> serializer = (TypeSerializer<T>) createOuterSerializerWithNestedSerializers(nestedSerializersSnapshotDelegate.getRestoredNestedSerializers()); return serializer; }
@Override public final TypeSerializerSchemaCompatibility<T> resolveSchemaCompatibility(TypeSerializer<T> newSerializer) { return internalResolveSchemaCompatibility(newSerializer, nestedSerializersSnapshotDelegate.getNestedSerializerSnapshots()); }
/** * Returns a result that signals migration to be performed. The migration will fail if the preceding * serializer for the previous data cannot be found. * * <p>You can also provide a convert deserializer using {@link #requiresMigration(TypeDeserializer)} * or {@link #requiresMigration(TypeSerializer)}, which will be used as a fallback resort in such cases. * * @return a result that signals migration is necessary, without providing a convert deserializer. */ public static <T> CompatibilityResult<T> requiresMigration() { return new CompatibilityResult<>(true, null); }
@Override public int compare(IN2 o1, IN2 o2) { return rightComparator.compare(o1, o2); } });
@Override public int compare(IN o1, IN o2) { return sortComparator.compare(o1, o2); } });