@@ -130,6 +130,11 @@ func EvalAddSSTable(
130
130
) (result.Result , error ) {
131
131
args := cArgs .Args .(* kvpb.AddSSTableRequest )
132
132
h := cArgs .Header
133
+
134
+ if err := args .Validate (h ); err != nil {
135
+ return result.Result {}, err
136
+ }
137
+
133
138
ms := cArgs .Stats
134
139
start , end := storage.MVCCKey {Key : args .Key }, storage.MVCCKey {Key : args .EndKey }
135
140
sst := args .Data
@@ -290,34 +295,26 @@ func EvalAddSSTable(
290
295
if checkConflicts {
291
296
stats .Add (checkConflictsStatsDelta )
292
297
}
293
- if ! (checkConflicts || args .ComputeStatsDiff ) {
294
- // If CheckSSTConflicts or ComputeStatsDiff are not used to compute stats,
295
- // then the stats do not account for overlapping keys in the engine, so we
296
- // have to assume they are estimates.
297
- stats .ContainsEstimates ++
298
- }
299
298
if args .ComputeStatsDiff {
300
- if checkConflicts {
301
- return result.Result {}, errors .New (
302
- "AddSSTableRequest.ComputeStatsDiff cannot be used with DisallowConflicts or DisallowShadowingBelow" )
303
- }
304
- if args .MVCCStats != nil {
305
- return result.Result {}, errors .New (
306
- "AddSSTableRequest.ComputeStatsDiff cannot be used with precomputed MVCCStats" )
307
- }
308
- statsDiff , err := computeSSTStatsDiffWrapper (ctx , sst , readWriter , h .Timestamp .WallTime , start , end )
299
+ statsDiff , err := computeSSTStatsDiffWithFallback (ctx , sst , readWriter , h .Timestamp .WallTime , start , end )
309
300
if err != nil {
310
301
return result.Result {}, errors .Wrap (err , "computing SST stats diff" )
311
302
}
312
303
stats .Add (statsDiff )
313
304
} else if args .MVCCStats != nil {
314
305
stats .Add (* args .MVCCStats )
306
+ if ! checkConflicts {
307
+ stats .ContainsEstimates ++
308
+ }
315
309
} else {
316
310
sstStats , err := computeSSTStats (ctx , sst , h .Timestamp .WallTime )
317
311
if err != nil {
318
312
return result.Result {}, errors .Wrap (err , "computing SST stats" )
319
313
}
320
314
stats .Add (sstStats )
315
+ if ! checkConflicts {
316
+ stats .ContainsEstimates ++
317
+ }
321
318
}
322
319
ms .Add (stats )
323
320
@@ -468,7 +465,7 @@ func EvalAddSSTable(
468
465
}, nil
469
466
}
470
467
471
- func computeSSTStatsDiffWrapper (
468
+ func computeSSTStatsDiffWithFallback (
472
469
ctx context.Context ,
473
470
sst []byte ,
474
471
readWriter storage.ReadWriter ,
@@ -519,7 +516,7 @@ func computeSSTStats(ctx context.Context, sst []byte, nowNanos int64) (enginepb.
519
516
}
520
517
521
518
// checkSSTSpanBounds verifies that the keys in the sstable are within the
522
- // span specified by the request header .
519
+ // span specified by [start, end] .
523
520
func checkSSTSpanBounds (ctx context.Context , sst []byte , start , end storage.MVCCKey ) error {
524
521
sstIter , err := storage .NewMemSSTIterator (sst , true /* verify */ , storage.IterOptions {
525
522
KeyTypes : storage .IterKeyTypePointsAndRanges ,
0 commit comments