Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func mapF(filename string, contents string) []mapreduce.KeyValue {
- tokens := strings.FieldsFunc(contents, func(r rune) bool {
- return !unicode.IsLetter(r)
- })
- kvs := make([]mapreduce.KeyValue, 0)
- for _, val := range tokens {
- kvs = append(kvs, mapreduce.KeyValue{Key: val, Value: "1"})
- }
- return kvs
- }
- func reduceF(key string, values []string) string {
- var sum int64
- for _, s := range values {
- val, _ := strconv.ParseInt(s, 10, 64)
- sum = sum + val
- }
- return fmt.Sprintf("%d", sum)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement