You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to understand the design decision behind requiring hashing to be stateless.
Each call to hashByte/hashLong etc. starts with the state equal to the original seed and calls finalize at the end. As far as I can tell, this means that you can't chain these hash calls (like you can with Guava, for example) unless you keep passing finalized() hashes around.
Am I missing something? It seems like we should require the user to call finalize and to have a stateful long hash variable that can be reset() in each implementation. This allows the user to replicate the current behavior by calling reset()-hashByte()-finalize() but also to chain calls to each of the hash functions (reset()-hashByte()-hashLong()...finalize()).
The text was updated successfully, but these errors were encountered:
Removing the currently-present API (single method calls) and making users to emulate it would be a bad decision, because requiring people to call three methods when just one suffices 95% of the time doesn't make sense.
Augmenting the current API with support for chaining is possible.
Streaming version api (with state) can be use to wrap a hash function as a OutputStream. It will reduce the overall allocations when we hash an object, which is the real scene in many RPC servers.
With stateless api, hashing the object will perform many allocations on the serialization step:
Hello.
I'm trying to understand the design decision behind requiring hashing to be stateless.
Each call to hashByte/hashLong etc. starts with the state equal to the original seed and calls finalize at the end. As far as I can tell, this means that you can't chain these hash calls (like you can with Guava, for example) unless you keep passing
finalized()
hashes around.Am I missing something? It seems like we should require the user to call finalize and to have a stateful
long hash
variable that can bereset()
in each implementation. This allows the user to replicate the current behavior by callingreset()-hashByte()-finalize()
but also to chain calls to each of the hash functions (reset()-hashByte()-hashLong()...finalize()
).The text was updated successfully, but these errors were encountered: