Ejemplo n.º 1
0
  /**
   * Triggers the window computation if the provided {@link TriggerResult} requires so. The caller
   * must ensure that the correct key is set in the state backend and the context object.
   */
  @SuppressWarnings("unchecked")
  private void fireOrContinue(
      TriggerResult triggerResult, W window, AppendingState<IN, ACC> windowState) throws Exception {
    if (!triggerResult.isFire()) {
      return;
    }

    timestampedCollector.setAbsoluteTimestamp(window.maxTimestamp());
    ACC contents = windowState.get();
    userFunction.apply(context.key, context.window, contents, timestampedCollector);
  }
Ejemplo n.º 2
0
  protected void emitWindow(Context context) throws Exception {
    timestampedCollector.setTimestamp(context.window.maxTimestamp());

    if (context.windowBuffer.size() > 0) {
      setKeyContextElement(context.windowBuffer.getElements().iterator().next());

      userFunction.apply(
          context.key,
          context.window,
          context.windowBuffer.getUnpackedElements(),
          timestampedCollector);
    }
  }