| | |
| | | |
| | | import ( |
| | | "sync" |
| | | "encoding/json" |
| | | "fmt" |
| | | //"encoding/json" |
| | | //"fmt" |
| | | ) |
| | | |
| | | var commonmux sync.Mutex |
| | |
| | | } |
| | | |
| | | // 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 { |
| | |
| | | } |
| | | |
| | | 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 |