royaltm / node-murmurhash-native

MurmurHash native bindings for node
MIT License
48 stars 7 forks source link

Stream API for murmur 2 #22

Closed blarfoon closed 4 years ago

blarfoon commented 4 years ago

Would it be possible to have the stream APIs for murmur 2 as well as murmur 3?

royaltm commented 4 years ago

Possible? Yes. A streaming API requires an incremental (a progressive) implementation of the hashing algorithm. PMur 3 - the progressive version of murmurhash 3-32 bit was written by the murmurhash author, PMur 3-128 was written by me, because I really needed that at the time. What is great about those progressive versions is that their performance is on par with the non-incremental ones, so in this module, I'm only using the incremental implementations even for the "one shot" API (less code - less possible bugs). Murmurhash 2 is an older and a different algorithm. While I think it is possible to write an incremental version of it, I didn't find one available anywhere and I didn't need one. If, perhaps, you already have a progressive implementation ready, then there should be no problem. Otherwise it requires some extra work to implement it and to test the implementation on different machine types (endianness, etc.).