Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions src/java/org/apache/cassandra/db/memtable/ShardBoundaries.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,11 @@ public ShardBoundaries(List<Token> boundaries, long ringVersion)
*/
public int getShardForToken(Token tk)
{
for (int i = 0; i < boundaries.length; i++)
{
if (tk.compareTo(boundaries[i]) <= 0) // boundaries are end-inclusive
return i;
}
return boundaries.length;
int idx = Arrays.binarySearch(boundaries, tk);
// boundaries are end-inclusive, so an exact match is the correct shard
if (idx >= 0)
return idx;
return -idx - 1;
}

/**
Expand Down
Loading