Skip to content

Commit 3262018

Browse files
authored
move Java snippet to Java, remove redundant line (apache#33242)
1 parent de7f1bd commit 3262018

File tree

1 file changed

+12
-17
lines changed
  • learning/tour-of-beam/learning-content/core-transforms/map/group-by-key

1 file changed

+12
-17
lines changed

learning/tour-of-beam/learning-content/core-transforms/map/group-by-key/description.md

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,7 @@ input := beam.ParDo(s, func(_ []byte, emit func(string, int)){
102102
emit("Banana", 5)
103103
emit("Lemon", 2)
104104
}, beam.Impulse(s))
105-
```
106105
107-
If the keys are duplicated, groupByKey collects data and the values will be stored in an array:
108-
```
109106
func applyTransform(s beam.Scope, input beam.PCollection) beam.PCollection {
110107
kv := beam.ParDo(s, func(word string,count int) (string, int) {
111108
return strings.ToLower(word),count
@@ -126,18 +123,6 @@ PCollection<KV<String, Integer>> input = pipeline
126123
KV.of("Banana", 5),
127124
KV.of("Lemon", 2)
128125
));
129-
```
130-
{{end}}
131-
{{if (eq .Sdk "python")}}
132-
```
133-
input = p | 'Fruits' >> Create([
134-
("banana", 2),
135-
("apple", 4),
136-
("lemon", 3),
137-
("Apple", 1),
138-
("Banana", 5),
139-
("Lemon", 2)
140-
])
141126
142127
input
143128
.apply("Lowercase", ParDo.of(new DoFn<KV<String, Integer>, KV<String, Integer>>() {
@@ -149,12 +134,22 @@ input
149134
}))
150135
.apply("GroupByKey", GroupByKey.create());
151136
```
137+
{{end}}
152138

153-
If the keys are duplicated, groupByKey collects data and the values will be stored in an array:
139+
{{if (eq .Sdk "python")}}
154140
```
141+
input = p | 'Fruits' >> Create([
142+
("banana", 2),
143+
("apple", 4),
144+
("lemon", 3),
145+
("Apple", 1),
146+
("Banana", 5),
147+
("Lemon", 2)
148+
])
149+
155150
class ApplyTransform(PTransform):
156151
def expand(self, input):
157152
return (input | 'Lowercase' >> util.Map(lambda word, count: (word.lower(), count))
158153
| 'GroupByKey' >> util.GroupByKey())
159154
```
160-
{{end}}
155+
{{end}}

0 commit comments

Comments
 (0)