Skip to content

Commit

Permalink
feat: Add "auto-split" arg to auto-gen UID prefixes (#1035)
Browse files Browse the repository at this point in the history
Closes: #1034
  • Loading branch information
jrconlin committed Apr 2, 2021
1 parent 354cf79 commit 487ac11
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tools/spanner/purge_ttl.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ def spanner_purge(args):
instance = client.instance(args.instance_id)
database = instance.database(args.database_id)
expiry_condition = get_expiry_condition(args)
if args.auto_split:
args.uid_prefixes = [
hex(i).lstrip("0x").zfill(args.auto_split) for i in range(
0, 16 ** args.auto_split)]
prefixes = args.uid_prefixes if args.uid_prefixes else [None]

for prefix in prefixes:
Expand Down Expand Up @@ -190,6 +194,14 @@ def get_args():
help="Array of strings used to limit purges based on UID. "
"Each entry is a separate purge run."
)
parser.add_argument(
"--auto_split",
type=int,
default=os.environ.get("PURGE_AUTO_SPLIT"),
help="""Automatically generate `uid_prefixes` for this many digits, """
"""(e.g. `3` would produce """
"""`uid_prefixes=["000","001","002",...,"fff"])"""
)
parser.add_argument(
"--mode",
type=str,
Expand Down

0 comments on commit 487ac11

Please sign in to comment.