Search in sources :

Example 1 with StateSnapshotKeyGroupReader

use of org.apache.flink.runtime.state.StateSnapshotKeyGroupReader in project flink by apache.

the class HeapRestoreOperation method readKeyGroupStateData.

private void readKeyGroupStateData(InputStream inputStream, Map<Integer, StateMetaInfoSnapshot> kvStatesById, int keyGroupIndex, int numStates, int readVersion) throws IOException {
    DataInputViewStreamWrapper inView = new DataInputViewStreamWrapper(inputStream);
    for (int i = 0; i < numStates; i++) {
        final int kvStateId = inView.readShort();
        final StateMetaInfoSnapshot stateMetaInfoSnapshot = kvStatesById.get(kvStateId);
        final StateSnapshotRestore registeredState;
        switch(stateMetaInfoSnapshot.getBackendStateType()) {
            case KEY_VALUE:
                registeredState = registeredKVStates.get(stateMetaInfoSnapshot.getName());
                break;
            case PRIORITY_QUEUE:
                registeredState = registeredPQStates.get(stateMetaInfoSnapshot.getName());
                break;
            default:
                throw new IllegalStateException("Unexpected state type: " + stateMetaInfoSnapshot.getBackendStateType() + ".");
        }
        StateSnapshotKeyGroupReader keyGroupReader = registeredState.keyGroupReader(readVersion);
        keyGroupReader.readMappingsInKeyGroup(inView, keyGroupIndex);
    }
}
Also used : StateSnapshotKeyGroupReader(org.apache.flink.runtime.state.StateSnapshotKeyGroupReader) StateMetaInfoSnapshot(org.apache.flink.runtime.state.metainfo.StateMetaInfoSnapshot) StateSnapshotRestore(org.apache.flink.runtime.state.StateSnapshotRestore) DataInputViewStreamWrapper(org.apache.flink.core.memory.DataInputViewStreamWrapper)

Aggregations

DataInputViewStreamWrapper (org.apache.flink.core.memory.DataInputViewStreamWrapper)1 StateSnapshotKeyGroupReader (org.apache.flink.runtime.state.StateSnapshotKeyGroupReader)1 StateSnapshotRestore (org.apache.flink.runtime.state.StateSnapshotRestore)1 StateMetaInfoSnapshot (org.apache.flink.runtime.state.metainfo.StateMetaInfoSnapshot)1