1
This commit is contained in:
parent
7685c13942
commit
1b00affd82
38
dbpool.go
38
dbpool.go
@ -134,6 +134,44 @@ func (this *dbPool) SyncBatchLoadFullTable(dataSource string, sqlTpl string,
|
|||||||
return lastIdx
|
return lastIdx
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *dbPool) BatchLoadFullTable(
|
||||||
|
dataSource string,
|
||||||
|
sqlCb func(int64) string,
|
||||||
|
params []string,
|
||||||
|
nextTimeCb func() int64,
|
||||||
|
doCb func(*DataSet) bool) error {
|
||||||
|
if this.style != GO_STYLE_DB {
|
||||||
|
panic("dbpool.BatchLoadFullTable is not gostyle")
|
||||||
|
}
|
||||||
|
var resultErr error
|
||||||
|
var lastIdx int64
|
||||||
|
done := false
|
||||||
|
for !done && resultErr == nil {
|
||||||
|
this.SyncSelectCustomQuery(
|
||||||
|
dataSource,
|
||||||
|
sqlCb(lastIdx),
|
||||||
|
func (err error, ds *DataSet) {
|
||||||
|
if err != nil {
|
||||||
|
resultErr = err
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for ds.Next() {
|
||||||
|
idx := q5.ToInt64(ds.GetByName("idx"))
|
||||||
|
doCb(ds)
|
||||||
|
if idx > lastIdx {
|
||||||
|
lastIdx = idx
|
||||||
|
} else {
|
||||||
|
panic(fmt.Sprintf("BatchLoadFullTable idx error:%s %s", idx, lastIdx))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ds.NumOfReaded() <= 0 {
|
||||||
|
done = true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return resultErr
|
||||||
|
}
|
||||||
|
|
||||||
func (this *dbPool) LoopLoad(
|
func (this *dbPool) LoopLoad(
|
||||||
dataSource string,
|
dataSource string,
|
||||||
name string,
|
name string,
|
||||||
|
@ -133,8 +133,9 @@ func DataSetStreamPageQuery(dataSet []interface{},
|
|||||||
var dataSetCopy []*interface{}
|
var dataSetCopy []*interface{}
|
||||||
q5.NewSlice(&dataSetCopy, 0, int32(len(dataSet)))
|
q5.NewSlice(&dataSetCopy, 0, int32(len(dataSet)))
|
||||||
for _, val := range dataSet {
|
for _, val := range dataSet {
|
||||||
|
tmpVal := val
|
||||||
if filterCb(val) {
|
if filterCb(val) {
|
||||||
q5.AppendSlice(&dataSetCopy, &val)
|
q5.AppendSlice(&dataSetCopy, &tmpVal)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
q5.Sort(dataSetCopy, func(a *interface{}, b *interface{}) bool {
|
q5.Sort(dataSetCopy, func(a *interface{}, b *interface{}) bool {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user