flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From EronWright <...@git.apache.org>
Subject [GitHub] flink pull request #4616: [FLINK-7552] [FLINK-7553] Enhance SinkInterface / ...
Date Fri, 01 Sep 2017 16:29:44 GMT
Github user EronWright commented on a diff in the pull request:

    https://github.com/apache/flink/pull/4616#discussion_r136615089
  
    --- Diff: flink-streaming-java/src/main/java/org/apache/flink/streaming/api/functions/sink/SinkFunction.java
---
    @@ -35,6 +35,39 @@
     	 *
     	 * @param value The input record.
     	 * @throws Exception
    +	 * @deprecated Use {@link #invoke(SinkContext, Object)}.
     	 */
    -	void invoke(IN value) throws Exception;
    +	@Deprecated
    +	default void invoke(IN value) throws Exception {
    +	}
    +
    +	/**
    +	 * Writes the given value to the sink. This function is called for every record.
    +	 *
    +	 * @param context Additional context about the input record.
    +	 * @param value The input record.
    +	 * @throws Exception
    +	 */
    +	default void invoke(SinkContext context, IN value) throws Exception {
    +		invoke(value);
    +	}
    +
    +	/**
    +	 * Context that {@link SinkFunction SinkFunctions } can use for getting additional data
about
    +	 * an input record.
    +	 *
    +	 * <p>The context is only valid for the duration of a
    +	 * {@link SinkFunction#invoke(SinkContext, Object)} call. Do not store the context and
use
    +	 * afterwards!
    +	 *
    +	 * @param <T> The type of elements accepted by the sink.
    +	 */
    +	@Public // Interface might be extended in the future with additional methods.
    +	interface SinkContext<T> {
    +
    +		/**
    +		 * Returns the timestamp of the current input record.
    +		 */
    +		long timestamp();
    --- End diff --
    
    Consider returning a `Long` to better match the `Context` interface in `ProcessFunction`,
and document the behavior when the time characteristic is `ProcessingTime`.
    ```
    		/**
    		 * Timestamp of the element currently being processed or timestamp of a firing timer.
    		 *
    		 * <p>This might be {@code null}, for example if the time characteristic of your
program
    		 * is set to {@link org.apache.flink.streaming.api.TimeCharacteristic#ProcessingTime}.
    		 */
    		public abstract Long timestamp();
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message