From 9dd7bb8196b8c03c19bc3f1fbfe8a1f93341fdfe Mon Sep 17 00:00:00 2001
From: 554325746@qq.com <554325746@qq.com>
Date: 星期四, 11 七月 2019 10:06:30 +0800
Subject: [PATCH] fix cache

---
 shardmap/shardmap.go |   18 +++++-------------
 dbpersoninfo.go      |   31 ++++++++++++++++---------------
 2 files changed, 21 insertions(+), 28 deletions(-)

diff --git a/dbpersoninfo.go b/dbpersoninfo.go
index 844b568..39d3f0b 100644
--- a/dbpersoninfo.go
+++ b/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){
diff --git a/shardmap/shardmap.go b/shardmap/shardmap.go
index 848db6d..4868281 100644
--- a/shardmap/shardmap.go
+++ b/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

--
Gitblit v1.8.0