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

Java 中的并行 XML 解析

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

問題描述

我正在編寫一個應(yīng)用程序,它處理大量具有深層節(jié)點結(jié)構(gòu)的 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.

算法被放置在與用戶交互的過程中,其中只有幾秒鐘的響應(yīng)時間是可以接受的.所以我需要改進(jìn)如何處理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. 我的進(jìn)程分析 xml 文件(僅提取幾個節(jié)點).
  2. 處理提取的節(jié)點并將新結(jié)果寫入新數(shù)據(jù)流(生成帶有修改節(jié)點的文檔副本).

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

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 更好?)/使用內(nèi)置并發(fā)的解析器

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

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

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 性能(暫時關(guān)閉,試試 google 緩存).

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

如果您的 XML 結(jié)構(gòu)是可預(yù)測的,則可以做到這一點:如果它有很多相同的頂級元素.例如:

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> 并將此部分提供給特定的解析器實例.這是一種簡化的方法:在現(xiàn)實生活中,我會使用 RandomAccessFile 來查找起點 (<element>),然后創(chuàng)建僅對文件的一部分進(jìn)行操作的自定義 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)造伍德斯托克斯的人.這是該領(lǐng)域的專家 - 不要重新發(fā)明輪子.

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

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

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

相關(guān)文檔推薦

Upload progress listener not fired (Google drive API)(上傳進(jìn)度偵聽器未觸發(fā)(Google 驅(qū)動器 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(谷歌驅(qū)動api服務(wù)賬戶查看上傳文件到谷歌驅(qū)動使用java)
Google Drive service account returns 403 usageLimits(Google Drive 服務(wù)帳號返回 403 usageLimits)
com.google.api.client.json.jackson.JacksonFactory; missing in Google Drive example(com.google.api.client.json.jackson.JacksonFactory;Google Drive 示例中缺少)
主站蜘蛛池模板: 久久久久久久网站 | 国产成人99久久亚洲综合精品 | 欧美在线日韩 | 久久最新网址 | 黄色午夜 | 999国产视频 | 在线观看福利影院 | 精品欧美黑人一区二区三区 | 少妇搡bbbb搡bbb搡澳门 | 久久久一区二区三区 | 91午夜精品亚洲一区二区三区 | 99精品久久久久久中文字幕 | 色婷婷av一区二区三区之e本道 | 能看毛片的网站 | 亚洲精品福利 | 182tv午夜| 国产成人综合网 | 手机av片 | 日韩视频免费 | 成人在线国产 | 精品欧美一区二区精品久久 | 久久久久久久国产精品 | 免费av网址在线观看 | 精品aaa | 九九热这里 | 国产日韩一区二区 | 黄色片国产 | 在线视频一区二区 | av日韩在线播放 | 日韩国产一区二区三区 | 欧美一级黄色录像 | 欧美视频亚洲视频 | 国产一区二区三区视频在线 | 免费看黄色小视频 | 午夜在线免费观看 | 欧美一区二区三区在线 | 久久av影院 | 激情视频网址 | 久久国产欧美 | 天天干天天曰 | 国产在线一区二区 |