コード例 #1
0
 public void onFire(W window, Timers timers, StateAccessor<?> state) throws Exception {
   // shouldFire should be false.
   // However it is too expensive to assert.
   FinishedTriggersBitSet finishedSet = readFinishedBits(state.access(FINISHED_BITS_TAG)).copy();
   TriggerStateMachine.TriggerContext context =
       contextFactory.base(window, timers, rootTrigger, finishedSet);
   rootTrigger.invokeOnFire(context);
   persistFinishedSet(state, finishedSet);
 }
コード例 #2
0
 /** Run the trigger logic to deal with a new value. */
 public void processValue(W window, Instant timestamp, Timers timers, StateAccessor<?> state)
     throws Exception {
   // Clone so that we can detect changes and so that changes here don't pollute merging.
   FinishedTriggersBitSet finishedSet = readFinishedBits(state.access(FINISHED_BITS_TAG)).copy();
   TriggerStateMachine.OnElementContext triggerContext =
       contextFactory.createOnElementContext(window, timers, timestamp, rootTrigger, finishedSet);
   rootTrigger.invokeOnElement(triggerContext);
   persistFinishedSet(state, finishedSet);
 }
コード例 #3
0
  private void persistFinishedSet(
      StateAccessor<?> state, FinishedTriggersBitSet modifiedFinishedSet) {
    if (!isFinishedSetNeeded()) {
      return;
    }

    ValueState<BitSet> finishedSetState = state.access(FINISHED_BITS_TAG);
    if (!readFinishedBits(finishedSetState).equals(modifiedFinishedSet)) {
      if (modifiedFinishedSet.getBitSet().isEmpty()) {
        finishedSetState.clear();
      } else {
        finishedSetState.write(modifiedFinishedSet.getBitSet());
      }
    }
  }
コード例 #4
0
 /** Return true if the trigger is closed in the window corresponding to the specified state. */
 public boolean isClosed(StateAccessor<?> state) {
   return readFinishedBits(state.access(FINISHED_BITS_TAG)).isFinished(rootTrigger);
 }
コード例 #5
0
 /**
  * Clear the state used for executing triggers, but leave the finished set to indicate the window
  * is closed.
  */
 public void clearState(W window, Timers timers, StateAccessor<?> state) throws Exception {
   // Don't need to clone, because we'll be clearing the finished bits anyways.
   FinishedTriggers finishedSet = readFinishedBits(state.access(FINISHED_BITS_TAG));
   rootTrigger.invokeClear(contextFactory.base(window, timers, rootTrigger, finishedSet));
 }
コード例 #6
0
 /** Clear the finished bits. */
 public void clearFinished(StateAccessor<?> state) {
   clearFinishedBits(state.access(FINISHED_BITS_TAG));
 }
コード例 #7
0
 public boolean shouldFire(W window, Timers timers, StateAccessor<?> state) throws Exception {
   FinishedTriggers finishedSet = readFinishedBits(state.access(FINISHED_BITS_TAG)).copy();
   TriggerStateMachine.TriggerContext context =
       contextFactory.base(window, timers, rootTrigger, finishedSet);
   return rootTrigger.invokeShouldFire(context);
 }
コード例 #8
0
 public void prefetchIsClosed(StateAccessor<?> state) {
   if (isFinishedSetNeeded()) {
     state.access(FINISHED_BITS_TAG).readLater();
   }
 }