Open jonbonazza opened 7 years ago
Well, it depends on how you define an empty case.
In our codebase, if we have an empty result (no cells), that means that no values have been found. It kind of makes the code nicer as we don't have to check if res == nil
, but instead just check len(res.Cell) == 0
.
Maybe it would be nicer to return nil
instead of empty hrpc.Result
, I don't have strong preference though. If nothing is found, then you'll have nil, nil returned, which is kind of strange also?
@timoha thinking about this more, the standard approach to something like this seems to be to return a specific error (i.e. ErrNoResults
) along with a nil Result
. What are your thoughts on this approach? For now, we are using len
.
@timoha We have come across a pretty major issue. When using
Client.Get
, if no result is found in HBase, HBase will return an RPC with no value and no error. The gohbase client will take this rpc response and return an empty*hrpc.Result
and no error. A workaround is to check the resulting*hrpc.Result
and make sure it's not the zero value, working under the assumption that a zero valuehrpc.Result
is never valid.I am fairly certain that the resulting code is here:
I can submit a PR for this if you wish, but I wanted to check in here to ensure that there wasn't some specific reason that an empty struct is returned here.