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屋!
查看全文