From 9b17025e68f9338f520e01a81ff401b7a475b08e Mon Sep 17 00:00:00 2001 From: Aaron Beitch Date: Thu, 15 Aug 2024 14:50:04 -0700 Subject: [PATCH] Keep priority on scanner's subsequent scans 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. --- hrpc/query.go | 7 ++----- region/client.go | 6 ++++-- scanner.go | 4 +++- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/hrpc/query.go b/hrpc/query.go index d279890..c95f3ad 100644 --- a/hrpc/query.go +++ b/hrpc/query.go @@ -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. diff --git a/region/client.go b/region/client.go index c50ae34..57796d7 100644 --- a/region/client.go +++ b/region/client.go @@ -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 { diff --git a/scanner.go b/scanner.go index a5aaa69..4b7bc07 100644 --- a/scanner.go +++ b/scanner.go @@ -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