Skip to content

Commit

Permalink
Create dt_hll.py
Browse files Browse the repository at this point in the history
create the python code for the hyperloglog tabbed examples on the date types page
  • Loading branch information
sav-norem authored Sep 20, 2023
1 parent 4042bf8 commit 814e3bb
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions doctests/dt_hll.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import redis

# HIDE_START
r = redis.Redis(decode_responses=True)
# HIDE_END

# REMOVE_START
r.delete("bikes", "commuter_bikes", "all_bikes")
# REMOVE_END

# STEP_START pfadd
res1 = r.pfadd("bikes", "Hyperion", "Deimos", "Phoebe", "Quaoar")
print(res1) # >>> 1

res2 = r.pfcount("bikes")
print(res2) # >>> 4

res3 = r.pfadd("commuter_bikes", "Salacia", "Mimas", "Quaoar")
print(res3) # >>> 1

res4 = r.pfmerge("all_bikes", "bikes", "commuter_bikes")
print(res4) # >>> True

res5 = r.pfcount("all_bikes")
print(res5) # >>> 6
# STEP_END

# REMOVE_START
assert res4 == True
# REMOVE_END

0 comments on commit 814e3bb

Please sign in to comment.