Java Code Examples for org.apache.flink.api.common.typeutils.TypeSerializerSnapshot#readVersionedSnapshot()
The following examples show how to use
org.apache.flink.api.common.typeutils.TypeSerializerSnapshot#readVersionedSnapshot() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LogicalTypeParser.java From flink with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") private LogicalType parseAnyType() { nextToken(TokenType.BEGIN_PARAMETER); nextToken(TokenType.LITERAL_STRING); final String className = tokenAsString(); nextToken(TokenType.LIST_SEPARATOR); nextToken(TokenType.LITERAL_STRING); final String serializer = tokenAsString(); nextToken(TokenType.END_PARAMETER); try { final Class<?> clazz = Class.forName(className, true, classLoader); final byte[] bytes = EncodingUtils.decodeBase64ToBytes(serializer); final DataInputDeserializer inputDeserializer = new DataInputDeserializer(bytes); final TypeSerializerSnapshot<?> snapshot = TypeSerializerSnapshot.readVersionedSnapshot( inputDeserializer, classLoader); return new AnyType(clazz, snapshot.restoreSerializer()); } catch (Throwable t) { throw parsingError( "Unable to restore the ANY type of class '" + className + "' with " + "serializer snapshot '" + serializer + "'.", t); } }
Example 2
Source File: RawType.java From flink with Apache License 2.0 | 6 votes |
/** * Restores a raw type from the components of a serialized string representation. */ @SuppressWarnings({"unchecked", "rawtypes"}) public static RawType<?> restore( ClassLoader classLoader, String className, String serializerString) { try { final Class<?> clazz = Class.forName(className, true, classLoader); final byte[] bytes = EncodingUtils.decodeBase64ToBytes(serializerString); final DataInputDeserializer inputDeserializer = new DataInputDeserializer(bytes); final TypeSerializerSnapshot<?> snapshot = TypeSerializerSnapshot.readVersionedSnapshot( inputDeserializer, classLoader); return (RawType<?>) new RawType(clazz, snapshot.restoreSerializer()); } catch (Throwable t) { throw new ValidationException( String.format( "Unable to restore the RAW type of class '%s' with serializer snapshot '%s'.", className, serializerString), t); } }
Example 3
Source File: PojoSerializerSnapshotData.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
private static BiFunctionWithException<DataInputView, String, TypeSerializerSnapshot<?>, IOException> snapshotReader(ClassLoader cl) { return (input, unused) -> { try { return TypeSerializerSnapshot.readVersionedSnapshot(input, cl); } catch (Throwable t) { LOG.warn("Exception while reading serializer snapshot.", t); return null; } }; }
Example 4
Source File: KryoSerializerSnapshotTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
private static TypeSerializerSnapshot<Animal> kryoSnapshotWithMissingClass() throws IOException { DataInputView in = new DataInputDeserializer(unLoadableSnapshotBytes()); return TypeSerializerSnapshot.readVersionedSnapshot( in, KryoSerializerSnapshotTest.class.getClassLoader()); }
Example 5
Source File: PojoSerializerSnapshotData.java From flink with Apache License 2.0 | 5 votes |
private static BiFunctionWithException<DataInputView, String, TypeSerializerSnapshot<?>, IOException> snapshotReader(ClassLoader cl) { return (input, unused) -> { try { return TypeSerializerSnapshot.readVersionedSnapshot(input, cl); } catch (Throwable t) { LOG.warn("Exception while reading serializer snapshot.", t); return null; } }; }
Example 6
Source File: KryoSerializerSnapshotTest.java From flink with Apache License 2.0 | 5 votes |
private static TypeSerializerSnapshot<Animal> kryoSnapshotWithMissingClass() throws IOException { DataInputView in = new DataInputDeserializer(unLoadableSnapshotBytes()); return TypeSerializerSnapshot.readVersionedSnapshot( in, KryoSerializerSnapshotTest.class.getClassLoader()); }
Example 7
Source File: PojoSerializerSnapshotData.java From flink with Apache License 2.0 | 5 votes |
private static BiFunctionWithException<DataInputView, String, TypeSerializerSnapshot<?>, IOException> snapshotReader(ClassLoader cl) { return (input, unused) -> { try { return TypeSerializerSnapshot.readVersionedSnapshot(input, cl); } catch (Throwable t) { LOG.warn("Exception while reading serializer snapshot.", t); return null; } }; }
Example 8
Source File: KryoSerializerSnapshotTest.java From flink with Apache License 2.0 | 5 votes |
private static TypeSerializerSnapshot<Animal> kryoSnapshotWithMissingClass() throws IOException { DataInputView in = new DataInputDeserializer(unLoadableSnapshotBytes()); return TypeSerializerSnapshot.readVersionedSnapshot( in, KryoSerializerSnapshotTest.class.getClassLoader()); }