久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

Java 中的并行 XML 解析

Parallel XML Parsing in Java(Java 中的并行 XML 解析)
本文介紹了Java 中的并行 XML 解析的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我正在編寫一個應用程序,它處理大量具有深層節(jié)點結構的 xml 文件 (>1000).使用 woodstox (Event API) 大約需要 6 秒來解析一個包含 22.000 個節(jié)點的文件.

I'm writing an application which processes a lot of xml files (>1000) with deep node structures. It takes about six seconds with with woodstox (Event API) to parse a file with 22.000 Nodes.

算法被放置在與用戶交互的過程中,其中只有幾秒鐘的響應時間是可以接受的.所以我需要改進如何處理xml文件的策略.

The algorithm is placed in a process with user interaction where only a few seconds response time are acceptable. So I need to improve the strategy how to handle the xml files.

  1. 我的進程分析 xml 文件(僅提取幾個節(jié)點).
  2. 處理提取的節(jié)點并將新結果寫入新數據流(生成帶有修改節(jié)點的文檔副本).

現在我正在考慮一種多線程解決方案(在 16 Core+ 硬件上可以更好地擴展).我想到了以下策略:

Now I'm thinking about a multithreaded solution (which scales better on 16 Core+ hardware). I thought about the following stategies:

  1. 創(chuàng)建多個解析器并在 xml 源上并行運行它們.
  2. 重寫我的解析算法線程保存以僅使用解析器的一個實例(工廠,...)
  3. 將 XML 源拆分成塊并將這些塊分配給多個處理線程(map-reduce xml - 串行)
  4. 優(yōu)化我的算法(StAX 解析器比 woodstox 更好?)/使用內置并發(fā)的解析器

我想同時提高整體性能和每個文件"的性能.

您有解決此類問題的經驗嗎?最好的方法是什么?

Do you have experience with such problems? What is the best way to go?

推薦答案

  1. 這一點很明顯:只需創(chuàng)建幾個解析器并在多個線程中并行運行它們.

  1. This one is obvious: just create several parsers and run them in parallel in multiple threads.

看看 Woodstox 性能(暫時關閉,試試 google 緩存).

Take a look at Woodstox Performance (down at the moment, try google cache).

如果您的 XML 結構是可預測的,則可以做到這一點:如果它有很多相同的頂級元素.例如:

This can be done IF structure of your XML is predictable: if it has a lot of same top-level elements. For instance:

<element>
    <more>more elements</more>
</element> 
<element>
    <other>other elements</other>
</element>

在這種情況下,您可以創(chuàng)建簡單的拆分器來搜索 <element> 并將此部分提供給特定的解析器實例.這是一種簡化的方法:在現實生活中,我會使用 RandomAccessFile 來查找起點 (<element>),然后創(chuàng)建僅對文件的一部分進行操作的自定義 FileInputStream.

In this case you could create simple splitter that searches <element> and feeds this part to a particular parser instance. That's a simplified approach: in real life I'd go with RandomAccessFile to find start stop points (<element>) and then create custom FileInputStream that just operates on a part of file.

看看 Aalto.創(chuàng)造伍德斯托克斯的人.這是該領域的專家 - 不要重新發(fā)明輪子.

Take a look at Aalto. The same guys that created Woodstox. This are experts in this area - don't reinvent the wheel.

這篇關于Java 中的并行 XML 解析的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯(lián)網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯(lián)系我們刪除處理,感謝您的支持!

相關文檔推薦

Upload progress listener not fired (Google drive API)(上傳進度偵聽器未觸發(fā)(Google 驅動器 API))
Save file in specific folder with Google Drive SDK(使用 Google Drive SDK 將文件保存在特定文件夾中)
Google Drive Android API - Invalid DriveId and Null ResourceId(Google Drive Android API - 無效的 DriveId 和 Null ResourceId)
Google drive api services account view uploaded files to google drive using java(谷歌驅動api服務賬戶查看上傳文件到谷歌驅動使用java)
Google Drive service account returns 403 usageLimits(Google Drive 服務帳號返回 403 usageLimits)
com.google.api.client.json.jackson.JacksonFactory; missing in Google Drive example(com.google.api.client.json.jackson.JacksonFactory;Google Drive 示例中缺少)
主站蜘蛛池模板: 久久久一区二区三区四区 | 欧美综合一区二区三区 | 中文字幕第7页 | 特级黄一级播放 | 中文字幕日韩欧美一区二区三区 | 国产一区二区日韩 | www国产成人免费观看视频,深夜成人网 | 在线成人av | 91麻豆精品国产91久久久久久久久 | 亚洲 欧美 日韩在线 | 国产精品免费一区二区三区四区 | 亚洲高清久久 | 亚洲日日夜夜 | 青青草一区二区 | 国产一区欧美 | 免费在线视频a | 欧美精品一区二区三区四区五区 | 欧美综合国产精品久久丁香 | 九色在线视频 | 久久手机视频 | 日本涩涩视频 | 国产高清视频 | 婷婷免费在线 | 日本久久网 | 韩日一区 | 国产成人精品一区二区三区在线 | 蜜桃av鲁一鲁一鲁一鲁 | 亚洲一区毛片 | 日韩综合在线视频 | 国产精品欧美一区二区 | 国产精品成av人在线视午夜片 | 不卡视频一区二区三区 | 精品日韩一区 | 视频一区在线观看 | 黄色大片免费看 | 热久久性 | 亚洲综合国产 | 瑟瑟视频在线看 | 男女羞羞视频在线免费观看 | 国产免费福利 | 欧美午夜一区二区三区免费大片 |