rhavyn / norbert

Norbert is a cluster manager and networking layer built on top of Zookeeper.
Apache License 2.0
390 stars 125 forks source link

optimize HashFunctions.fnv() #8

Open brentdmiller opened 12 years ago

brentdmiller commented 12 years ago

yatmatsuda writes: We use HashFunctions.fnv(Array[Byte]) (norbert code) for hash partitioning the graph data. We serialize NodeId to a byte array, then this function scans the bytes and calculate the hash value. HashFunctions.fnv is recursively defined. It takes one byte (key.head) to compute a intermediate value and creates a new array (key.drop(1)) of rest of the data and call recursively until all data are processed. It means we create an array per byte. Too expensive. We can simply use a while-loop with the array index as the loop variable.

(private ref: CLD-384)