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
85
vendor/github.com/pingcap/go-themis/themis_scan.go
generated
vendored
Normal file
85
vendor/github.com/pingcap/go-themis/themis_scan.go
generated
vendored
Normal file
|
@ -0,0 +1,85 @@
|
|||
package themis
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/binary"
|
||||
|
||||
"github.com/ngaut/log"
|
||||
"github.com/pingcap/go-hbase"
|
||||
)
|
||||
|
||||
type ThemisScanner struct {
|
||||
scan *hbase.Scan
|
||||
txn *themisTxn
|
||||
tbl []byte
|
||||
}
|
||||
|
||||
func newThemisScanner(tbl []byte, txn *themisTxn, batchSize int, c hbase.HBaseClient) *ThemisScanner {
|
||||
s := hbase.NewScan(tbl, batchSize, c)
|
||||
// add start ts
|
||||
b := bytes.NewBuffer(nil)
|
||||
binary.Write(b, binary.BigEndian, txn.startTs)
|
||||
s.AddAttr("_themisTransationStartTs_", b.Bytes())
|
||||
return &ThemisScanner{
|
||||
scan: s,
|
||||
txn: txn,
|
||||
tbl: tbl,
|
||||
}
|
||||
}
|
||||
|
||||
func (s *ThemisScanner) setStartRow(start []byte) {
|
||||
s.scan.StartRow = start
|
||||
}
|
||||
|
||||
func (s *ThemisScanner) setStopRow(stop []byte) {
|
||||
s.scan.StopRow = stop
|
||||
}
|
||||
|
||||
func (s *ThemisScanner) SetTimeRange(tsRangeFrom uint64, tsRangeTo uint64) {
|
||||
s.scan.TsRangeFrom = tsRangeFrom
|
||||
s.scan.TsRangeTo = tsRangeTo
|
||||
}
|
||||
|
||||
func (s *ThemisScanner) SetMaxVersions(maxVersions uint32) {
|
||||
s.scan.MaxVersions = maxVersions
|
||||
}
|
||||
|
||||
func (s *ThemisScanner) createGetFromScan(row []byte) *hbase.Get {
|
||||
return s.scan.CreateGetFromScan(row)
|
||||
}
|
||||
|
||||
func (s *ThemisScanner) Next() *hbase.ResultRow {
|
||||
r := s.scan.Next()
|
||||
if r == nil {
|
||||
return nil
|
||||
}
|
||||
// if we encounter conflict locks, we need to clean lock for this row and read again
|
||||
if isLockResult(r) {
|
||||
g := s.createGetFromScan(r.Row)
|
||||
r, err := s.txn.tryToCleanLockAndGetAgain(s.tbl, g, r.SortedColumns)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return nil
|
||||
}
|
||||
// empty result indicates the current row has been erased, we should get next row
|
||||
if r == nil {
|
||||
return s.Next()
|
||||
} else {
|
||||
return r
|
||||
}
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
func (s *ThemisScanner) Closed() bool {
|
||||
return s.scan.Closed()
|
||||
}
|
||||
|
||||
func (s *ThemisScanner) Close() {
|
||||
if !s.scan.Closed() {
|
||||
// TODO: handle error, now just log
|
||||
if err := s.scan.Close(); err != nil {
|
||||
log.Warnf("scanner close error, scan: %s, error: %v", s.scan, err)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue