554325746@qq.com
2019-07-12 e73efb4afc3bc91ddc49ac63f0f3db463d1f8cc1
dbpersoninfo.go
@@ -7,11 +7,10 @@
    "sync"
    "encoding/base64"
    "test/cache/esutil"
    "test/cache/shardmap"
//   "basic.com/pubsub/cache.git/esutil"
//  "basic.com/pubsub/cache.git/shardmap"
//  "basic.com/pubsub/protomsg.git"
    "encoding/json"
    "basic.com/pubsub/cache.git/esutil"
    "basic.com/pubsub/cache.git/shardmap"
    "basic.com/valib/gosdk.git"
)
@@ -21,7 +20,7 @@
type CmapItem struct {
    sync.Mutex
    cam map[string]*shardmap.ShardMap
    Cam map[string]*shardmap.ShardMap
}
var Cmap *CmapItem
@@ -31,7 +30,7 @@
    gosdk.InitFaceExtractor(16, 0)
    Cmap = &CmapItem{
        cam: make(map[string]*shardmap.ShardMap),
        Cam: make(map[string]*shardmap.ShardMap),
    }
    temptime := time.Now()
@@ -51,11 +50,11 @@
            Cmap.Lock()           
           for _, value := range escache{
                if _, ok :=Cmap.cam[value.Tableid]; !ok {
                   Cmap.cam[value.Tableid]=shardmap.New(uint8(*threadnum))
                if _, ok :=Cmap.Cam[value.Tableid]; !ok {
                   Cmap.Cam[value.Tableid]=shardmap.New(uint8(*threadnum))
                }
                
                Cmap.cam[value.Tableid].Set(value.Id,value.FaceFeature)
                Cmap.Cam[value.Tableid].Set(value.Id,value.FaceFeature)
           }
            Cmap.Unlock()
@@ -67,44 +66,52 @@
    fmt.Println()
}
//func main(){
//    Init()
//    Getdbpersonmsg("")
//}
func Getdbpersonmsg(tableid string, teststring []byte, IsCompare bool) ([]byte) {
func Getdbpersonmsg(tableid, teststring string, IsCompare bool) ([]byte) {
    totalmap := make(map[string]float32)
    var buf []byte
    if !IsCompare {
        return nil
    }
    if teststring == "" {
        return nil
    if teststring == nil {
        return nil
    }
   for id, value := range Cmap.cam{
        if id == tableid{
            fmt.Println(id)
            buf =value.Walk(Printest, teststring)
    if tableid == "" {
        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("the id is: ", id)
                tmpmap :=value.Walk(Printest, teststring)
                for key, sec := range tmpmap {
                    totalmap[key]= sec
                }
                break
            }
       }
    }
    fmt.Println()
    fmt.Println()
    firsttime := time.Now()
    fmt.Println(time.Since(firsttime))
    return  buf
    buf, err := json.Marshal(totalmap)
    if err != nil {
        fmt.Println("map to json error!", err)
         return nil
    }
    return  buf
}
func Printest(ci, co string ) (float32){
    //ci_d, err := base64.StdEncoding.DecodeString(ci)
    //if err != nil {
    //    fmt.Println("ci_d : error : ", err)
    //    return -1
    //}
func Printest(ci []byte, co string ) (float32){
   co_d, err := base64.StdEncoding.DecodeString(co)
    if err != nil {
@@ -112,6 +119,6 @@
        return -1
    }
    sec := gosdk.FaceCompare([]byte(ci), co_d)
    sec := gosdk.FaceCompare(ci, co_d)
    return sec
}