lukecwik commented on a change in pull request #11199: [BEAM-9562] Update Timer 
encoding with respect of dynamic timers
URL: https://github.com/apache/beam/pull/11199#discussion_r402505215
 
 

 ##########
 File path: 
runners/core-construction-java/src/main/java/org/apache/beam/runners/core/construction/Timer.java
 ##########
 @@ -40,92 +50,197 @@
 @AutoValue
 public abstract class Timer<T> {
 
-  /** Returns a timer for the given timestamp with a {@code null} payload. */
-  public static Timer<Void> of(Instant time) {
-    return of(time, (Void) null);
+  /**
+   * Returns a non-cleared timer for the given userKey, dynamicTimerTag, 
fireTimestamp,
+   * holdTimestamp, windows and pane.
+   */
+  public static <T> Timer<T> of(
+      T userKey,
+      String dynamicTimerTag,
+      Instant fireTimestamp,
+      Instant holdTimestamp,
+      Collection<? extends BoundedWindow> windows,
+      PaneInfo pane) {
+    return new AutoValue_Timer(
+        userKey, dynamicTimerTag, false, fireTimestamp, holdTimestamp, 
windows, pane);
   }
 
-  /** Returns a timer for the given timestamp with a user specified payload. */
-  public static <T> Timer<T> of(Instant timestamp, @Nullable T payload) {
-    return new AutoValue_Timer(timestamp, payload);
+  /** Returns a cleared timer for the given userKey, dynamicTimerTag. */
+  public static <T> Timer<T> cleared(T userKey, String dynamicTimerTag) {
+    return new AutoValue_Timer(userKey, dynamicTimerTag, true, null, null, 
null, null);
   }
 
+  /** Returns the key that the timer is set on. */
+  public abstract T getUserKey();
+
+  /**
+   * Returns the tag that the timer is set on. This tag is empty string only 
when the timer is set
+   * from TimerSpec.
+   */
+  public abstract String getDynamicTimerTag();
+
+  /** Returns a boolean which indicate whether the timer is going to be 
cleared. */
+  public abstract boolean getClearBit();
+
   /**
-   * Returns the timestamp of when the timer is scheduled to fire.
+   * Returns the timestamp of when the timer is scheduled to fire. This field 
is nullable only when
+   * the clearBit is true.
    *
    * <p>The time is relative to the time domain defined in the {@link
    * org.apache.beam.model.pipeline.v1.RunnerApi.TimerFamilySpec} that is 
associated with this
    * timer.
 
 Review comment:
   The default should be the input timestamp but we should allow people to set 
it to any value greater then that. For example, consider a person writing a 
simple polling function where they check the status of something using a timer 
and they would like to be able to advance the hold based upon what the current 
system time is. The input to this transform is the output of impulse (+ a dummy 
key) so the input timestamp would be MIN_TIMESTAMP initially.
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to