Java Code Examples for org.apache.flink.api.common.typeutils.TypeSerializerSerializationUtil#tryReadSerializer()
The following examples show how to use
org.apache.flink.api.common.typeutils.TypeSerializerSerializationUtil#tryReadSerializer() .
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: KryoSerializerCompatibilityTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testDeserializingKryoSerializerWithoutAvro() throws Exception { final String resource = "serialized-kryo-serializer-1.3"; TypeSerializer<?> serializer; try (InputStream in = getClass().getClassLoader().getResourceAsStream(resource)) { DataInputViewStreamWrapper inView = new DataInputViewStreamWrapper(in); serializer = TypeSerializerSerializationUtil.tryReadSerializer(inView, getClass().getClassLoader()); } assertNotNull(serializer); assertTrue(serializer instanceof KryoSerializer); }
Example 2
Source File: KryoSerializerCompatibilityTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testDeserializingKryoSerializerWithoutAvro() throws Exception { final String resource = "serialized-kryo-serializer-1.3"; TypeSerializer<?> serializer; try (InputStream in = getClass().getClassLoader().getResourceAsStream(resource)) { DataInputViewStreamWrapper inView = new DataInputViewStreamWrapper(in); serializer = TypeSerializerSerializationUtil.tryReadSerializer(inView, getClass().getClassLoader()); } assertNotNull(serializer); assertTrue(serializer instanceof KryoSerializer); }
Example 3
Source File: KryoSerializerCompatibilityTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testDeserializingKryoSerializerWithoutAvro() throws Exception { final String resource = "serialized-kryo-serializer-1.3"; TypeSerializer<?> serializer; try (InputStream in = getClass().getClassLoader().getResourceAsStream(resource)) { DataInputViewStreamWrapper inView = new DataInputViewStreamWrapper(in); serializer = TypeSerializerSerializationUtil.tryReadSerializer(inView, getClass().getClassLoader()); } assertNotNull(serializer); assertTrue(serializer instanceof KryoSerializer); }
Example 4
Source File: AvroSerializerMigrationTest.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
@SuppressWarnings("deprecation") private static TypeSerializer<?> javaDeserialize(String base64) throws IOException { byte[] bytes = Base64.getMimeDecoder().decode(base64); DataInputDeserializer in = new DataInputDeserializer(bytes); return TypeSerializerSerializationUtil.tryReadSerializer(in, Thread.currentThread().getContextClassLoader()); }
Example 5
Source File: KeyedBackendSerializationProxy.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") @Override public void read(DataInputView in) throws IOException { super.read(in); final int readVersion = getReadVersion(); if (readVersion >= 4) { usingKeyGroupCompression = in.readBoolean(); } else { usingKeyGroupCompression = false; } // only starting from version 3, we have the key serializer and its config snapshot written if (readVersion >= 6) { this.keySerializerSnapshot = TypeSerializerSnapshotSerializationUtil.readSerializerSnapshot( in, userCodeClassLoader, null); } else if (readVersion >= 3) { Tuple2<TypeSerializer<?>, TypeSerializerSnapshot<?>> keySerializerAndConfig = TypeSerializerSerializationUtil.readSerializersAndConfigsWithResilience(in, userCodeClassLoader).get(0); this.keySerializerSnapshot = (TypeSerializerSnapshot<K>) keySerializerAndConfig.f1; } else { this.keySerializerSnapshot = new BackwardsCompatibleSerializerSnapshot<>( TypeSerializerSerializationUtil.tryReadSerializer(in, userCodeClassLoader, true)); } this.keySerializer = null; Integer metaInfoSnapshotVersion = META_INFO_SNAPSHOT_FORMAT_VERSION_MAPPER.get(readVersion); if (metaInfoSnapshotVersion == null) { // this should not happen; guard for the future throw new IOException("Cannot determine corresponding meta info snapshot version for keyed backend serialization readVersion=" + readVersion); } final StateMetaInfoReader stateMetaInfoReader = StateMetaInfoSnapshotReadersWriters.getReader( metaInfoSnapshotVersion, StateMetaInfoSnapshotReadersWriters.StateTypeHint.KEYED_STATE); int numKvStates = in.readShort(); stateMetaInfoSnapshots = new ArrayList<>(numKvStates); for (int i = 0; i < numKvStates; i++) { StateMetaInfoSnapshot snapshot = stateMetaInfoReader.readStateMetaInfoSnapshot(in, userCodeClassLoader); stateMetaInfoSnapshots.add(snapshot); } }
Example 6
Source File: AvroSerializerMigrationTest.java From flink with Apache License 2.0 | 4 votes |
@SuppressWarnings("deprecation") private static TypeSerializer<?> javaDeserialize(String base64) throws IOException { byte[] bytes = Base64.getMimeDecoder().decode(base64); DataInputDeserializer in = new DataInputDeserializer(bytes); return TypeSerializerSerializationUtil.tryReadSerializer(in, Thread.currentThread().getContextClassLoader()); }
Example 7
Source File: KeyedBackendSerializationProxy.java From flink with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") @Override public void read(DataInputView in) throws IOException { super.read(in); final int readVersion = getReadVersion(); if (readVersion >= 4) { usingKeyGroupCompression = in.readBoolean(); } else { usingKeyGroupCompression = false; } // only starting from version 3, we have the key serializer and its config snapshot written if (readVersion >= 6) { this.keySerializerSnapshot = TypeSerializerSnapshotSerializationUtil.readSerializerSnapshot( in, userCodeClassLoader, null); } else if (readVersion >= 3) { Tuple2<TypeSerializer<?>, TypeSerializerSnapshot<?>> keySerializerAndConfig = TypeSerializerSerializationUtil.readSerializersAndConfigsWithResilience(in, userCodeClassLoader).get(0); this.keySerializerSnapshot = (TypeSerializerSnapshot<K>) keySerializerAndConfig.f1; } else { this.keySerializerSnapshot = new BackwardsCompatibleSerializerSnapshot<>( TypeSerializerSerializationUtil.tryReadSerializer(in, userCodeClassLoader, true)); } this.keySerializer = null; Integer metaInfoSnapshotVersion = META_INFO_SNAPSHOT_FORMAT_VERSION_MAPPER.get(readVersion); if (metaInfoSnapshotVersion == null) { // this should not happen; guard for the future throw new IOException("Cannot determine corresponding meta info snapshot version for keyed backend serialization readVersion=" + readVersion); } final StateMetaInfoReader stateMetaInfoReader = StateMetaInfoSnapshotReadersWriters.getReader( metaInfoSnapshotVersion, StateMetaInfoSnapshotReadersWriters.StateTypeHint.KEYED_STATE); int numKvStates = in.readShort(); stateMetaInfoSnapshots = new ArrayList<>(numKvStates); for (int i = 0; i < numKvStates; i++) { StateMetaInfoSnapshot snapshot = stateMetaInfoReader.readStateMetaInfoSnapshot(in, userCodeClassLoader); stateMetaInfoSnapshots.add(snapshot); } }
Example 8
Source File: KeyedBackendSerializationProxy.java From flink with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") @Override public void read(DataInputView in) throws IOException { super.read(in); final int readVersion = getReadVersion(); if (readVersion >= 4) { usingKeyGroupCompression = in.readBoolean(); } else { usingKeyGroupCompression = false; } // only starting from version 3, we have the key serializer and its config snapshot written if (readVersion >= 6) { this.keySerializerSnapshot = TypeSerializerSnapshotSerializationUtil.readSerializerSnapshot( in, userCodeClassLoader, null); } else if (readVersion >= 3) { Tuple2<TypeSerializer<?>, TypeSerializerSnapshot<?>> keySerializerAndConfig = TypeSerializerSerializationUtil.readSerializersAndConfigsWithResilience(in, userCodeClassLoader).get(0); this.keySerializerSnapshot = (TypeSerializerSnapshot<K>) keySerializerAndConfig.f1; } else { this.keySerializerSnapshot = new BackwardsCompatibleSerializerSnapshot<>( TypeSerializerSerializationUtil.tryReadSerializer(in, userCodeClassLoader, true)); } this.keySerializer = null; Integer metaInfoSnapshotVersion = META_INFO_SNAPSHOT_FORMAT_VERSION_MAPPER.get(readVersion); if (metaInfoSnapshotVersion == null) { // this should not happen; guard for the future throw new IOException("Cannot determine corresponding meta info snapshot version for keyed backend serialization readVersion=" + readVersion); } final StateMetaInfoReader stateMetaInfoReader = StateMetaInfoSnapshotReadersWriters.getReader( metaInfoSnapshotVersion, StateMetaInfoSnapshotReadersWriters.StateTypeHint.KEYED_STATE); int numKvStates = in.readShort(); stateMetaInfoSnapshots = new ArrayList<>(numKvStates); for (int i = 0; i < numKvStates; i++) { StateMetaInfoSnapshot snapshot = stateMetaInfoReader.readStateMetaInfoSnapshot(in, userCodeClassLoader); stateMetaInfoSnapshots.add(snapshot); } }