func newReplicaDataIterator( d *roachpb.RangeDescriptor, e engine.Reader, replicatedOnly bool, ) *replicaDataIterator { rangeFunc := makeAllKeyRanges if replicatedOnly { rangeFunc = makeReplicatedKeyRanges } ri := &replicaDataIterator{ ranges: rangeFunc(d), Iterator: e.NewIterator(false), } ri.Seek(ri.ranges[ri.curIndex].start) return ri }
// ComputeStatsForRange computes the stats for a given range by // iterating over all key ranges for the given range that should // be accounted for in its stats. func ComputeStatsForRange( d *roachpb.RangeDescriptor, e engine.Reader, nowNanos int64, ) (engine.MVCCStats, error) { iter := e.NewIterator(false) defer iter.Close() ms := engine.MVCCStats{} for _, r := range makeReplicatedKeyRanges(d) { msDelta, err := iter.ComputeStats(r.start, r.end, nowNanos) if err != nil { return engine.MVCCStats{}, err } ms.Add(msDelta) } return ms, nil }