private long getIndexVersion ( List < ShardIndexVersion > shards ) { long version = 1 ; // order shards per their id before computing the hash Collections . sort ( shards , new Comparator < ShardIndexVersion > ( ) { @ Override public int compare ( ShardIndexVersion o1 , ShardIndexVersion o2 ) { return o1 . getShardRouting ( ) . id ( ) - o2 . getShardRouting ( ) . id ( ) ; } } ) ; // compute hash for ( ShardIndexVersion shard : shards ) { version = 31 * version + shard . getVersion ( ) ; } return version ; }
Computes a unique hash based on the version of the shards .