public Integer calculateNewEntry ( PartitionEntry newEntry , Map < Integer , Integer > buckets ) { if ( newEntry == null ) { throw new IllegalArgumentException ( "newEntry must be not null" ) ; } if ( isEmpty ( buckets ) ) { throw new IllegalArgumentException ( "buckets must be not null" ) ; } HashFunction md5 = Hashing . md5 ( ) ; int numBuckets = buckets . size ( ) ; return buckets . get ( Hashing . consistentHash ( md5 . hashInt ( newEntry . hashCode ( ) ) , numBuckets ) ) ; }
Distribute a new entry across buckets using a consistent hashing strategy .