src/services/counters.py
BeforeProposed
+1−0
1010 wrapped = (F.col("_previous") * 4 >= modulus * 3) & (F.col("counter") * 4 <= modulus)
1111 delta = (F.when(F.col("_previous").isNull(), F.lit(0))
1212 .when(F.col("counter") >= F.col("_previous"), F.col("counter") - F.col("_previous"))
13 .when(wrapped, modulus - F.col("_previous") + F.col("counter"))
1314 .otherwise(F.col("counter")))
1415 return frame.withColumn("_delta", delta).withColumn("_gap", F.col("at") - F.col("_prior_time"))