[ 
https://issues.apache.org/jira/browse/BEAM-5524?focusedWorklogId=394345&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-394345
 ]

ASF GitHub Bot logged work on BEAM-5524:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 27/Feb/20 17:29
            Start Date: 27/Feb/20 17:29
    Worklog Time Spent: 10m 
      Work Description: lukecwik commented on issue #10987: [BEAM-5524] Fix 
minor issue in style guide.
URL: https://github.com/apache/beam/pull/10987#issuecomment-592081329
 
 
   R: @Ardagan 
 
----------------------------------------------------------------
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: 394345)
    Time Spent: 20m  (was: 10m)

> PTransform style guide error
> ----------------------------
>
>                 Key: BEAM-5524
>                 URL: https://issues.apache.org/jira/browse/BEAM-5524
>             Project: Beam
>          Issue Type: Bug
>          Components: website
>    Affects Versions: 2.6.0
>            Reporter: Simon Waddington
>            Priority: Minor
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> On the page  [https://beam.apache.org/contribute/ptransform-style-guide/] the 
> example for Transforms with multiple output collections has a method 
> {code:java}
> PCollectionTuple apply(... input) {
>     ...
>     PCollection<Moo> moo = ...;
>     PCollection<Blah> blah = ...;
>     return PCollectionTuple.of(mooTag, moo)
>                            .and(blahTag, blah);
>   }{code}
> I'm no expert - just trying to understand that use case - but it seems to me 
> it should be overriding the method {{expand}} of {{PTransform}} as in this 
> [ParDoTest.java|https://github.com/apache/beam/blob/279a05604b83a54e8e5a79e13d8761f94841f326/sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/ParDoTest.java#L301]
>  code which does a similar thing.
> {code:java}
> static class MultiFilter
>     extends PTransform<PCollection<Integer>, PCollectionTuple> {
>   private static final TupleTag<Integer> BY2 = new TupleTag<Integer>("by2"){};
>   private static final TupleTag<Integer> BY3 = new TupleTag<Integer>("by3"){};
>   @Override
>   public PCollectionTuple expand(PCollection<Integer> input) {
>     PCollection<Integer> by2 = input.apply("Filter2s", ParDo.of(new 
> FilterFn(2)));
>     PCollection<Integer> by3 = input.apply("Filter3s", ParDo.of(new 
> FilterFn(3)));
>     return PCollectionTuple.of(BY2, by2).and(BY3, by3);
>   }
>   static class FilterFn extends DoFn<Integer, Integer> {
>     private final int divisor;
>     FilterFn(int divisor) {
>       this.divisor = divisor;
>     }
>     @ProcessElement
>     public void processElement(@Element Integer element,
>                                OutputReceiver<Integer> r) throws Exception {
>       if (element % divisor == 0) {
>         r.output(element);
>       }
>     }
>   }
> }
> {code}
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to