From 6a413e1d7d485f506e81c669bc692868c29cefb9 Mon Sep 17 00:00:00 2001
From: sunty <1172534965@qq.com>
Date: 星期四, 18 七月 2019 17:37:25 +0800
Subject: [PATCH] fix sdkcompare

---
 shardmap/shardmap.go |   21 +++++++--------------
 1 files changed, 7 insertions(+), 14 deletions(-)

diff --git a/shardmap/shardmap.go b/shardmap/shardmap.go
index 9f1dc6c..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
@@ -26,7 +26,7 @@
 
 var Count = make(chan int)
 
-type wfOp func(a, b string) float32 
+type wfOp func(a []byte, b string) float32 
 
 /**
 * @param uint8, shardCnt must be pow of two
@@ -78,11 +78,9 @@
 }
 
 // modify by long.
-func (s *ShardMap) Walk(wf wfOp, cfrom string) ([]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 {
@@ -92,7 +90,7 @@
 
         wg.Add(1)
         
-		go func(st *shardItem, fw wfOp, cf string) {
+		go func(st *shardItem, fw wfOp, cf []byte) {
             defer wg.Done()
             commonmux.Lock()
 			for id, feature := range st.data {
@@ -110,13 +108,8 @@
 
     wg.Wait()
 
-    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