Content Based Slicing Using Rabin-Karp Hash
One of the interesting use cases of the rolling hash function is that it can create dynamic, content-based chunks of a stream or file. This is especially useful when it is required to send only the changed chunks of a large file over a network and a simple byte addition at the front of the file would cause all the fixed size windows to become updated, while in reality, only the first ‘chunk’ has been modified.
The simplest approach to calculate the dynamic chunks is to calculate the rolling hash and if it matches a pattern (like the lower N bits are all zeroes) then it’s a chunk boundary. This approach will ensure that any change in the file will only affect it’s current and possibly the next chunk, but nothing else.
When the boundaries are known, the chunks need to be compared by their hash values to detect which one was modified and needs transfer across the network.
Read more about this topic: Rolling Hash
Famous quotes containing the words content and/or based:
“For believe me!the secret to harvesting the greatest abundance and the greatest enjoyment from existence is thisliving dangerously! Build your cities on the slopes of Vesuvius! Send your ships into uncharted seas! Live at war with your peers and yourselves! Be robbers and conquerors, so long as you cannot be rulers and possessors, you knowing ones! The time will soon be past when you could be content to live hidden in the forests like timid deer.”
—Friedrich Nietzsche (18441900)
“Your honesty is not to be based either on religion or policy. Both your religion and policy must be based on it. Your honesty must be based, as the sun is, in vacant heaven; poised, as the lights in the firmament, which have rule over the day and over the night.”
—John Ruskin (18191900)