Java Code Examples for org.apache.flink.runtime.state.KeyedStateHandle#getIntersection()

The following examples show how to use org.apache.flink.runtime.state.KeyedStateHandle#getIntersection() . 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: StateAssignmentOperation.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
/**
 * Extracts certain key group ranges from the given state handles and adds them to the collector.
 */
private static void extractIntersectingState(
	Collection<KeyedStateHandle> originalSubtaskStateHandles,
	KeyGroupRange rangeToExtract,
	List<KeyedStateHandle> extractedStateCollector) {

	for (KeyedStateHandle keyedStateHandle : originalSubtaskStateHandles) {

		if (keyedStateHandle != null) {

			KeyedStateHandle intersectedKeyedStateHandle = keyedStateHandle.getIntersection(rangeToExtract);

			if (intersectedKeyedStateHandle != null) {
				extractedStateCollector.add(intersectedKeyedStateHandle);
			}
		}
	}
}
 
Example 2
Source File: StateAssignmentOperation.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
/**
 * Determine the subset of {@link KeyGroupsStateHandle KeyGroupsStateHandles} with correct
 * key group index for the given subtask {@link KeyGroupRange}.
 *
 * <p>This is publicly visible to be used in tests.
 */
public static List<KeyedStateHandle> getKeyedStateHandles(
	Collection<? extends KeyedStateHandle> keyedStateHandles,
	KeyGroupRange subtaskKeyGroupRange) {

	List<KeyedStateHandle> subtaskKeyedStateHandles = new ArrayList<>(keyedStateHandles.size());

	for (KeyedStateHandle keyedStateHandle : keyedStateHandles) {
		KeyedStateHandle intersectedKeyedStateHandle = keyedStateHandle.getIntersection(subtaskKeyGroupRange);

		if (intersectedKeyedStateHandle != null) {
			subtaskKeyedStateHandles.add(intersectedKeyedStateHandle);
		}
	}

	return subtaskKeyedStateHandles;
}
 
Example 3
Source File: StateAssignmentOperation.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Extracts certain key group ranges from the given state handles and adds them to the collector.
 */
private static void extractIntersectingState(
	Collection<KeyedStateHandle> originalSubtaskStateHandles,
	KeyGroupRange rangeToExtract,
	List<KeyedStateHandle> extractedStateCollector) {

	for (KeyedStateHandle keyedStateHandle : originalSubtaskStateHandles) {

		if (keyedStateHandle != null) {

			KeyedStateHandle intersectedKeyedStateHandle = keyedStateHandle.getIntersection(rangeToExtract);

			if (intersectedKeyedStateHandle != null) {
				extractedStateCollector.add(intersectedKeyedStateHandle);
			}
		}
	}
}
 
Example 4
Source File: StateAssignmentOperation.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Determine the subset of {@link KeyGroupsStateHandle KeyGroupsStateHandles} with correct
 * key group index for the given subtask {@link KeyGroupRange}.
 *
 * <p>This is publicly visible to be used in tests.
 */
public static List<KeyedStateHandle> getKeyedStateHandles(
	Collection<? extends KeyedStateHandle> keyedStateHandles,
	KeyGroupRange subtaskKeyGroupRange) {

	List<KeyedStateHandle> subtaskKeyedStateHandles = new ArrayList<>(keyedStateHandles.size());

	for (KeyedStateHandle keyedStateHandle : keyedStateHandles) {
		KeyedStateHandle intersectedKeyedStateHandle = keyedStateHandle.getIntersection(subtaskKeyGroupRange);

		if (intersectedKeyedStateHandle != null) {
			subtaskKeyedStateHandles.add(intersectedKeyedStateHandle);
		}
	}

	return subtaskKeyedStateHandles;
}
 
Example 5
Source File: StateAssignmentOperation.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Extracts certain key group ranges from the given state handles and adds them to the collector.
 */
@VisibleForTesting
public static void extractIntersectingState(
		Collection<? extends KeyedStateHandle> originalSubtaskStateHandles,
		KeyGroupRange rangeToExtract,
		List<KeyedStateHandle> extractedStateCollector) {

	for (KeyedStateHandle keyedStateHandle : originalSubtaskStateHandles) {

		if (keyedStateHandle != null) {

			KeyedStateHandle intersectedKeyedStateHandle = keyedStateHandle.getIntersection(rangeToExtract);

			if (intersectedKeyedStateHandle != null) {
				extractedStateCollector.add(intersectedKeyedStateHandle);
			}
		}
	}
}