Rolling Hash - Content Based Slicing Using Rabin-Karp Hash

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:

    Sir Charles: Aren’t you drinking?
    Princess Dala: I don’t drink.
    Sir Charles: Never?
    Princess Dala: I’m quite content with reality, I have no need for escape.
    Sir Charles: Well, I enjoy reality as much as the next man, it’s just in my case, fortunately, reality includes a good stiff belt every now and then.
    Blake Edwards (b. 1922)

    This is a war universe. War all the time. That is its nature. There may be other universes based on all sorts of other principles, but ours seems to be based on war and games.
    William Burroughs (b. 1914)