use of org.apache.flink.runtime.state.metainfo.StateMetaInfoSnapshot in project flink by apache.
the class KeyedBackendSerializationProxy method read.
@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);
}
}
use of org.apache.flink.runtime.state.metainfo.StateMetaInfoSnapshot in project flink by apache.
the class KeyedBackendSerializationProxy method write.
@Override
public void write(DataOutputView out) throws IOException {
super.write(out);
// write the compression format used to write each key-group
out.writeBoolean(usingKeyGroupCompression);
TypeSerializerSnapshotSerializationUtil.writeSerializerSnapshot(out, keySerializerSnapshot, keySerializer);
// write individual registered keyed state metainfos
out.writeShort(stateMetaInfoSnapshots.size());
for (StateMetaInfoSnapshot metaInfoSnapshot : stateMetaInfoSnapshots) {
StateMetaInfoSnapshotReadersWriters.getWriter().writeStateMetaInfoSnapshot(metaInfoSnapshot, out);
}
}
use of org.apache.flink.runtime.state.metainfo.StateMetaInfoSnapshot in project flink by apache.
the class ChangelogBackendLogApplier method applyMetaDataChange.
private static void applyMetaDataChange(DataInputView in, ChangelogKeyedStateBackend<?> backend, ClassLoader classLoader, Map<Short, StateID> stateIds) throws Exception {
StateMetaInfoSnapshot snapshot = readStateMetaInfoSnapshot(in, classLoader);
RegisteredStateMetaInfoBase meta;
switch(snapshot.getBackendStateType()) {
case KEY_VALUE:
meta = restoreKvMetaData(backend, snapshot, in);
break;
case PRIORITY_QUEUE:
meta = restorePqMetaData(backend, snapshot);
break;
default:
throw new RuntimeException("Unsupported state type: " + snapshot.getBackendStateType() + ", sate: " + snapshot.getName());
}
stateIds.put(in.readShort(), new StateID(meta.getName(), BackendStateType.byCode(in.readByte())));
}
Aggregations