Package org.apache.cassandra.db.memtable
Class ShardBoundaries
- java.lang.Object
-
- org.apache.cassandra.db.memtable.ShardBoundaries
-
public class ShardBoundaries extends java.lang.ObjectHolds boundaries (tokens) used to map a particular token (so partition key) to a shard id. In practice, each keyspace has its associated boundaries, seeKeyspace.Technically, if we use
nshards, this is a list ofn-1tokens and each tokentkgets assigned to the shard ID corresponding to the slot of the smallest token in the list that is greater totk, orniftkis bigger than any token in the list.
-
-
Field Summary
Fields Modifier and Type Field Description static ShardBoundariesNONElongringVersion
-
Constructor Summary
Constructors Constructor Description ShardBoundaries(java.util.List<Token> boundaries, long ringVersion)ShardBoundaries(Token[] boundaries, long ringVersion)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object o)intgetShardForKey(PartitionPosition key)Computes the shard to use for the provided key.intgetShardForToken(Token tk)Computes the shard to use for the provided token.inthashCode()intshardCount()The number of shards that this boundaries support, that is how many different shard idsgetShardForToken(org.apache.cassandra.dht.Token)might possibly return.java.lang.StringtoString()
-
-
-
Field Detail
-
NONE
public static final ShardBoundaries NONE
-
ringVersion
public final long ringVersion
-
-
Method Detail
-
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 idsgetShardForToken(org.apache.cassandra.dht.Token)might possibly return.- Returns:
- the number of shards supported by theses boundaries.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
-