Java Code Examples for org.apache.flink.runtime.state.StateSnapshotKeyGroupReader#readMappingsInKeyGroup()

The following examples show how to use org.apache.flink.runtime.state.StateSnapshotKeyGroupReader#readMappingsInKeyGroup() . 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: HeapRestoreOperation.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
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);
	}
}
 
Example 2
Source File: HeapRestoreOperation.java    From flink with Apache License 2.0 5 votes vote down vote up
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);
	}
}
 
Example 3
Source File: HeapRestoreOperation.java    From flink with Apache License 2.0 5 votes vote down vote up
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);
	}
}