forked from forgejo/forgejo
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
This commit is contained in:
parent
4680c349dd
commit
b6a95a8cb3
691 changed files with 305318 additions and 1272 deletions
92
vendor/github.com/pingcap/go-hbase/put.go
generated
vendored
Normal file
92
vendor/github.com/pingcap/go-hbase/put.go
generated
vendored
Normal file
|
@ -0,0 +1,92 @@
|
|||
package hbase
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"math"
|
||||
|
||||
pb "github.com/golang/protobuf/proto"
|
||||
"github.com/pingcap/go-hbase/proto"
|
||||
)
|
||||
|
||||
type Put struct {
|
||||
Row []byte
|
||||
Families [][]byte
|
||||
Qualifiers [][][]byte
|
||||
Values [][][]byte
|
||||
Timestamp uint64
|
||||
}
|
||||
|
||||
func NewPut(row []byte) *Put {
|
||||
return &Put{
|
||||
Row: row,
|
||||
Families: make([][]byte, 0),
|
||||
Qualifiers: make([][][]byte, 0),
|
||||
Values: make([][][]byte, 0),
|
||||
}
|
||||
}
|
||||
|
||||
func (p *Put) GetRow() []byte {
|
||||
return p.Row
|
||||
}
|
||||
|
||||
func (p *Put) AddValue(family, qual, value []byte) *Put {
|
||||
pos := p.posOfFamily(family)
|
||||
if pos == -1 {
|
||||
p.Families = append(p.Families, family)
|
||||
p.Qualifiers = append(p.Qualifiers, make([][]byte, 0))
|
||||
p.Values = append(p.Values, make([][]byte, 0))
|
||||
|
||||
pos = p.posOfFamily(family)
|
||||
}
|
||||
|
||||
p.Qualifiers[pos] = append(p.Qualifiers[pos], qual)
|
||||
p.Values[pos] = append(p.Values[pos], value)
|
||||
return p
|
||||
}
|
||||
|
||||
func (p *Put) AddStringValue(family, column, value string) *Put {
|
||||
return p.AddValue([]byte(family), []byte(column), []byte(value))
|
||||
}
|
||||
|
||||
func (p *Put) AddTimestamp(ts uint64) *Put {
|
||||
if ts == 0 {
|
||||
p.Timestamp = math.MaxInt64
|
||||
} else {
|
||||
p.Timestamp = ts
|
||||
}
|
||||
return p
|
||||
}
|
||||
|
||||
func (p *Put) posOfFamily(family []byte) int {
|
||||
for p, v := range p.Families {
|
||||
if bytes.Equal(family, v) {
|
||||
return p
|
||||
}
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
func (p *Put) ToProto() pb.Message {
|
||||
put := &proto.MutationProto{
|
||||
Row: p.Row,
|
||||
MutateType: proto.MutationProto_PUT.Enum(),
|
||||
}
|
||||
|
||||
for i, family := range p.Families {
|
||||
cv := &proto.MutationProto_ColumnValue{
|
||||
Family: family,
|
||||
}
|
||||
|
||||
for j := range p.Qualifiers[i] {
|
||||
cv.QualifierValue = append(cv.QualifierValue, &proto.MutationProto_ColumnValue_QualifierValue{
|
||||
Qualifier: p.Qualifiers[i][j],
|
||||
Value: p.Values[i][j],
|
||||
Timestamp: pb.Uint64(p.Timestamp),
|
||||
})
|
||||
}
|
||||
|
||||
put.ColumnValue = append(put.ColumnValue, cv)
|
||||
}
|
||||
|
||||
return put
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue