SHARE
TWEET

Untitled

a guest Apr 24th, 2019 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. func mapF(filename string, contents string) []mapreduce.KeyValue {
  2.     tokens := strings.FieldsFunc(contents, func(r rune) bool {
  3.         return !unicode.IsLetter(r)
  4.     })
  5.     kvs := make([]mapreduce.KeyValue, 0)
  6.     for _, val := range tokens {
  7.         kvs = append(kvs, mapreduce.KeyValue{Key: val, Value: "1"})
  8.     }
  9.     return kvs
  10. }
  11.  
  12. func reduceF(key string, values []string) string {
  13.     var sum int64
  14.     for _, s := range values {
  15.         val, _ := strconv.ParseInt(s, 10, 64)
  16.         sum = sum + val
  17.     }
  18.     return fmt.Sprintf("%d", sum)
  19. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top