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

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

                Author: ASF GitHub Bot
            Created on: 03/Dec/19 15:49
            Start Date: 03/Dec/19 15:49
    Worklog Time Spent: 10m 
      Work Description: jkff commented on pull request #10256: [BEAM-8865] 
Updating Javadoc of FileIO example
URL: https://github.com/apache/beam/pull/10256#discussion_r353259489
 
 

 ##########
 File path: sdks/java/core/src/main/java/org/apache/beam/sdk/io/FileIO.java
 ##########
 @@ -135,9 +135,15 @@
  *     .apply(FileIO.readMatches().withCompression(GZIP))
  *     .apply(MapElements
  *         // uses imports from TypeDescriptors
- *         .into(KVs(strings(), strings()))
- *         .via((ReadableFile f) -> KV.of(
- *             f.getMetadata().resourceId().toString(), 
f.readFullyAsUTF8String())));
+ *         .into(kvs(strings(), strings()))
+ *         .via((ReadableFile f) -> {
+ *           try {
+ *             return KV.of(
+ *                 f.getMetadata().resourceId().toString(), 
f.readFullyAsUTF8String());
+ *           } catch (IOException ex) {
+ *             throw new RuntimeException("Failed to read the file", ex);
 
 Review comment:
   Ah, then maybe the example should add `Requirements.empty()` to force this 
overload? 
https://github.com/apache/beam/blob/master/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/Contextful.java#L122
 There's probably some frustrating Java reason why we can't just add an 
`fn(Fn)` overload - Java probably wouldn't be able to disambiguate between it 
and the other overloads when you supply a lambda.
 
----------------------------------------------------------------
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: 352719)
    Time Spent: 1h 10m  (was: 1h)

> FileIO's Javadoc is outdated: TypeDescriptors.KVs and unhandled IOException
> ---------------------------------------------------------------------------
>
>                 Key: BEAM-8865
>                 URL: https://issues.apache.org/jira/browse/BEAM-8865
>             Project: Beam
>          Issue Type: Bug
>          Components: sdk-java-core
>            Reporter: Tomo Suzuki
>            Assignee: Tomo Suzuki
>            Priority: Major
>         Attachments: v1YuuuT2o2i.png
>
>          Time Spent: 1h 10m
>  Remaining Estimate: 0h
>
> The doc says
>  !v1YuuuT2o2i.png! 
> However, I had to modify the code to below:
> {noformat}
>     p.apply("ReadLines",
>         FileIO.match().filepattern("hdfs:///foo/bar/*.gz"))
>         .apply(FileIO.readMatches().withCompression(GZIP))
>         .apply(MapElements
>             // uses imports from TypeDescriptors
>             .into(kvs(strings(), strings()))
>             .via((ReadableFile f) -> {
>               try {
>                 return KV.of(
>                     f.getMetadata().resourceId().toString(), 
> f.readFullyAsUTF8String());
>               } catch (IOException ex) {
>                 throw new RuntimeException("Failed to read the file", ex);
>               }
>              }))
> {noformat}



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

Reply via email to