Clojure 中的巨大 XML [英] Huge XML in Clojure
本文介绍了Clojure 中的巨大 XML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是 Clojure 的新手,我的第一个项目必须处理巨大的 (250+GB) XML 文件.我想把它放到 PostgreSQL 中以便稍后处理它,但不知道如何处理这么大的文件.
I'm new to Clojure and my first project has to deal with huge (250+GB) XML file. I want to put it into PostgreSQL to process it later on, but have no idea how to approach such a big file.
推荐答案
我使用新的 clojure.data.xml
在一台普通的笔记本电脑上处理 31GB 维基百科转储.旧的 lazy-xml
contrib 库对我不起作用(内存不足).
I used the new clojure.data.xml
to process a 31GB Wikipedia dump on a modest laptop. The old lazy-xml
contrib library did not work for me (ran out of memory).
https://github.com/clojure/data.xml
简化示例代码:
(require '[clojure.data.xml :as data.xml]) ;'
(defn process-page [page]
;; ...
)
(defn page-seq [rdr]
(->> (:content (data.xml/parse rdr))
(filter #(= :page (:tag %)))
(map process-page)))
这篇关于Clojure 中的巨大 XML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文