Package org.apache.cassandra.db.memtable
Class ShardBoundaries
- java.lang.Object
-
- org.apache.cassandra.db.memtable.ShardBoundaries
-
public class ShardBoundaries extends java.lang.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, seeKeyspace
.Technically, if we use
n
shards, this is a list ofn-1
tokens and each tokentk
gets assigned to the shard ID corresponding to the slot of the smallest token in the list that is greater totk
, orn
iftk
is bigger than any token in the list.
-
-
Field Summary
Fields Modifier and Type Field Description static ShardBoundaries
NONE
long
ringVersion
-
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 boolean
equals(java.lang.Object o)
int
getShardForKey(PartitionPosition key)
Computes the shard to use for the provided key.int
getShardForToken(Token tk)
Computes the shard to use for the provided token.int
hashCode()
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.java.lang.String
toString()
-
-
-
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:
toString
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
-