Class ShardBoundaries

java.lang.Object
org.apache.cassandra.db.memtable.ShardBoundaries

public class ShardBoundaries extends Object
Holds boundaries (tokens) used to map a particular token (so partition key) to a shard id. In practice, each keyspace has its associated boundaries, see Keyspace.

Technically, if we use n shards, this is a list of n-1 tokens and each token tk gets assigned to the shard ID corresponding to the slot of the smallest token in the list that is greater to tk, or n if tk is bigger than any token in the list.

  • Field Details

    • NONE

      public static final ShardBoundaries NONE
    • ringVersion

      public final long ringVersion
  • Constructor Details

    • ShardBoundaries

      public ShardBoundaries(Token[] boundaries, long ringVersion)
    • ShardBoundaries

      public ShardBoundaries(List<Token> boundaries, long ringVersion)
  • Method Details

    • getShardForToken

      public int getShardForToken(Token tk)
      Computes the shard to use for the provided token.
    • getShardForKey

      public int getShardForKey(PartitionPosition key)
      Computes the shard to use for the provided key.
    • shardCount

      public int shardCount()
      The number of shards that this boundaries support, that is how many different shard ids getShardForToken(org.apache.cassandra.dht.Token) might possibly return.
      Returns:
      the number of shards supported by theses boundaries.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object