Commit 3ea385d
committed
fix: consolidate duplicate ShardedKey implementations in core module
Remove the deprecated org.apache.beam.sdk.values.ShardedKey and the
internal (@VisibleForTesting) org.apache.beam.sdk.coders.ShardedKeyCoder,
consolidating into the single org.apache.beam.sdk.util.ShardedKey.
- Add of(K, int) factory and getShardNumber() accessor to util.ShardedKey
so callers using integer shard numbers migrate without logic changes.
The int is stored as a 4-byte big-endian byte array and round-trips
through the Coder.
- toString() displays integer shard number for 4-byte shard IDs instead
of raw byte array, preserving log readability.
- Migrate all consumers across core SDK, BigQuery IO, WriteFiles,
ShardingFunction, Flink runner, and Spark runner.
- Simplify auto-sharded write paths in WriteFiles and BatchLoads that
previously required awkward conversion between the two ShardedKey types.
- Add tests for int-based shard methods and coder round-trip behavior.
- Update CHANGES.md with Breaking Changes entry.
Wire format note: the removed ShardedKeyCoder (sdk.coders) had a
different wire format from ShardedKey.Coder (sdk.util) — reversed field
order and VarInt vs ByteArray shard encoding. ShardedKeyCoder was NOT a
Beam standard/model coder and was only used transiently within pipeline
constructions (GroupByKey, sharding), never for persistent state or
checkpoints. The standard model coder (ShardedKey.Coder) is unchanged.1 parent 5a65f6e commit 3ea385d
20 files changed
Lines changed: 108 additions & 186 deletions
File tree
- playground/frontend/playground_components/assets/symbols
- runners
- flink/src
- main/java/org/apache/beam/runners/flink
- test/java/org/apache/beam/runners/flink
- spark/3/src/main/java/org/apache/beam/runners/spark/structuredstreaming/translation
- sdks/java
- core/src
- main/java/org/apache/beam/sdk
- coders
- io
- util
- values
- test/java/org/apache/beam/sdk
- io
- util
- io/google-cloud-platform/src
- main/java/org/apache/beam/sdk/io/gcp/bigquery
- test/java/org/apache/beam/sdk/io/gcp/bigquery
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
| 83 | + | |
83 | 84 | | |
84 | 85 | | |
85 | 86 | | |
| |||
Lines changed: 0 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10741 | 10741 | | |
10742 | 10742 | | |
10743 | 10743 | | |
10744 | | - | |
10745 | | - | |
10746 | | - | |
10747 | | - | |
10748 | | - | |
10749 | | - | |
10750 | | - | |
10751 | 10744 | | |
10752 | 10745 | | |
10753 | 10746 | | |
| |||
Lines changed: 2 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
34 | 33 | | |
35 | 34 | | |
36 | 35 | | |
| |||
49 | 48 | | |
50 | 49 | | |
51 | 50 | | |
| 51 | + | |
52 | 52 | | |
53 | 53 | | |
54 | | - | |
55 | 54 | | |
56 | 55 | | |
57 | 56 | | |
| |||
320 | 319 | | |
321 | 320 | | |
322 | 321 | | |
323 | | - | |
| 322 | + | |
324 | 323 | | |
325 | 324 | | |
326 | 325 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
46 | 47 | | |
47 | 48 | | |
48 | | - | |
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
60 | | - | |
61 | 60 | | |
62 | 61 | | |
63 | 62 | | |
| |||
74 | 73 | | |
75 | 74 | | |
76 | 75 | | |
| 76 | + | |
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
| |||
255 | 255 | | |
256 | 256 | | |
257 | 257 | | |
258 | | - | |
| 258 | + | |
259 | 259 | | |
260 | 260 | | |
261 | 261 | | |
| |||
Lines changed: 0 additions & 63 deletions
This file was deleted.
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| |||
Lines changed: 8 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
41 | 40 | | |
42 | 41 | | |
43 | 42 | | |
| |||
76 | 75 | | |
77 | 76 | | |
78 | 77 | | |
| 78 | + | |
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
| |||
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
88 | | - | |
89 | 88 | | |
90 | 89 | | |
91 | 90 | | |
| |||
627 | 626 | | |
628 | 627 | | |
629 | 628 | | |
630 | | - | |
| 629 | + | |
631 | 630 | | |
632 | 631 | | |
633 | 632 | | |
| |||
928 | 927 | | |
929 | 928 | | |
930 | 929 | | |
931 | | - | |
| 930 | + | |
932 | 931 | | |
933 | 932 | | |
934 | 933 | | |
| |||
984 | 983 | | |
985 | 984 | | |
986 | 985 | | |
987 | | - | |
| 986 | + | |
988 | 987 | | |
989 | 988 | | |
990 | 989 | | |
| |||
996 | 995 | | |
997 | 996 | | |
998 | 997 | | |
999 | | - | |
1000 | | - | |
| 998 | + | |
1001 | 999 | | |
1002 | 1000 | | |
1003 | 1001 | | |
| |||
1007 | 1005 | | |
1008 | 1006 | | |
1009 | 1007 | | |
1010 | | - | |
| 1008 | + | |
1011 | 1009 | | |
1012 | 1010 | | |
1013 | 1011 | | |
1014 | | - | |
1015 | | - | |
| 1012 | + | |
1016 | 1013 | | |
1017 | 1014 | | |
1018 | 1015 | | |
| |||
1022 | 1019 | | |
1023 | 1020 | | |
1024 | 1021 | | |
1025 | | - | |
| 1022 | + | |
1026 | 1023 | | |
1027 | 1024 | | |
1028 | 1025 | | |
| |||
Lines changed: 40 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
| 26 | + | |
25 | 27 | | |
26 | 28 | | |
27 | 29 | | |
28 | 30 | | |
29 | 31 | | |
30 | 32 | | |
31 | 33 | | |
32 | | - | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
33 | 40 | | |
34 | 41 | | |
35 | 42 | | |
36 | | - | |
| 43 | + | |
| 44 | + | |
37 | 45 | | |
38 | 46 | | |
39 | 47 | | |
| |||
53 | 61 | | |
54 | 62 | | |
55 | 63 | | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
56 | 74 | | |
57 | 75 | | |
58 | 76 | | |
59 | 77 | | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
60 | 95 | | |
61 | 96 | | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
62 | 100 | | |
63 | 101 | | |
64 | 102 | | |
| |||
Lines changed: 0 additions & 71 deletions
This file was deleted.
0 commit comments