简体   繁体   English

创建数百万条记录的XML

[英]XML creation for millions of records

I have to create a single large XML file which will have more than 60 milllion records. 我必须创建一个单个的大型XML文件,该文件将具有超过60亿条记录。 I need a fast way to do this operation as it will be repeated on regular basis. 我需要一种快速的方法来执行此操作,因为它会定期重复。

I have data at two places 我在两个地方都有数据

  1. In Database in two different tables. 在数据库中有两个不同的表。
  2. On File System In two pipe separated files. 在文件系统上在两个管道分隔的文件中。

At present, I am trying to use StaX parser to create XML file in JAVA. 目前,我正在尝试使用StaX解析器在JAVA中创建XML文件。

Here I need to know whether I should use database / text file to read data and create XML file. 在这里,我需要知道是否应该使用数据库/文本文件读取数据并创建XML文件。

Which one will be faster option ? 哪个会更快?
Also, is there any specific API which handles creation / conversion for such large data to XML in optimized way ? 此外,是否有任何特定的API以优化的方式处理从如此大的数据到XML的创建/转换?

I am open to File processing using linux commands as well provided it is a faster option. 我也愿意使用linux命令进行文件处理,只要它是一个更快的选择。

UPDATE On Comments 更新评论

  • How fast can you get XML element info from two separate files vs DB Query CSV dump? 与DB Query CSV dump相比,从两个单独的文件中获取XML元素信息的速度有多快? Whatever is available in database is available in PIPE Separated Files. PIPE分隔文件中提供了数据库中可用的任何内容。 And How FAST can we get / create XML element info is exactly the intent of the question here. 我们如何快速/快速地获取/创建XML元素信息正是这个问题的目的。 This is exactly what will impact overall speed of operation. 这正是将影响整体操作速度的原因。

  • Mapping Complication : Mapping is 1 to many. 映射复杂度:映射是一对多。 1 records in first file maps to approx than 8000 records in second text file / table. 第一个文件中的1条记录映射到第二个文本文件/表中的大约8000条记录。

UPDATE on Comment - > Use large output buffers. 注释上的更新->使用较大的输出缓冲区。

Understood. 明白了 Will read data from database / file in larger chunks and flush it in once I have processed a complete chunk. 处理完一个完整的块后,将从数据库/文件中读取更大的块中的数据并将其刷新。 But again should I do by Database read or File read ? 但是我还是应该通过数据库读取还是文件读取来做?

Update Can I export it using any tool from MySQL database , auto-converted to XML format ? 更新我可以使用任何工具从MySQL数据库中将其自动转换为XML格式导出吗?

You can use perl and XML::Simple / XML::Writer perl modules. 您可以使用perlXML :: Simple / XML :: Writer perl模块。 Perl is also capable of reading data from both database and text files. Perl还能够从数据库文件和文本文件中读取数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM