From 6fdb4a7ae10e30be838caea9f43b9b48f280ce02 Mon Sep 17 00:00:00 2001 From: Murphy Law Date: Sat, 25 May 2019 20:16:14 -0700 Subject: [PATCH] hrpc: don't always expect partials for scan Older hbase versions (e.g. 1.0.x) do not support partials. If partials aren't provided by the regionserver then treat the cell results as complete. Closes #81 --- hrpc/scan.go | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/hrpc/scan.go b/hrpc/scan.go index cf8064da..dd2c8c78 100644 --- a/hrpc/scan.go +++ b/hrpc/scan.go @@ -228,16 +228,23 @@ func (s *Scan) NewResponse() proto.Message { func (s *Scan) DeserializeCellBlocks(m proto.Message, b []byte) (uint32, error) { scanResp := m.(*pb.ScanResponse) partials := scanResp.GetPartialFlagPerResult() - scanResp.Results = make([]*pb.Result, len(partials)) + cellsPerResult := scanResp.GetCellsPerResult() + if len(partials) == 0 { + scanResp.Results = make([]*pb.Result, len(cellsPerResult)) + } else { + scanResp.Results = make([]*pb.Result, len(partials)) + } var readLen uint32 - for i, numCells := range scanResp.GetCellsPerResult() { + for i, numCells := range cellsPerResult { cells, l, err := deserializeCellBlocks(b[readLen:], numCells) if err != nil { return 0, err } - scanResp.Results[i] = &pb.Result{ - Cell: cells, - Partial: proto.Bool(partials[i]), + scanResp.Results[i] = &pb.Result{Cell: cells} + if len(partials) == 0 { + scanResp.Results[i].Partial = proto.Bool(false) + } else { + scanResp.Results[i].Partial = proto.Bool(partials[i]) } readLen += l }