0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2024-12-29 10:54:02 -05:00
forgejo/vendor/github.com/pingcap/go-hbase/client_ops.go
Thomas Boerger b6a95a8cb3 Integrate public as bindata optionally (#293)
* Dropped unused codekit config

* Integrated dynamic and static bindata for public

* Ignore public bindata

* Add a general generate make task

* Integrated flexible public assets into web command

* Updated vendoring, added all missiong govendor deps

* Made the linter happy with the bindata and dynamic code

* Moved public bindata definition to modules directory

* Ignoring the new bindata path now

* Updated to the new public modules import path

* Updated public bindata command and drop the new prefix
2016-11-30 00:26:36 +08:00

67 lines
1.8 KiB
Go

package hbase
import (
"github.com/juju/errors"
"github.com/pingcap/go-hbase/proto"
)
func (c *client) Delete(table string, del *Delete) (bool, error) {
response, err := c.do([]byte(table), del.GetRow(), del, true)
if err != nil {
return false, errors.Trace(err)
}
switch r := response.(type) {
case *proto.MutateResponse:
return r.GetProcessed(), nil
}
return false, errors.Errorf("Invalid response seen [response: %#v]", response)
}
func (c *client) Get(table string, get *Get) (*ResultRow, error) {
response, err := c.do([]byte(table), get.GetRow(), get, true)
if err != nil {
return nil, errors.Trace(err)
}
switch r := response.(type) {
case *proto.GetResponse:
res := r.GetResult()
if res == nil {
return nil, errors.Errorf("Empty response: [table=%s] [row=%q]", table, get.GetRow())
}
return NewResultRow(res), nil
case *exception:
return nil, errors.New(r.msg)
}
return nil, errors.Errorf("Invalid response seen [response: %#v]", response)
}
func (c *client) Put(table string, put *Put) (bool, error) {
response, err := c.do([]byte(table), put.GetRow(), put, true)
if err != nil {
return false, errors.Trace(err)
}
switch r := response.(type) {
case *proto.MutateResponse:
return r.GetProcessed(), nil
}
return false, errors.Errorf("Invalid response seen [response: %#v]", response)
}
func (c *client) ServiceCall(table string, call *CoprocessorServiceCall) (*proto.CoprocessorServiceResponse, error) {
response, err := c.do([]byte(table), call.Row, call, true)
if err != nil {
return nil, errors.Trace(err)
}
switch r := response.(type) {
case *proto.CoprocessorServiceResponse:
return r, nil
case *exception:
return nil, errors.New(r.msg)
}
return nil, errors.Errorf("Invalid response seen [response: %#v]", response)
}