Skip to content

Commit fa81664

Browse files
craig[bot]mgartner
andcommitted
Merge #159088
159088: kvcoord: inline gcassert:bce assertions r=rickystewart a=mgartner The `gcassert:bce` assertions added in 888140d are added at the end of their lines, for better readability. Release note: None Co-authored-by: Marcus Gartner <[email protected]>
2 parents 947a416 + 39de8b0 commit fa81664

File tree

1 file changed

+20
-40
lines changed

1 file changed

+20
-40
lines changed

pkg/kv/kvclient/kvcoord/batch.go

Lines changed: 20 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -485,14 +485,12 @@ func (h *BatchTruncationHelper) truncateAsc(rs roachpb.RSpan) ([]kvpb.RequestUni
485485

486486
fullyProcessed := 0
487487
for i := range positions {
488-
//gcassert:bce
489-
pos := positions[i]
488+
pos := positions[i] //gcassert:bce
490489
if pos < 0 {
491490
fullyProcessed++
492491
continue
493492
}
494-
//gcassert:bce
495-
header := headers[i]
493+
header := headers[i] //gcassert:bce
496494
ek := rs.EndKey.AsRawKey()
497495
if ek.Compare(header.Key) <= 0 {
498496
// All of the remaining requests start after this range, so we're
@@ -514,31 +512,26 @@ func (h *BatchTruncationHelper) truncateAsc(rs roachpb.RSpan) ([]kvpb.RequestUni
514512
truncPositions := make([]int, 0, numReqs)
515513

516514
for i := range positions {
517-
//gcassert:bce
518-
pos := positions[i]
515+
pos := positions[i] //gcassert:bce
519516
if pos < 0 {
520517
// This request has already been fully processed, so there is no
521518
// need to look at it.
522519
continue
523520
}
524-
//gcassert:bce
525-
header := headers[i]
521+
header := headers[i] //gcassert:bce
526522
// rs.EndKey can't be local because it contains range split points,
527523
// which are never local.
528524
ek := rs.EndKey.AsRawKey()
529-
//gcassert:bce
530-
req := requests[i]
525+
req := requests[i] //gcassert:bce
531526
//gcassert:bce
532527
if !isRange[i] {
533528
// This is a point request, and the key is contained within this
534529
// range, so we include the request as is and mark it as "fully
535530
// processed".
536531
truncReqs = append(truncReqs, req)
537532
truncPositions = append(truncPositions, pos)
538-
//gcassert:bce
539-
headers[i] = kvpb.RequestHeader{}
540-
//gcassert:bce
541-
positions[i] = -1
533+
headers[i] = kvpb.RequestHeader{} //gcassert:bce
534+
positions[i] = -1 //gcassert:bce
542535
continue
543536
}
544537
// We're dealing with a range-spanning request.
@@ -555,10 +548,8 @@ func (h *BatchTruncationHelper) truncateAsc(rs roachpb.RSpan) ([]kvpb.RequestUni
555548
if header.EndKey.Compare(ek) <= 0 {
556549
// This is the last part of this request since it is fully contained
557550
// within this range, so we mark the request as "fully processed".
558-
//gcassert:bce
559-
headers[i] = kvpb.RequestHeader{}
560-
//gcassert:bce
561-
positions[i] = -1
551+
headers[i] = kvpb.RequestHeader{} //gcassert:bce
552+
positions[i] = -1 //gcassert:bce
562553
if origStartKey := inner.Header().Key; origStartKey.Equal(header.Key) {
563554
// This range-spanning request fits within a single range, so we
564555
// can just use the original request.
@@ -570,8 +561,7 @@ func (h *BatchTruncationHelper) truncateAsc(rs roachpb.RSpan) ([]kvpb.RequestUni
570561
header.EndKey = ek
571562
// Adjust the start key of the header so that it contained only the
572563
// unprocessed suffix of the request.
573-
//gcassert:bce
574-
headers[i].Key = header.EndKey
564+
headers[i].Key = header.EndKey //gcassert:bce
575565
}
576566
shallowCopy := inner.ShallowCopy()
577567
shallowCopy.SetHeader(header)
@@ -684,14 +674,12 @@ func (h *BatchTruncationHelper) truncateDesc(rs roachpb.RSpan) ([]kvpb.RequestUn
684674

685675
fullyProcessed := 0
686676
for i := range positions {
687-
//gcassert:bce
688-
pos := positions[i]
677+
pos := positions[i] //gcassert:bce
689678
if pos < 0 {
690679
fullyProcessed++
691680
continue
692681
}
693-
//gcassert:bce
694-
header := headers[i]
682+
header := headers[i] //gcassert:bce
695683
sk := rs.Key.AsRawKey()
696684
if sk.Compare(header.EndKey) >= 0 {
697685
// All of the remaining requests end before this range, so we're
@@ -713,31 +701,26 @@ func (h *BatchTruncationHelper) truncateDesc(rs roachpb.RSpan) ([]kvpb.RequestUn
713701
truncPositions := make([]int, 0, numReqs)
714702

715703
for i := range positions {
716-
//gcassert:bce
717-
pos := positions[i]
704+
pos := positions[i] //gcassert:bce
718705
if pos < 0 {
719706
// This request has already been fully processed, so there is no
720707
// need to look at it.
721708
continue
722709
}
723-
//gcassert:bce
724-
header := headers[i]
710+
header := headers[i] //gcassert:bce
725711
// rs.Key can't be local because it contains range split points, which
726712
// are never local.
727713
sk := rs.Key.AsRawKey()
728-
//gcassert:bce
729-
req := requests[i]
714+
req := requests[i] //gcassert:bce
730715
//gcassert:bce
731716
if !isRange[i] {
732717
// This is a point request, and the key is contained within this
733718
// range, so we include the request as is and mark it as "fully
734719
// processed".
735720
truncReqs = append(truncReqs, req)
736721
truncPositions = append(truncPositions, pos)
737-
//gcassert:bce
738-
headers[i] = kvpb.RequestHeader{}
739-
//gcassert:bce
740-
positions[i] = -1
722+
headers[i] = kvpb.RequestHeader{} //gcassert:bce
723+
positions[i] = -1 //gcassert:bce
741724
continue
742725
}
743726
// We're dealing with a range-spanning request.
@@ -754,10 +737,8 @@ func (h *BatchTruncationHelper) truncateDesc(rs roachpb.RSpan) ([]kvpb.RequestUn
754737
if header.Key.Compare(sk) >= 0 {
755738
// This is the last part of this request since it is fully contained
756739
// within this range, so we mark the request as "fully processed".
757-
//gcassert:bce
758-
headers[i] = kvpb.RequestHeader{}
759-
//gcassert:bce
760-
positions[i] = -1
740+
headers[i] = kvpb.RequestHeader{} //gcassert:bce
741+
positions[i] = -1 //gcassert:bce
761742
if origEndKey := inner.Header().EndKey; len(origEndKey) == 0 || origEndKey.Equal(header.EndKey) {
762743
// This range-spanning request fits within a single range, so we
763744
// can just use the original request.
@@ -769,8 +750,7 @@ func (h *BatchTruncationHelper) truncateDesc(rs roachpb.RSpan) ([]kvpb.RequestUn
769750
header.Key = sk
770751
// Adjust the end key of the header so that it contained only the
771752
// unprocessed prefix of the request.
772-
//gcassert:bce
773-
headers[i].EndKey = header.Key
753+
headers[i].EndKey = header.Key //gcassert:bce
774754
}
775755
shallowCopy := inner.ShallowCopy()
776756
shallowCopy.SetHeader(header)

0 commit comments

Comments
 (0)