0
我正在尝试编写源文件存储在GCS中的文本文件。代码运行良好,但不是一个XML文件,而是生成多个XML文件。 (XML文件的数量似乎遵循源文本文件中存在的记录总数)。我在使用'DataflowRunner'时观察了这种情况。通过Apache Beam写入XML时生成多个文件
当我在本地运行相同的代码,然后生成两个文件。第一个包含所有具有适当元素的记录,第二个仅包含打开和关闭根元素。
有关这种意外行为发生的任何想法?请在下面找到我使用的代码片段:
PCollection<String>input_records=p.apply(TextIO.read().from("gs://balajee_test/xml_source.txt"));
PCollection<XMLFormatter> input_object= input_records.apply(ParDo.of(new DoFn<String,XMLFormatter>(){
@ProcessElement
public void processElement(ProcessContext c)
{
String elements[]=c.element().toString().split(",");
c.output(new XMLFormatter(elements[0],elements[1],elements[2],elements[3],elements[4]));
System.out.println("Values to be written have been provided to constructor ");
}
})).setCoder(AvroCoder.of(XMLFormatter.class));
input_object.apply(XmlIO.<XMLFormatter>write()
.withRecordClass(XMLFormatter.class)
.withRootElement("library")
.to("gs://balajee_test/book_output"));
请让我知道在输出端一个XML文件(book_output.xml)的方式。
https://issues.apache.org/jira/browse/BEAM-2826 –
提交相同的JIRA请求。 –