【问题标题】:process XML files with Spotify Scio (scala wrapper for apache beam)使用 Spotify Scio(Apache Beam 的 Scala 包装器)处理 XML 文件
【发布时间】:2017-09-28 03:58:23
【问题描述】:

Apache beam java sdk 支持读取大型 xml 输入文件,带有 org.apache.beam.sdk.io.xml.XmlIO(我看的是 2.1.0 版本)

有谁知道 Scio 是否允许您这样做或举个例子?我有一组非常大的 xml 文件要处理。

【问题讨论】:

    标签: xml apache-beam spotify-scio


    【解决方案1】:

    您可以通过 Scio 使用自定义输入转换来执行此操作。通常,您需要对没有原生 Scio 界面的任何输入源执行此操作。

    例子:

    import org.apache.beam.sdk.io.xml._
    
    
    val xmlInputTransform = XmlIO.read()
      .from("file or pattern spec")         // TODO: specify file name or Java "glob" file pattern to read multiple XML files
      .withRootElement("root element")      // TODO: specify name of root element
      .withRecordElement("record element")  // TODO: specify name of record element
      .withRecordClass(classOf[Record])     // TODO: Define JAXB annotated Record class
    
    // xmls is an SCollection[Record]
    val xmls = sc.customInput("fromXML", xmlInputTransform)
    

    有关详细信息,请参阅 Apache Beam Java SDK 参考中的 XmlIO.Read 部分:https://beam.apache.org/documentation/sdks/javadoc/2.2.0/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-10-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多