chore: fix clustering build

Clustering requires taking the hash of synthetic points, so
allow this function to work on anything with a HashID.
pull/20265/head
Sam Arnold 2020-12-07 11:24:45 -04:00
parent d1a1e4b667
commit d96c8fb125
1 changed files with 6 additions and 3 deletions

View File

@ -1363,12 +1363,15 @@ func (sgi ShardGroupInfo) clone() ShardGroupInfo {
return other
}
// ShardFor returns the ShardInfo for a Point.
func (sgi *ShardGroupInfo) ShardFor(p models.Point) ShardInfo {
type hashIDer interface {
HashID() uint64
}
// ShardFor returns the ShardInfo for a Point or other hashIDer.
func (sgi *ShardGroupInfo) ShardFor(p hashIDer) ShardInfo {
if len(sgi.Shards) == 1 {
return sgi.Shards[0]
}
return sgi.Shards[p.HashID()%uint64(len(sgi.Shards))]
}