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

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

                Author: ASF GitHub Bot
            Created on: 10/Dec/19 21:18
            Start Date: 10/Dec/19 21:18
    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_r356282252
 
 

 ##########
 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:
   Sorry I missed this. Hmm, this is getting ugly enough that I think the 
original code you proposed is better - it's, at least, idiomatic in Java. Would 
be nice (not in this PR) to make it easier to do MapElements.via() with 
throwing functions without the hassle of fn(lambda, Requirements.empty()).
   
   So for now I suggest to revert to the original version you proposed.
 
----------------------------------------------------------------
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:
us...@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 357415)
    Time Spent: 1.5h  (was: 1h 20m)

> 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: 1.5h
>  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