TIL about Google Cloud Datastore scattered IDs.
def scatter_id(counter: int) -> int:
if not 0 <= counter < 1 << 51:
raise ValueError("counter must fit in 51 bits")
return (1 << 52) | int(f"{counter:051b}"[::-1], 2)
TIL about Google Cloud Datastore scattered IDs.
def scatter_id(counter: int) -> int:
if not 0 <= counter < 1 << 51:
raise ValueError("counter must fit in 51 bits")
return (1 << 52) | int(f"{counter:051b}"[::-1], 2)
No replies here yet.