This is an automated email from the ASF dual-hosted git repository.
xqhu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/beam.git
The following commit(s) were added to refs/heads/master by this push:
new 32620186a00 move Java snippet to Java, remove redundant line (#33242)
32620186a00 is described below
commit 32620186a0029106b1396560257d68663891021d
Author: Gabija Balvociute <[email protected]>
AuthorDate: Mon Apr 21 07:35:17 2025 -0700
move Java snippet to Java, remove redundant line (#33242)
---
.../map/group-by-key/description.md | 29 +++++++++-------------
1 file changed, 12 insertions(+), 17 deletions(-)
diff --git
a/learning/tour-of-beam/learning-content/core-transforms/map/group-by-key/description.md
b/learning/tour-of-beam/learning-content/core-transforms/map/group-by-key/description.md
index d8c396bf3a7..4a1afc28b31 100644
---
a/learning/tour-of-beam/learning-content/core-transforms/map/group-by-key/description.md
+++
b/learning/tour-of-beam/learning-content/core-transforms/map/group-by-key/description.md
@@ -102,10 +102,7 @@ input := beam.ParDo(s, func(_ []byte, emit func(string,
int)){
emit("Banana", 5)
emit("Lemon", 2)
}, beam.Impulse(s))
-```
-If the keys are duplicated, groupByKey collects data and the values will be
stored in an array:
-```
func applyTransform(s beam.Scope, input beam.PCollection) beam.PCollection {
kv := beam.ParDo(s, func(word string,count int) (string, int) {
return strings.ToLower(word),count
@@ -126,18 +123,6 @@ PCollection<KV<String, Integer>> input = pipeline
KV.of("Banana", 5),
KV.of("Lemon", 2)
));
-```
-{{end}}
-{{if (eq .Sdk "python")}}
-```
-input = p | 'Fruits' >> Create([
- ("banana", 2),
- ("apple", 4),
- ("lemon", 3),
- ("Apple", 1),
- ("Banana", 5),
- ("Lemon", 2)
-])
input
.apply("Lowercase", ParDo.of(new DoFn<KV<String, Integer>, KV<String,
Integer>>() {
@@ -149,12 +134,22 @@ input
}))
.apply("GroupByKey", GroupByKey.create());
```
+{{end}}
-If the keys are duplicated, groupByKey collects data and the values will be
stored in an array:
+{{if (eq .Sdk "python")}}
```
+input = p | 'Fruits' >> Create([
+ ("banana", 2),
+ ("apple", 4),
+ ("lemon", 3),
+ ("Apple", 1),
+ ("Banana", 5),
+ ("Lemon", 2)
+])
+
class ApplyTransform(PTransform):
def expand(self, input):
return (input | 'Lowercase' >> util.Map(lambda word, count:
(word.lower(), count))
| 'GroupByKey' >> util.GroupByKey())
```
-{{end}}
\ No newline at end of file
+{{end}}