beam-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniel Halperin (JIRA)" <>
Subject [jira] [Commented] (BEAM-469) NullableCoder optimized encoding via passthrough context
Date Wed, 21 Dec 2016 23:30:58 GMT


Daniel Halperin commented on BEAM-469:

Sorry I missed this JIRA comment, [~mariusz89016]! A bit late, but...

Say a coder C does not have the nested context. Then we actually have the guarantee that no
one will put later elements.

So if {{NullableCoder}} does not have the nested context, then no one will put more elements
after whatever the {{NullableCoder}} puts. If the NC puts {{0}} then that's it -- the element
is null. But if the NC puts {{1}}, then we know that all remaining bytes in the encoded string
belong to the inner coder. That is effectively saying that the inner coder also does not need
to have the nested context, so it does not need to write its own length.

In your example, the {{NullableCoder}} is used in an inner context. So the inner coder needs
to also use the inner context, because there may be more encoded elements later.

In either case: the context of the nullable coder can be the same as the context of the inner
coder. This is why in the patch here, we simply pass the NC's context down into the inner
coder. All we have removed is the _additional_ nesting that was used. 

> NullableCoder optimized encoding via passthrough context
> --------------------------------------------------------
>                 Key: BEAM-469
>                 URL:
>             Project: Beam
>          Issue Type: Improvement
>          Components: sdk-java-core
>            Reporter: Luke Cwik
>            Assignee: Thomas Groh
>            Priority: Trivial
>              Labels: backward-incompatible
>             Fix For: 0.3.0-incubating
> NullableCoder should encode using the context given and not always use the nested context.
For coders which can efficiently encode in the outer context such as StringUtf8Coder or ByteArrayCoder,
we are forcing them to prefix themselves with their length.

This message was sent by Atlassian JIRA

View raw message