[
https://issues.apache.org/jira/browse/BEAM-5967?focusedWorklogId=326451&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-326451
]
ASF GitHub Bot logged work on BEAM-5967:
----------------------------------------
Author: ASF GitHub Bot
Created on: 10/Oct/19 16:58
Start Date: 10/Oct/19 16:58
Worklog Time Spent: 10m
Work Description: alexvanboxel commented on issue #8496: [BEAM-5967] Add
handling of DynamicMessage in ProtoCoder
URL: https://github.com/apache/beam/pull/8496#issuecomment-540678718
The ProtoDomain is tested though the Protoaware support, I aligned the
class with that PR, having this PR approved for this would make the schema
aware PR smalled, as I will rebase the PR.
_/
_/ Alex Van Boxel
On Thu, Oct 10, 2019 at 6:55 PM Kenn Knowles <[email protected]>
wrote:
> *@kennknowles* approved this pull request.
>
> Sorry for the delay. This seems quite nice and useful. I am not expert in
> proto descriptor wrangling. I would guess if there is a problem in that,
> @reuvenlax <https://github.com/reuvenlax> is more likely to catch it.
>
> Maybe follow up with more extensive testing exercising lots of cases of
> ProtoDomain?
> ------------------------------
>
> In
>
sdks/java/core/src/main/java/org/apache/beam/sdk/testing/CoderProperties.java
> <https://github.com/apache/beam/pull/8496#discussion_r333626680>:
>
> > @@ -104,6 +104,16 @@
> assertThat(decodeEncode(coder, context, value), equalTo(value));
> }
>
> + /**
> + * Verifies that for the given {@code Coder<T>}, {@code Coder.Context},
and value of type {@code
> + * T}, encoding followed by decoding yields an equal value of type
{@code T}.
>
> This one doesn't test that it is equal, but tests that the matcher
> succeeds.
> ------------------------------
>
> In
>
sdks/java/extensions/protobuf/src/main/java/org/apache/beam/sdk/extensions/protobuf/ProtoDomain.java
> <https://github.com/apache/beam/pull/8496#discussion_r333628729>:
>
> > + }
> +
> + private ProtoDomain(DescriptorProtos.FileDescriptorSet
fileDescriptorSet) {
> + this.fileDescriptorSet = fileDescriptorSet;
> + hashCode =
java.util.Arrays.hashCode(this.fileDescriptorSet.toByteArray());
> + crosswire();
> + }
> +
> + private static Map<String, DescriptorProtos.FileDescriptorProto>
extractProtoMap(
> + DescriptorProtos.FileDescriptorSet fileDescriptorSet) {
> + HashMap<String, DescriptorProtos.FileDescriptorProto> map = new
HashMap<>();
> + fileDescriptorSet.getFileList().forEach(fdp -> map.put(fdp.getName(),
fdp));
> + return map;
> + }
> +
> + private static Descriptors.FileDescriptor convertToFileDescriptorMap(
>
> @Nullable. I'm a bit sad our analyses didn't catch this.
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
>
<https://github.com/apache/beam/pull/8496?email_source=notifications&email_token=AAE4EM6SXFD4LZQQJJBWNBLQN5M6XA5CNFSM4HKZOJI2YY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCHSNI2Q#pullrequestreview-300209258>,
> or unsubscribe
>
<https://github.com/notifications/unsubscribe-auth/AAE4EM2TBV4JI73PGIM7QHLQN5M6XANCNFSM4HKZOJIQ>
> .
>
----------------------------------------------------------------
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]
Issue Time Tracking
-------------------
Worklog Id: (was: 326451)
Time Spent: 4.5h (was: 4h 20m)
> ProtoCoder doesn't support DynamicMessage
> -----------------------------------------
>
> Key: BEAM-5967
> URL: https://issues.apache.org/jira/browse/BEAM-5967
> Project: Beam
> Issue Type: Improvement
> Components: sdk-java-core
> Affects Versions: 2.8.0
> Reporter: Alex Van Boxel
> Assignee: Alex Van Boxel
> Priority: Major
> Fix For: 2.17.0
>
> Time Spent: 4.5h
> Remaining Estimate: 0h
>
> The ProtoCoder does make some assumptions about static messages being
> available. The DynamicMessage doesn't have some of them, mainly because the
> proto schema is defined at runtime and not at compile time.
> Does it make sense to make a special coder for DynamicMessage or build it
> into the normal ProtoCoder.
> Here is an example of the assumtion being made in the current Codec:
> {code:java}
> try {
> @SuppressWarnings("unchecked")
> T protoMessageInstance = (T)
> protoMessageClass.getMethod("getDefaultInstance").invoke(null);
> @SuppressWarnings("unchecked")
> Parser<T> tParser = (Parser<T>) protoMessageInstance.getParserForType();
> memoizedParser = tParser;
> } catch (IllegalAccessException | InvocationTargetException |
> NoSuchMethodException e) {
> throw new IllegalArgumentException(e);
> }
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)