3 ms·
> I’ve been wondering how to do this for years, and suddenly it occurred to me how to do this. One way that doesn’t work is to view the sequence of values as so
by amelius 11y ago
> I’ve been wondering how to do this for years, and suddenly it occurred to me how to do this. One way that doesn’t work is to view the sequence of values as some kind of linked list, where each value has an invisible write-once-only pointer to the next value. The write-once-pointer gets updated when the value is updated, unfortunately this is difficult to implement and there are problems with consistency.
Why?
> The solution is blindingly simple (once you see it) - we represent the sequence as a set Key-Value pairs where the Keys are taken from an iterated sequence of SHA1 checksums. The first key is a random number, thereafter Key[i] = sha(Key[i-1]).
Why not simply use Key[0] = 0, and Key[i] = Key[i-1]+1, or, in other words Key[i] = i?
- vannevar 11y agoBecause, as I read the article, each key[i=0] represents a single value chain and you're going to have many chains in the store, presumably being written by multiple processes. So if you were inserting based on some global incrementing counter, you couldn't be sure that key[n+1] belonged to the same chain as key[n]. Using iterated SHA1 gives reasonable assurance that key[i+1] will be unique while at the same time making it a function of key[i] so that it can easily be found given that initial key.
- amelius 11y agoThen how about using a double key (i,j) where j is the global chain number?