org.apache.flink.cep.pattern.conditions.BooleanConditions Java Examples

The following examples show how to use org.apache.flink.cep.pattern.conditions.BooleanConditions. 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: Pattern.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
public IterativeCondition<F> getCondition() {
	if (condition != null) {
		return condition;
	} else {
		return BooleanConditions.trueFunction();
	}
}
 
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. 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 #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 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 #4
Source File: NFACompiler.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
/**
 * @return An true function extended with stop(until) condition if necessary.
 */
@SuppressWarnings("unchecked")
private IterativeCondition<T> getTrueFunction() {
	IterativeCondition<T> trueCondition = BooleanConditions.trueFunction();
	if (currentGroupPattern != null && currentGroupPattern.getUntilCondition() != null) {
		trueCondition = extendWithUntilCondition(
			trueCondition,
			(IterativeCondition<T>) currentGroupPattern.getUntilCondition(),
			true);
	}
	return trueCondition;
}
 
Example #5
Source File: Pattern.java    From flink with Apache License 2.0 5 votes vote down vote up
public IterativeCondition<F> getCondition() {
	if (condition != null) {
		return condition;
	} else {
		return BooleanConditions.trueFunction();
	}
}
 
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 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 #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. 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 #8
Source File: NFACompiler.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * @return An true function extended with stop(until) condition if necessary.
 */
@SuppressWarnings("unchecked")
private IterativeCondition<T> getTrueFunction() {
	IterativeCondition<T> trueCondition = BooleanConditions.trueFunction();
	if (currentGroupPattern != null && currentGroupPattern.getUntilCondition() != null) {
		trueCondition = extendWithUntilCondition(
			trueCondition,
			(IterativeCondition<T>) currentGroupPattern.getUntilCondition(),
			true);
	}
	return trueCondition;
}
 
Example #9
Source File: Pattern.java    From flink with Apache License 2.0 5 votes vote down vote up
public IterativeCondition<F> getCondition() {
	if (condition != null) {
		return condition;
	} else {
		return BooleanConditions.trueFunction();
	}
}
 
Example #10
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 #11
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 #12
Source File: NFACompiler.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * @return An true function extended with stop(until) condition if necessary.
 */
@SuppressWarnings("unchecked")
private IterativeCondition<T> getTrueFunction() {
	IterativeCondition<T> trueCondition = BooleanConditions.trueFunction();
	if (currentGroupPattern != null && currentGroupPattern.getUntilCondition() != null) {
		trueCondition = extendWithUntilCondition(
			trueCondition,
			(IterativeCondition<T>) currentGroupPattern.getUntilCondition(),
			true);
	}
	return trueCondition;
}