Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Simply having multiple patterns might not be able to deal with situations like above, and the concept Rule  can handle them properly.


We propose to add Rule interface PatternProcessor interface as below. The properties of the rule are required by CEP operator in order to function correctly.

Code Block
/**
 * Base class for a rulepattern processor definition.
 *
 * <p>A pattern ruleprocessor defines a {@link Pattern}, how to match the pattern, and how to process
 * the found
 * matches.
 *
 * @param <IN> Base type of the elements appearing in the pattern.
 * @param <OUT> Type of produced elements based on found matches.
 */
@PublicEvolving
public interface Rule<INPatternProcessor<IN, OUT> extends Serializable, Versioned {

    /**
     * Returns the ID of the rulepattern processor.
     *
     * @return The ID of the pattern ruleprocessor.
     */
    String getId();

    /**
     * Returns the scheduled time at which the pattern ruleprocessor should come into effective.
     *
     * <p>If the scheduled time is earlier than current event/processing time, the rulepattern willprocessor
     * will immediately become effective.
     *
     * <p>If the rulepattern processor should always become effective immediately, the scheduled time
 can be set to
 * can be set *to {@code Long.MIN_VALUE}: {@value Long#MIN_VALUE}.
     *
     * @return The scheduled time.
     */
    default Long getTimestamp() {
        return Long.MIN_VALUE;
    }

      /**
     * Returns the {@link Pattern} to be matched.
     *
     * @return The pattern of the rulepattern processor.
     */
    Pattern<IN, ?> getPattern();

    /**
     * Returns the {@link KeySelector} to extract the key of the elements appearing in the pattern.
     *
     * <p>Only data with the same key can be chained to match a pattern. If extracted key is null,
     * the behavior is to reuse current key if is {@link KeyedStream}, or allocate the same key for
     * all input data if is not {@link KeyedStream}.
     *
     * @return The key selector of the rulepattern processor.
     */
    @Nullable
    KeySelector<IN, ?> getKeySelector();

    /**
     * Get the {@link PatternProcessFunction} to process the found matches for the pattern.
     *
     * @return The pattern process function of the pattern ruleprocessor.
     */
    PatternProcessFunction<IN, OUT> getPatternProcessFunction();
}

...