add protobuf struct for baseinfo
| | |
| | | import ( |
| | | "errors" |
| | | "strconv" |
| | | |
| | | "basic.com/pubsub/protomsg.git" |
| | | ) |
| | | |
| | | func DbPersoninfos( queryindex int, querynums int ) (dbpersoninfos []Baseinfo, err error){ |
| | | func DbPersoninfos( queryindex int, querynums int ) (dbpersoninfos []protomsg.Baseinfo, err error){ |
| | | point := strconv.Itoa(queryindex) |
| | | number := strconv.Itoa(querynums) |
| | | |
| | |
| | | ] |
| | | }` |
| | | |
| | | // 返回请求的buf |
| | | buf, err := GetDbinfo(dbinfoRequest ) |
| | | if err != nil { |
| | | return nil ,errors.New("http request get dbperson info is err!") |
| | | } |
| | | |
| | | // 返回 _source 数组 |
| | | sources, err := Sourcelist(buf) |
| | | if err != nil { |
| | | return nil,err |
| | | } |
| | | |
| | | // 返回所有查询的数据 |
| | | dbpersoninfos = Parsesources(sources) |
| | | return dbpersoninfos, nil |
| | | } |
| | |
| | | "net/http" |
| | | "time" |
| | | "bytes" |
| | | |
| | | "basic.com/pubsub/protomsg.git" |
| | | ) |
| | | |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | func Parsesources(sources []map[string]interface{}) []Baseinfo { |
| | | var tmpinfo Baseinfo |
| | | var baseinfos []Baseinfo |
| | | func Parsesources(sources []map[string]interface{}) []protomsg.Baseinfo { |
| | | var tmpinfo protomsg.Baseinfo |
| | | var baseinfos []protomsg.Baseinfo |
| | | var ok bool |
| | | for _, source := range sources { |
| | | |
| | |
| | | import ( |
| | | "sync" |
| | | "fmt" |
| | | |
| | | "basic.com/pubsub/protomsg.git" |
| | | ) |
| | | |
| | | const ( |
| | |
| | | } |
| | | |
| | | // modify by long. |
| | | func (s *ShardMap) Walk(wf wfOp, cfrom string) []interface{} { |
| | | func (s *ShardMap) Walk(wf wfOp, cfrom string) []protomsg.Baseinfo{ |
| | | var wg sync.WaitGroup |
| | | var second float32 |
| | | |
| | | var baseinfos []interface{} |
| | | var baseinfos []protomsg.Baseinfo |
| | | |
| | | for _, si := range s.shards { |
| | | wg.Add(1) |
| | |
| | | if second == -1 { |
| | | continue |
| | | } |
| | | fmt.Println("比对分数: ", second) |
| | | baseinfos = append(baseinfos, value ) |
| | | if info, ok := value.(protomsg.Baseinfo) ;ok { |
| | | fmt.Println("比对分数: ", second) |
| | | info.CompareScore = second |
| | | baseinfos = append(baseinfos,info) |
| | | } |
| | | } |
| | | s.RUnlock() |
| | | }(si,wf, cfrom) |
| | | |
| | | } |
| | | wg.Wait() |
| | | return baseinfos |