All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.flink.cep.functions.TimedOutPartialMatchHandler Maven / Gradle / Ivy

There is a newer version: 2.0-preview1
Show newest version
/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.apache.flink.cep.functions;

import org.apache.flink.annotation.PublicEvolving;

import java.time.Duration;
import java.util.List;
import java.util.Map;

/**
 * Enables handling timed out partial matches. It shall be used in a mixin style. If you need your
 * {@link PatternProcessFunction} to be able to handle timed out partial matches implement this
 * interface as well. Example:
 *
 * 
{@code
 * private class MyFunction extends PatternProcessFunction implements TimedOutPartialMatchHandler {
 *
 * }
 * }
* * @param type of input elements */ @PublicEvolving public interface TimedOutPartialMatchHandler { /** * Called for every timed out partial match (due to {@link * org.apache.flink.cep.pattern.Pattern#within(Duration)}). It enables custom handling, e.g. one * can emit the timed out results through a side output: * *
{@code
     * private final OutputTag timedOutPartialMatchesTag = ...
     *
     * private class MyFunction extends PatternProcessFunction implements TimedOutPartialMatchHandler {
     *
     *     @Override
     *     public void processMatch(Map> match, Context ctx, Collector out) throws Exception {
     *          ...
     *     }
     *
     *     @Override
     *     void processTimedOutMatch(Map> match, PatternProcessFunction.Context ctx) throws Exception {
     *          ctx.output(timedOutPartialMatchesTag, match);
     *     }
     * }
     * }
* *

{@link PatternProcessFunction.Context#timestamp()} in this case returns the minimal time * in which we can say that the partial match will not become a match, which is effectively the * timestamp of the first element assigned to the partial match plus the value of within. * * @param match map containing the timed out partial match. Events are identified by their * names. * @param ctx enables access to time features and emitting results through side outputs * @throws Exception This method may throw exceptions. Throwing an exception will cause the * operation to fail and may trigger recovery. */ void processTimedOutMatch( final Map> match, final PatternProcessFunction.Context ctx) throws Exception; }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy