apache / apache/beam

Developing "GroupByMultiKey"

Open
#19,467 0 comments 0 reactions 0 assignees View on GitHub
beam-model new feature P3 sdk-ideas
Dominant language
Java
Stars
8.7k
Forks
4.7k
Avg merge
1d 20h
Merged PRs (30d)
196

Description

GroupByKey is useful, but it is difficult to express complex grouping conditions.

I propose the development of the function to group if there is a common term in even one of multiple keys.

Like this....

 

usage

 
```

List io = Arrays.asList(
KV.of(new MultiKey("A","C", "E"),"0"),
KV.of(new MultiKey("A","D", "F"),"1"),

KV.of(new MultiKey("B","D", "G"),"2"),
KV.of(new MultiKey("H","J", "L"),"3"),
KV.of(new MultiKey("I","K",
"L"),"4"),
KV.of(new MultiKey("M","C", "O"),"5"),
KV.of(new MultiKey(null,null, "O"),"6"),
KV.of(new
MultiKey(null,null, null),"7")
);
p.apply(Create.of(io))
.apply(GroupByMultiKey.create(3))
.apply(new
DebugPrintln());

```

 

 out put this
>  
> [KV\{["A","C","E"],"0"},KV\{["A","D","F"],"1"},KV\{["B","D","G"],"2"},KV\{["M","C","O"],"5"},KV\{[null,null,"O"],"6"}]

[KV\{["H","J","L"],"3"},KV\{["I","K","L"],"4"}]

[KV\{[null,null,null],"7"}]

 
>

Imported from Jira [BEAM-7358](https://issues.apache.org/jira/browse/BEAM-7358). Original Jira may contain additional context.
Reported by: naoki.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.