554325746@qq.com
2019-07-11 9dd7bb8196b8c03c19bc3f1fbfe8a1f93341fdfe
fix cache
2个文件已修改
49 ■■■■■ 已修改文件
dbpersoninfo.go 31 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
shardmap/shardmap.go 18 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
dbpersoninfo.go
@@ -9,6 +9,8 @@
    "basic.com/pubsub/cache.git/esutil"
    "basic.com/pubsub/cache.git/shardmap"
    "test/cache/esutil"
    "test/cache/shardmap"
    "basic.com/valib/gosdk.git"
)
@@ -64,14 +66,9 @@
    fmt.Println()
}
//func main(){
//    Init()
//    Getdbpersonmsg("")
//}
func Getdbpersonmsg(tableid string, teststring []byte, IsCompare bool) (map[string]float32) {
func Getdbpersonmsg(tableid string, teststring []byte, IsCompare bool) ([]byte) {
    var buf []byte
    totalmap := make(map[string]float32)
    if !IsCompare {
        return nil
@@ -82,17 +79,21 @@
    }
    if tableid == "" {
        for _, val := range Cmap.cam{
            tmpbuf := val.Walk(Printest, teststring)
            buf =append(buf, tmpbuf...)
        for id, val := range Cmap.cam{
            fmt.Println("the id is: ", id)
            tmpmap := val.Walk(Printest, teststring)
            for key, sec := range tmpmap {
                totalmap[key] = sec
            }
        }
    }else{
       for id, value := range Cmap.cam{
            if id == tableid{
                fmt.Println(id)
                buf =value.Walk(Printest, teststring)
                fmt.Println("the id is: ", id)
                tmpmap :=value.Walk(Printest, teststring)
                for key, sec := range tmpmap {
                    totalmap[key]= sec
                }
                break
            }
       }
@@ -103,7 +104,7 @@
    firsttime := time.Now()
    fmt.Println(time.Since(firsttime))
    return  buf
    return  totalmap
}
func Printest(ci []byte, co string ) (float32){
shardmap/shardmap.go
@@ -4,8 +4,8 @@
import (
    "sync"
    "encoding/json"
    "fmt"
    //"encoding/json"
    //"fmt"
)
var commonmux sync.Mutex
@@ -78,11 +78,9 @@
}
// modify by long.
func (s *ShardMap) Walk(wf wfOp, cfrom []byte) ([]byte){
func (s *ShardMap) Walk(wf wfOp, cfrom []byte) ( map[string]float32 ){
    var wg sync.WaitGroup
    var second float32 
    var buf []byte
    var err error
    ids := make(map[string]float32)
    for _, si := range s.shards {
@@ -109,15 +107,9 @@
    }
    wg.Wait()
    fmt.Println("value of map: ",ids)
    buf, err = json.Marshal(ids)
    if err != nil {
        fmt.Println("compare json err")
            buf = nil
    }
    return buf
    return ids
}
// print all