Skip to content

Commit

Permalink
db: remove unnecessary key clones during ingest load
Browse files Browse the repository at this point in the history
During ingest loads, the smallest and largest bounds for point and
ranges are calculated. The point and range key bounds are cloned from an
iterator. When setting the overall bounds for the table, the point and /
or range key bounds can be reused for `Smallest` and `Largest`, as the
former are stable.

Remove the unnecessary key clones.

Follow up from cockroachdb#1521.
  • Loading branch information
nicktrav committed Feb 22, 2022
1 parent 998400e commit bf754af
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions ingest.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,24 +202,24 @@ func ingestLoad1(
switch {
case !hasRanges:
// Table has only point keys. Use the point key bounds.
meta.Smallest = meta.SmallestPointKey.Clone()
meta.Largest = meta.LargestPointKey.Clone()
meta.Smallest = meta.SmallestPointKey
meta.Largest = meta.LargestPointKey
case !hasPoints:
// Table has only range key. Use the range key bounds.
meta.Smallest = meta.SmallestRangeKey.Clone()
meta.Largest = meta.LargestRangeKey.Clone()
meta.Smallest = meta.SmallestRangeKey
meta.Largest = meta.LargestRangeKey
default:
// Table has both points and ranges. Compute the bounds by considering both
// the point and range key bounds.
if base.InternalCompare(opts.Comparer.Compare, meta.SmallestPointKey, meta.SmallestRangeKey) < 0 {
meta.Smallest = meta.SmallestPointKey.Clone()
meta.Smallest = meta.SmallestPointKey
} else {
meta.Smallest = meta.SmallestRangeKey.Clone()
meta.Smallest = meta.SmallestRangeKey
}
if base.InternalCompare(opts.Comparer.Compare, meta.LargestPointKey, meta.LargestRangeKey) > 0 {
meta.Largest = meta.LargestPointKey.Clone()
meta.Largest = meta.LargestPointKey
} else {
meta.Largest = meta.LargestRangeKey.Clone()
meta.Largest = meta.LargestRangeKey
}
}

Expand Down

0 comments on commit bf754af

Please sign in to comment.