Skip to content

Commit 3809627

Browse files
committed
kvstorage: update RangeID iterator comments
Epic: none Release note: none
1 parent 77b2d9a commit 3809627

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

pkg/kv/kvserver/kvstorage/init.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,14 +145,22 @@ func checkCanInitializeEngine(ctx context.Context, eng storage.Engine) error {
145145
return err
146146
}
147147

148+
// readKeyFn reads the given key, and unmarshals the value into the given proto.
149+
// Returns false if the key does not exist, or is requested out of order.
148150
type readKeyFn func(roachpb.Key, protoutil.Message) (bool, error)
151+
152+
// scanRangeIDFn reports the existence of a RangeID, and allows reading
153+
// RangeID-local keys via the readKeyFn callback.
149154
type scanRangeIDFn func(roachpb.RangeID, readKeyFn) error
150155

151-
// iterateRangeIDKeys helps visit system keys that use RangeID prefixing (such
156+
// iterateRangeIDKeys helps visit storage keys that use RangeID prefixing (such
152157
// as RaftHardStateKey, RangeTombstoneKey, and many others). Such keys could in
153-
// principle exist at any RangeID, and this helper efficiently discovers all the
154-
// keys of the desired type (as specified by the supplied `keyFn`) and, for each
155-
// key-value pair discovered, unmarshals it into `msg` and then invokes `f`.
158+
// principle exist for any RangeID.
159+
//
160+
// The helper visits all RangeIDs that have any keys, and for each range calls
161+
// the scanRangeID function. The implementation of this function can request any
162+
// subset of RangeID-local keys via the readKeyFn callback. All keys must be
163+
// requested in sorted order.
156164
//
157165
// Iteration stops on the first error (and will pass through that error).
158166
func iterateRangeIDKeys(

0 commit comments

Comments
 (0)