by flipperhero · 3y ago · 0 comments
Use case: I already have a list of equally spaced snapshots that I'd like to logarithmically space.
Also, it occurs to me that this (and other grandfather snapshot schemes) ultimately derive from the generational hypothesis: users want files for either a short time (transient files, tarballs, PDFs, checkouts) or a long time (photos).
- Start with the most recent snapshot; keep it
- Go on to the next snapshot; keep it, and then drop the next 2^1 - 1 = 1 snapshot
- Go on to the next snapshot; keep it, and then drop the next 2^2 - 1 = 3 snapshots
- Go on to the next snapshot; keep it, and then drop the next 2^3 - 1 = 7 snapshots
Etc.
Alternately (if it's easier to model or implement it thus), the snapshots that you keep are the ones at power-of-two indices, plus 0 (starting again from the most recent snapshot): snapshot 0, snapshot 1, snapshot 2, snapshot 4...