Java Code Examples for org.apache.flink.cep.nfa.sharedbuffer.EventId#equals()

The following examples show how to use org.apache.flink.cep.nfa.sharedbuffer.EventId#equals() . 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: SkipToElementStrategy.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
protected EventId getPruningId(Collection<Map<String, List<EventId>>> match) {
	EventId pruningId = null;
	for (Map<String, List<EventId>> resultMap : match) {
		List<EventId> pruningPattern = resultMap.get(patternName);
		if (pruningPattern == null || pruningPattern.isEmpty()) {
			if (shouldThrowException) {
				throw new FlinkRuntimeException(String.format(
					"Could not skip to %s. No such element in the found match %s",
					patternName,
					resultMap));
			}
		} else {
			pruningId = max(pruningId, pruningPattern.get(getIndex(pruningPattern.size())));
		}

		if (shouldThrowException) {
			EventId startEvent = resultMap.values()
				.stream()
				.flatMap(Collection::stream)
				.min(EventId::compareTo)
				.orElseThrow(() -> new IllegalStateException("Cannot prune based on empty match"));

			if (pruningId != null && pruningId.equals(startEvent)) {
				throw new FlinkRuntimeException("Could not skip to first element of a match.");
			}
		}
	}

	return pruningId;
}
 
Example 2
Source File: SkipToElementStrategy.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
protected EventId getPruningId(Collection<Map<String, List<EventId>>> match) {
	EventId pruningId = null;
	for (Map<String, List<EventId>> resultMap : match) {
		List<EventId> pruningPattern = resultMap.get(patternName);
		if (pruningPattern == null || pruningPattern.isEmpty()) {
			if (shouldThrowException) {
				throw new FlinkRuntimeException(String.format(
					"Could not skip to %s. No such element in the found match %s",
					patternName,
					resultMap));
			}
		} else {
			pruningId = max(pruningId, pruningPattern.get(getIndex(pruningPattern.size())));
		}

		if (shouldThrowException) {
			EventId startEvent = resultMap.values()
				.stream()
				.flatMap(Collection::stream)
				.min(EventId::compareTo)
				.orElseThrow(() -> new IllegalStateException("Cannot prune based on empty match"));

			if (pruningId != null && pruningId.equals(startEvent)) {
				throw new FlinkRuntimeException("Could not skip to first element of a match.");
			}
		}
	}

	return pruningId;
}
 
Example 3
Source File: SkipToElementStrategy.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
protected EventId getPruningId(Collection<Map<String, List<EventId>>> match) {
	EventId pruningId = null;
	for (Map<String, List<EventId>> resultMap : match) {
		List<EventId> pruningPattern = resultMap.get(patternName);
		if (pruningPattern == null || pruningPattern.isEmpty()) {
			if (shouldThrowException) {
				throw new FlinkRuntimeException(String.format(
					"Could not skip to %s. No such element in the found match %s",
					patternName,
					resultMap));
			}
		} else {
			pruningId = max(pruningId, pruningPattern.get(getIndex(pruningPattern.size())));
		}

		if (shouldThrowException) {
			EventId startEvent = resultMap.values()
				.stream()
				.flatMap(Collection::stream)
				.min(EventId::compareTo)
				.orElseThrow(() -> new IllegalStateException("Cannot prune based on empty match"));

			if (pruningId != null && pruningId.equals(startEvent)) {
				throw new FlinkRuntimeException("Could not skip to first element of a match.");
			}
		}
	}

	return pruningId;
}