You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by al...@apache.org on 2015/10/21 11:39:04 UTC

flink git commit: [hotfix] Add shortcuts for creating Time objects

Repository: flink
Updated Branches:
  refs/heads/master 06f6ac5d3 -> 22510f0e2


[hotfix] Add shortcuts for creating Time objects

This adds Time.milliseconds(), Time.seconds(), and so on.


Project: http://git-wip-us.apache.org/repos/asf/flink/repo
Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/22510f0e
Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/22510f0e
Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/22510f0e

Branch: refs/heads/master
Commit: 22510f0e28af4f7910f5164e537bfb04378f79d5
Parents: 06f6ac5
Author: Aljoscha Krettek <al...@gmail.com>
Authored: Wed Oct 21 11:37:44 2015 +0200
Committer: Aljoscha Krettek <al...@gmail.com>
Committed: Wed Oct 21 11:37:44 2015 +0200

----------------------------------------------------------------------
 .../streaming/api/windowing/time/Time.java      | 44 ++++++++++++++++++--
 1 file changed, 40 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flink/blob/22510f0e/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/windowing/time/Time.java
----------------------------------------------------------------------
diff --git a/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/windowing/time/Time.java b/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/windowing/time/Time.java
index d1b3fe3..7f9356a 100644
--- a/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/windowing/time/Time.java
+++ b/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/windowing/time/Time.java
@@ -51,16 +51,52 @@ public final class Time extends AbstractTime {
 	// ------------------------------------------------------------------------
 
 	/**
-	 * Creates a time policy describing a processing time interval. The policy refers to the
-	 * time characteristic that is set on the dataflow via
+	 * Creates a new {@link Time} of the given duration and {@link TimeUnit}.
+	 *
+	 * <p>The {@code Time} refers to the time characteristic that is set on the dataflow via
 	 * {@link org.apache.flink.streaming.api.environment.StreamExecutionEnvironment#
 	 * setStreamTimeCharacteristic(org.apache.flink.streaming.api.TimeCharacteristic)}.
 	 *
-	 * @param size The size of the generated windows.
-	 * @param unit The init (seconds, milliseconds) of the time interval.
+	 * @param size The duration of time.
+	 * @param unit The unit of time of the duration, for example {@code TimeUnit.SECONDS}.
 	 * @return The time policy.
 	 */
 	public static Time of(long size, TimeUnit unit) {
 		return new Time(size, unit);
 	}
+
+	/**
+	 * Creates a new {@link Time} that represents the given number of milliseconds.
+	 */
+	public static Time milliseconds(long milliseconds) {
+		return of(milliseconds, TimeUnit.MILLISECONDS);
+	}
+
+	/**
+	 * Creates a new {@link Time} that represents the given number of seconds.
+	 */
+	public static Time seconds(long seconds) {
+		return of(seconds, TimeUnit.SECONDS);
+	}
+
+	/**
+	 * Creates a new {@link Time} that represents the given number of minutes.
+	 */
+	public static Time minutes(long minutes) {
+		return of(minutes, TimeUnit.MINUTES);
+	}
+
+	/**
+	 * Creates a new {@link Time} that represents the given number of hours.
+	 */
+	public static Time hours(long hours) {
+		return of(hours, TimeUnit.HOURS);
+	}
+
+	/**
+	 * Creates a new {@link Time} that represents the given number of days.
+	 */
+	public static Time days(long days) {
+		return of(days, TimeUnit.DAYS);
+	}
 }