mirror of
https://github.com/go-gitea/gitea
synced 2024-12-19 16:54:14 +01:00
b6a95a8cb3
* 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
76 lines
1.4 KiB
Go
76 lines
1.4 KiB
Go
package hbase
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/pingcap/go-hbase/proto"
|
|
)
|
|
|
|
type Kv struct {
|
|
Row []byte
|
|
Ts uint64
|
|
Value []byte
|
|
// history results
|
|
Values map[uint64][]byte
|
|
Column
|
|
}
|
|
|
|
func (kv *Kv) String() string {
|
|
if kv == nil {
|
|
return "<nil>"
|
|
}
|
|
return fmt.Sprintf("Kv(%+v)", *kv)
|
|
}
|
|
|
|
type ResultRow struct {
|
|
Row []byte
|
|
Columns map[string]*Kv
|
|
SortedColumns []*Kv
|
|
}
|
|
|
|
func (r *ResultRow) String() string {
|
|
if r == nil {
|
|
return "<nil>"
|
|
}
|
|
return fmt.Sprintf("ResultRow(%+v)", *r)
|
|
}
|
|
|
|
func NewResultRow(result *proto.Result) *ResultRow {
|
|
// empty response
|
|
if len(result.GetCell()) == 0 {
|
|
return nil
|
|
}
|
|
res := &ResultRow{}
|
|
res.Columns = make(map[string]*Kv)
|
|
res.SortedColumns = make([]*Kv, 0)
|
|
|
|
for _, cell := range result.GetCell() {
|
|
res.Row = cell.GetRow()
|
|
|
|
col := &Kv{
|
|
Row: res.Row,
|
|
Column: Column{
|
|
Family: cell.GetFamily(),
|
|
Qual: cell.GetQualifier(),
|
|
},
|
|
Value: cell.GetValue(),
|
|
Ts: cell.GetTimestamp(),
|
|
}
|
|
|
|
colName := string(col.Column.Family) + ":" + string(col.Column.Qual)
|
|
|
|
if v, exists := res.Columns[colName]; exists {
|
|
// renew the same cf result
|
|
if col.Ts > v.Ts {
|
|
v.Value = col.Value
|
|
v.Ts = col.Ts
|
|
}
|
|
v.Values[col.Ts] = col.Value
|
|
} else {
|
|
col.Values = map[uint64][]byte{col.Ts: col.Value}
|
|
res.Columns[colName] = col
|
|
res.SortedColumns = append(res.SortedColumns, col)
|
|
}
|
|
}
|
|
return res
|
|
}
|