Skip to content

Commit

Permalink
Implement CoderNullable pullDecoderNoAlloc case (#31340)
Browse files Browse the repository at this point in the history
  • Loading branch information
damondouglas authored May 20, 2024
1 parent 2e4a152 commit fed6489
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions sdks/go/pkg/beam/runners/prism/internal/coders.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,20 @@ func pullDecoderNoAlloc(c *pipepb.Coder, coders map[string]*pipepb.Coder) func(i
l, _ := coder.DecodeVarInt(r)
ioutilx.ReadN(r, int(l))
}
case urns.CoderNullable:
return func(r io.Reader) {
b, _ := ioutilx.ReadN(r, 1)
if len(b) == 0 {
return
}
// Nullable coder is prefixed with 0 or 1 to indicate whether there exists remaining data.
prefix := b[0]
if prefix == 0 {
return
}
l, _ := coder.DecodeVarInt(r)
ioutilx.ReadN(r, int(l))
}
case urns.CoderVarInt:
return func(r io.Reader) {
coder.DecodeVarInt(r)
Expand Down

0 comments on commit fed6489

Please sign in to comment.