Java Code Examples for org.apache.flink.cep.pattern.Pattern#getCondition()

The following examples show how to use org.apache.flink.cep.pattern.Pattern#getCondition() . 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: NFACompiler.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
/**
 * @return The {@link IterativeCondition condition} for the {@code IGNORE} edge
 * that corresponds to the specified {@link Pattern} and extended with stop(until) condition
 * if necessary. It is applicable only for inner states of a complex state like looping or times.
 */
@SuppressWarnings("unchecked")
private IterativeCondition<T> getInnerIgnoreCondition(Pattern<T, ?> pattern) {
	Quantifier.ConsumingStrategy consumingStrategy = pattern.getQuantifier().getInnerConsumingStrategy();
	if (headOfGroup(pattern)) {
		// for the head pattern of a group pattern, we should consider the
		// inner consume strategy of the group pattern
		consumingStrategy = currentGroupPattern.getQuantifier().getInnerConsumingStrategy();
	}

	IterativeCondition<T> innerIgnoreCondition = null;
	switch (consumingStrategy) {
		case STRICT:
			innerIgnoreCondition = null;
			break;
		case SKIP_TILL_NEXT:
			innerIgnoreCondition = new RichNotCondition<>((IterativeCondition<T>) pattern.getCondition());
			break;
		case SKIP_TILL_ANY:
			innerIgnoreCondition = BooleanConditions.trueFunction();
			break;
	}

	if (currentGroupPattern != null && currentGroupPattern.getUntilCondition() != null) {
		innerIgnoreCondition = extendWithUntilCondition(
			innerIgnoreCondition,
			(IterativeCondition<T>) currentGroupPattern.getUntilCondition(),
			false);
	}
	return innerIgnoreCondition;
}
 
Example 2
Source File: NFACompiler.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
/**
 * @return The {@link IterativeCondition condition} for the {@code IGNORE} edge
 * that corresponds to the specified {@link Pattern} and extended with
 * stop(until) condition if necessary. For more on strategy see {@link Quantifier}
 */
@SuppressWarnings("unchecked")
private IterativeCondition<T> getIgnoreCondition(Pattern<T, ?> pattern) {
	Quantifier.ConsumingStrategy consumingStrategy = pattern.getQuantifier().getConsumingStrategy();
	if (headOfGroup(pattern)) {
		// for the head pattern of a group pattern, we should consider the inner consume strategy
		// of the group pattern if the group pattern is not the head of the TIMES/LOOPING quantifier;
		// otherwise, we should consider the consume strategy of the group pattern
		if (isCurrentGroupPatternFirstOfLoop()) {
			consumingStrategy = currentGroupPattern.getQuantifier().getConsumingStrategy();
		} else {
			consumingStrategy = currentGroupPattern.getQuantifier().getInnerConsumingStrategy();
		}
	}

	IterativeCondition<T> ignoreCondition = null;
	switch (consumingStrategy) {
		case STRICT:
			ignoreCondition = null;
			break;
		case SKIP_TILL_NEXT:
			ignoreCondition = new RichNotCondition<>((IterativeCondition<T>) pattern.getCondition());
			break;
		case SKIP_TILL_ANY:
			ignoreCondition = BooleanConditions.trueFunction();
			break;
	}

	if (currentGroupPattern != null && currentGroupPattern.getUntilCondition() != null) {
		ignoreCondition = extendWithUntilCondition(
			ignoreCondition,
			(IterativeCondition<T>) currentGroupPattern.getUntilCondition(),
			false);
	}
	return ignoreCondition;
}
 
Example 3
Source File: NFACompiler.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
/**
 * @return the {@link IterativeCondition condition} for the {@code TAKE} edge
 * that corresponds to the specified {@link Pattern} and extended with
 * stop(until) condition if necessary.
 */
@SuppressWarnings("unchecked")
private IterativeCondition<T> getTakeCondition(Pattern<T, ?> pattern) {
	IterativeCondition<T> takeCondition = (IterativeCondition<T>) pattern.getCondition();
	if (currentGroupPattern != null && currentGroupPattern.getUntilCondition() != null) {
		takeCondition = extendWithUntilCondition(
			takeCondition,
			(IterativeCondition<T>) currentGroupPattern.getUntilCondition(),
			true);
	}
	return takeCondition;
}
 
Example 4
Source File: NFACompiler.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * @return The {@link IterativeCondition condition} for the {@code IGNORE} edge
 * that corresponds to the specified {@link Pattern} and extended with stop(until) condition
 * if necessary. It is applicable only for inner states of a complex state like looping or times.
 */
@SuppressWarnings("unchecked")
private IterativeCondition<T> getInnerIgnoreCondition(Pattern<T, ?> pattern) {
	Quantifier.ConsumingStrategy consumingStrategy = pattern.getQuantifier().getInnerConsumingStrategy();
	if (headOfGroup(pattern)) {
		// for the head pattern of a group pattern, we should consider the
		// inner consume strategy of the group pattern
		consumingStrategy = currentGroupPattern.getQuantifier().getInnerConsumingStrategy();
	}

	IterativeCondition<T> innerIgnoreCondition = null;
	switch (consumingStrategy) {
		case STRICT:
			innerIgnoreCondition = null;
			break;
		case SKIP_TILL_NEXT:
			innerIgnoreCondition = new RichNotCondition<>((IterativeCondition<T>) pattern.getCondition());
			break;
		case SKIP_TILL_ANY:
			innerIgnoreCondition = BooleanConditions.trueFunction();
			break;
	}

	if (currentGroupPattern != null && currentGroupPattern.getUntilCondition() != null) {
		innerIgnoreCondition = extendWithUntilCondition(
			innerIgnoreCondition,
			(IterativeCondition<T>) currentGroupPattern.getUntilCondition(),
			false);
	}
	return innerIgnoreCondition;
}
 
Example 5
Source File: NFACompiler.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * @return The {@link IterativeCondition condition} for the {@code IGNORE} edge
 * that corresponds to the specified {@link Pattern} and extended with
 * stop(until) condition if necessary. For more on strategy see {@link Quantifier}
 */
@SuppressWarnings("unchecked")
private IterativeCondition<T> getIgnoreCondition(Pattern<T, ?> pattern) {
	Quantifier.ConsumingStrategy consumingStrategy = pattern.getQuantifier().getConsumingStrategy();
	if (headOfGroup(pattern)) {
		// for the head pattern of a group pattern, we should consider the inner consume strategy
		// of the group pattern if the group pattern is not the head of the TIMES/LOOPING quantifier;
		// otherwise, we should consider the consume strategy of the group pattern
		if (isCurrentGroupPatternFirstOfLoop()) {
			consumingStrategy = currentGroupPattern.getQuantifier().getConsumingStrategy();
		} else {
			consumingStrategy = currentGroupPattern.getQuantifier().getInnerConsumingStrategy();
		}
	}

	IterativeCondition<T> ignoreCondition = null;
	switch (consumingStrategy) {
		case STRICT:
			ignoreCondition = null;
			break;
		case SKIP_TILL_NEXT:
			ignoreCondition = new RichNotCondition<>((IterativeCondition<T>) pattern.getCondition());
			break;
		case SKIP_TILL_ANY:
			ignoreCondition = BooleanConditions.trueFunction();
			break;
	}

	if (currentGroupPattern != null && currentGroupPattern.getUntilCondition() != null) {
		ignoreCondition = extendWithUntilCondition(
			ignoreCondition,
			(IterativeCondition<T>) currentGroupPattern.getUntilCondition(),
			false);
	}
	return ignoreCondition;
}
 
Example 6
Source File: NFACompiler.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * @return the {@link IterativeCondition condition} for the {@code TAKE} edge
 * that corresponds to the specified {@link Pattern} and extended with
 * stop(until) condition if necessary.
 */
@SuppressWarnings("unchecked")
private IterativeCondition<T> getTakeCondition(Pattern<T, ?> pattern) {
	IterativeCondition<T> takeCondition = (IterativeCondition<T>) pattern.getCondition();
	if (currentGroupPattern != null && currentGroupPattern.getUntilCondition() != null) {
		takeCondition = extendWithUntilCondition(
			takeCondition,
			(IterativeCondition<T>) currentGroupPattern.getUntilCondition(),
			true);
	}
	return takeCondition;
}
 
Example 7
Source File: NFACompiler.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * @return The {@link IterativeCondition condition} for the {@code IGNORE} edge
 * that corresponds to the specified {@link Pattern} and extended with stop(until) condition
 * if necessary. It is applicable only for inner states of a complex state like looping or times.
 */
@SuppressWarnings("unchecked")
private IterativeCondition<T> getInnerIgnoreCondition(Pattern<T, ?> pattern) {
	Quantifier.ConsumingStrategy consumingStrategy = pattern.getQuantifier().getInnerConsumingStrategy();
	if (headOfGroup(pattern)) {
		// for the head pattern of a group pattern, we should consider the
		// inner consume strategy of the group pattern
		consumingStrategy = currentGroupPattern.getQuantifier().getInnerConsumingStrategy();
	}

	IterativeCondition<T> innerIgnoreCondition = null;
	switch (consumingStrategy) {
		case STRICT:
			innerIgnoreCondition = null;
			break;
		case SKIP_TILL_NEXT:
			innerIgnoreCondition = new RichNotCondition<>((IterativeCondition<T>) pattern.getCondition());
			break;
		case SKIP_TILL_ANY:
			innerIgnoreCondition = BooleanConditions.trueFunction();
			break;
	}

	if (currentGroupPattern != null && currentGroupPattern.getUntilCondition() != null) {
		innerIgnoreCondition = extendWithUntilCondition(
			innerIgnoreCondition,
			(IterativeCondition<T>) currentGroupPattern.getUntilCondition(),
			false);
	}
	return innerIgnoreCondition;
}
 
Example 8
Source File: NFACompiler.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * @return The {@link IterativeCondition condition} for the {@code IGNORE} edge
 * that corresponds to the specified {@link Pattern} and extended with
 * stop(until) condition if necessary. For more on strategy see {@link Quantifier}
 */
@SuppressWarnings("unchecked")
private IterativeCondition<T> getIgnoreCondition(Pattern<T, ?> pattern) {
	Quantifier.ConsumingStrategy consumingStrategy = pattern.getQuantifier().getConsumingStrategy();
	if (headOfGroup(pattern)) {
		// for the head pattern of a group pattern, we should consider the inner consume strategy
		// of the group pattern if the group pattern is not the head of the TIMES/LOOPING quantifier;
		// otherwise, we should consider the consume strategy of the group pattern
		if (isCurrentGroupPatternFirstOfLoop()) {
			consumingStrategy = currentGroupPattern.getQuantifier().getConsumingStrategy();
		} else {
			consumingStrategy = currentGroupPattern.getQuantifier().getInnerConsumingStrategy();
		}
	}

	IterativeCondition<T> ignoreCondition = null;
	switch (consumingStrategy) {
		case STRICT:
			ignoreCondition = null;
			break;
		case SKIP_TILL_NEXT:
			ignoreCondition = new RichNotCondition<>((IterativeCondition<T>) pattern.getCondition());
			break;
		case SKIP_TILL_ANY:
			ignoreCondition = BooleanConditions.trueFunction();
			break;
	}

	if (currentGroupPattern != null && currentGroupPattern.getUntilCondition() != null) {
		ignoreCondition = extendWithUntilCondition(
			ignoreCondition,
			(IterativeCondition<T>) currentGroupPattern.getUntilCondition(),
			false);
	}
	return ignoreCondition;
}
 
Example 9
Source File: NFACompiler.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * @return the {@link IterativeCondition condition} for the {@code TAKE} edge
 * that corresponds to the specified {@link Pattern} and extended with
 * stop(until) condition if necessary.
 */
@SuppressWarnings("unchecked")
private IterativeCondition<T> getTakeCondition(Pattern<T, ?> pattern) {
	IterativeCondition<T> takeCondition = (IterativeCondition<T>) pattern.getCondition();
	if (currentGroupPattern != null && currentGroupPattern.getUntilCondition() != null) {
		takeCondition = extendWithUntilCondition(
			takeCondition,
			(IterativeCondition<T>) currentGroupPattern.getUntilCondition(),
			true);
	}
	return takeCondition;
}