Skip to content

Commit

Permalink
Keep priority on scanner's subsequent scans
Browse files Browse the repository at this point in the history
If a scanner needs to scan multiple times ensure all scanners get the
priority set in the initial hrpc.Scan.

Updated baseQuery.Priority to return a uint32 rather than a *uint32 to
be less weird.
  • Loading branch information
aaronbee committed Aug 15, 2024
1 parent e08f807 commit 9b17025
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
7 changes: 2 additions & 5 deletions hrpc/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,8 @@ func (bq *baseQuery) setConsistency(consistency ConsistencyType) {
func (bq *baseQuery) setPriority(priority uint32) {
bq.priority = priority
}
func (bq *baseQuery) Priority() *uint32 {
if bq.priority == 0 {
return nil
}
return &bq.priority
func (bq *baseQuery) Priority() uint32 {
return bq.priority
}

// Families option adds families constraint to a Scan or Get request.
Expand Down
6 changes: 4 additions & 2 deletions region/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -687,8 +687,10 @@ func marshalProto(rpc hrpc.Call, callID uint32, request proto.Message,
header.MethodName = proto.String(rpc.Name())
header.RequestParam = pbTrue
header.CallId = &callID
if p, ok := rpc.(interface{ Priority() *uint32 }); ok {
header.Priority = p.Priority()
if p, ok := rpc.(interface{ Priority() uint32 }); ok {
if p := p.Priority(); p > 0 {
header.Priority = &p
}
}

if cellblocksLen > 0 {
Expand Down
4 changes: 3 additions & 1 deletion scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,9 @@ func (s *scanner) request() (*pb.ScanResponse, hrpc.RegionInfo, error) {
s.startRow,
nil,
hrpc.ScannerID(s.curRegionScannerID),
hrpc.NumberOfRows(s.rpc.NumberOfRows()))
hrpc.NumberOfRows(s.rpc.NumberOfRows()),
hrpc.Priority(s.rpc.Priority()),
)
}
if err != nil {
return nil, nil, err
Expand Down

0 comments on commit 9b17025

Please sign in to comment.