@@ -174,3 +174,28 @@ func DestroyReplica(
174174 NextReplicaID : next , // NB: NextReplicaID > 0
175175 })
176176}
177+
178+ // SubsumeReplica is like DestroyReplica, but it does not delete the user keys
179+ // (and the corresponding system and lock table keys). The latter are inherited
180+ // by the subsuming range.
181+ //
182+ // Returns SelectOpts which can be used to reflect on the key spans that this
183+ // function clears.
184+ // TODO(pav-kv): get rid of SelectOpts.
185+ func SubsumeReplica (
186+ ctx context.Context , reader storage.Reader , writer storage.Writer , info DestroyReplicaInfo ,
187+ ) (rditer.SelectOpts , error ) {
188+ // NB: set MustUseClearRange to true because this call is used for generating
189+ // SSTables when ingesting a snapshot, which requires Clears and Puts to be
190+ // written in key order. DestroyReplica sets RangeTombstoneKey after clearing
191+ // the unreplicated span which may contain higher keys.
192+ opts := ClearRangeDataOptions {
193+ ClearReplicatedByRangeID : true ,
194+ ClearUnreplicatedByRangeID : true ,
195+ MustUseClearRange : true ,
196+ }
197+ return rditer.SelectOpts {
198+ ReplicatedByRangeID : opts .ClearReplicatedByRangeID ,
199+ UnreplicatedByRangeID : opts .ClearUnreplicatedByRangeID ,
200+ }, DestroyReplica (ctx , reader , writer , info , MergedTombstoneReplicaID , opts )
201+ }
0 commit comments