Skip to content

Instantly share code, notes, and snippets.

@VibhuJawa
Last active May 11, 2021 20:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save VibhuJawa/a7797908f53a0ee2d49790b6bd0e0c96 to your computer and use it in GitHub Desktop.
Save VibhuJawa/a7797908f53a0ee2d49790b6bd0e0c96 to your computer and use it in GitHub Desktop.
# UDF-1
# make a array for session change flag
# for all rows x
# set the flag if user_sk[x]!=user_sk[x-1] or tstamp_inSec[x] - tstamp_inSec[x-1] > 60 minutes
@cuda.jit
def make_session_change_flag_kernel(
user_sk, tstamp_inSec, session_change_flag, time_out
):
gid = cuda.grid(1)
if 0 < gid < len(wcs_user_sk):
if (
user_sk[gid] != user_sk[gid - 1]
or tstamp_inSec[gid] - tstamp_inSec[gid - 1] > time_out
):
session_change_flag[gid] = np.int32(1)
else:
session_change_flag[gid] = np.int32(0)
else:
session_change_flag[gid] = np.int32(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment