lostluck commented on a change in pull request #12426:
URL: https://github.com/apache/beam/pull/12426#discussion_r465223398
##########
File path: model/pipeline/src/main/proto/beam_runner_api.proto
##########
@@ -855,10 +855,21 @@ message StandardCoders {
// BOOLEAN: beam:coder:bool:v1
// BYTES: beam:coder:bytes:v1
// ArrayType: beam:coder:iterable:v1 (always has a known length)
- // MapType: not yet a standard coder (BEAM-7996)
+ // MapType: not a standard coder, specification defined below.
// RowType: beam:coder:row:v1
// LogicalType: Uses the coder for its representation.
//
+ // The MapType is encoded by:
+ // - An INT32 representing the size of the map (N)
+ // - Followed by N interleaved keys and values, encoded with their
+ // corresponding coder.
+ //
+ // Nullable types in container types (ArrayType, MapType) are encoded by:
+ // - A one byte null indicator, 0x00 for null values, or 0x01 for present
+ // values.
+ // - For present values the null indicator is followed by the value
+ // encoded with it's corresponding coder.
+ //
Review comment:
@robertwb Your comment fed my own misunderstanding. It is possible to
declare a map as not having null/keys values.
Technically, there's no reason that the SDK can't use a non-nullable
containing version of the container if the Key and Value components are not
themselves marked as nillable. IIRC, the Java SDK *could* converted
ImmutableMaps or similar into just non-nullable Key and non-nullable Value
types.
The issue as I'm understanding it is that the limitation is on the SDK
Language side, rather than the schema specification side, as discussed the
schemas fields can individually have their nullable bits set.
Eg. Go doesn't have this ambiguity for map types.
On the other hand, in Go, Iterable/array types which will be represented by
slices *will* have this ambiguity when used as a field, as they can be nil, and
could also still be pointers to said reference types. That ambiguity is well
known enough that pointers to reference types (maps, slices, chans..) are
strongly discouraged in idiomatic Go.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]