Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: No need to compute point hash if there is only one shard #20118

Merged
merged 4 commits into from
Nov 30, 2020
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
v1.8.4 [unreleased]
-------------------

### Features

- [#20118](https://github.com/influxdata/influxdb/pull/20118): feat: Optimize shard lookups in groups containing only one shard. Thanks @StoneYunZhao!

### Bugfixes

- [#19696](https://github.com/influxdata/influxdb/pull/19697): fix(flux): add durations to Flux logging
Expand Down
2 changes: 1 addition & 1 deletion coordinator/points_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ func (w *PointsWriter) MapShards(wp *WritePointsRequest) (*ShardMapping, error)
continue
}

sh := sg.ShardFor(p.HashID())
sh := sg.ShardFor(p)
mapping.MapPoint(&sh, p)
}
return mapping, nil
Expand Down
10 changes: 7 additions & 3 deletions services/meta/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -1363,9 +1363,13 @@ func (sgi ShardGroupInfo) clone() ShardGroupInfo {
return other
}

// ShardFor returns the ShardInfo for a Point hash.
func (sgi *ShardGroupInfo) ShardFor(hash uint64) ShardInfo {
return sgi.Shards[hash%uint64(len(sgi.Shards))]
// ShardFor returns the ShardInfo for a Point.
func (sgi *ShardGroupInfo) ShardFor(p models.Point) ShardInfo {
if len(sgi.Shards) == 1 {
return sgi.Shards[0]
}

return sgi.Shards[p.HashID()%uint64(len(sgi.Shards))]
}

// marshal serializes to a protobuf representation.
Expand Down