Couchbase gocb批量操作提供部分空结果
在使用gocb的go代码中,我们查询一个返回32k ID的视图。然后,我们执行一个批量查询(见下面的代码),如中所述。然而,我们只能得到部分结果。我们可以看到Couchbase gocb批量操作提供部分空结果,go,couchbase,gocb,Go,Couchbase,Gocb,在使用gocb的go代码中,我们查询一个返回32k ID的视图。然后,我们执行一个批量查询(见下面的代码),如中所述。然而,我们只能得到部分结果。我们可以看到ruleset,:=items[i]。(*gocb.GetOp).Value.(*ruleset)只返回前2048个id的值。那么IDs2049-11322不包含值,依此类推。我们的结果如下所示: Line 1 Key: 12345678901234567890123456789012, Value: map[0.0.0.0/0:map[j
ruleset,:=items[i]。(*gocb.GetOp).Value.(*ruleset)
只返回前2048个id的值。那么IDs2049-11322不包含值,依此类推。我们的结果如下所示:
Line 1 Key: 12345678901234567890123456789012, Value: map[0.0.0.0/0:map[jsona:valueofjsona]]
...
Line 2018 Key: 12345678901234567890123456712345, Value: map[0.0.0.0/0:map[jsona:valueofjsona]]
Line 2019 Key: 12345678901234567890123456712345, Value: map[]
...
Line 11323 Key: 12345678901234567890123456712347, Value: map[jsonb:valueofjsonb]]
(上面的行已简化,键与实际数据不匹配,值也不匹配。)
请求的数据中有很大一部分实际上没有返回:
CB# grep '\[\]' result.out |wc -l
27042
CB# wc -l result.out
31988 rdmp.out
bucket.do
在处理完所有查询之前返回吗?我们查看了API代码,没有找到解释
你知道怎么解决这个问题吗
type RuleSet struct {
Rules map[string]interface{} "json:\"rules,\""
}
func DiffViaBulkQuery() {
var items []gocb.BulkOp
var row interface{}
var cnt int = 0
bucket := cbase.MyBucket()
// [...]
// add 600k entries to itemsget in a loop like
// itemsGet = append(itemsGet, &gocb.GetOp{Key: key + "_" + strconv.Itoa(i), Value: &Doc{}})
// Perform the bulk operation to Get all documents
err = bucket.Do(itemsGet)
if err != nil {
fmt.Println("ERRROR PERFORMING BULK GET:", err)
}
// Print the output
for i := 0; i < len(itemsGet); i++ {
fmt.Println(itemsGet[i].(*gocb.GetOp).Key, itemsGet[i].(*gocb.GetOp).Value.(*Doc).Item)
}
类型规则集结构{
规则映射[字符串]接口{}“json:\”规则,\“”
}
func diffvia查询(){
var项目[]gocb.BulkOp
变量行接口{}
var cnt int=0
bucket:=cbase.MyBucket()
// [...]
//在循环中向itemsget添加600k个条目,如
//itemsGet=append(itemsGet,&gocb.GetOp{Key:Key+“”+strconv.Itoa(i),Value:&Doc{})
//执行批量操作以获取所有文档
err=bucket.Do(itemsGet)
如果错误!=零{
fmt.Println(“执行批量获取时出错:”,err)
}
//打印输出
对于i:=0;i
Thx提前,
Torsten检查您正在执行的每个操作的错误值是值得的。您可以通过执行
op.Err
来执行此操作,例如
for i := 0; i < len(items); i++ {
fmt.Println(items[i].(*gocb.GetOp).Key, items[i].(*gocb.GetOp).Value.(*Doc).Item, items[i].(*gocb.GetOp).Err)
}
i:=0;i队列溢出
错误,gocb调度程序队列已满,默认最大大小为2048个项目。解决方案通常是以较小的批次执行工作,以免gocb过载。上的示例也存在类似问题