sessionWindow#

swordfish.function.sessionWindow()#

The first session window starts at the first non-null value of X. Sequentially check whether the difference between each element in X and its previous adjacent element is less than sessionGap. If the difference is less than sessionGap, the session window remains open. Otherwise, the session window ends and a new session window is started from the current element. The value of the first element in each session window is used as its identifier. This function returns the identifier of the session window to which each element in X belongs.

Note

  • For null values in X: If the first element of X is null, a null value is returned; otherwise, it returns the identifier of the window to which the previous non-null element belongs.

  • For out-of-order data: It will not be involved in the comparison and the identifier of the current window is returned directly.

Parameters:
  • X (Constant) – A n integral or temporal vector.

  • sessionGap (Constant) – A positive integer indicating the gap between two sessions. Its unit is the same as the time precision of X.