public ElasticHashinator addTokens ( NavigableMap < Integer , Integer > tokensToAdd ) { // figure out the interval long interval = deriveTokenInterval ( m_tokensMap . get ( ) . keySet ( ) ) ; Map < Integer , Integer > tokens = Maps . newTreeMap ( ) ; for ( Map . Entry < Integer , Integer > e : m_tokensMap . get ( ) . entrySet ( ) ) { if ( tokensToAdd . containsKey ( e . getKey ( ) ) ) { continue ; } // see if we are moving an intermediate token forward if ( isIntermediateToken ( e . getKey ( ) , interval ) ) { Map . Entry < Integer , Integer > floorEntry = tokensToAdd . floorEntry ( e . getKey ( ) ) ; // If the two tokens belong to the same partition and bucket, we are moving the one on the ring // forward, so remove it from the ring if ( floorEntry != null && floorEntry . getValue ( ) . equals ( e . getValue ( ) ) && containingBucket ( floorEntry . getKey ( ) , interval ) == containingBucket ( e . getKey ( ) , interval ) ) { continue ; } } tokens . put ( e . getKey ( ) , e . getValue ( ) ) ; } tokens . putAll ( tokensToAdd ) ; return new ElasticHashinator ( ImmutableSortedMap . copyOf ( tokens ) ) ; }
Add the given tokens to the ring and generate the new hashinator . The current hashinator is not changed .