[ 
https://issues.apache.org/jira/browse/BEAM-8865?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Tomo Suzuki updated BEAM-8865:
------------------------------
    Description: 
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}


  was:
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}



> 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
>
>
> 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