【发布时间】:2019-08-22 01:15:08
【问题描述】:
我需要解压缩一个非常大的文件 (100GB+) 并让它由两个并行线程处理。问题是我想使用 STDIN/STDOUT 同时向两个线程提供未压缩的内容
bzip2 north-america-latest.osm.bz2 | \
osmosis --read-xml file=- \ # get first thread
--tf accept-ways highway=motorway
outPipe.0=motorway \
--fast-read-xml file=- # here another thread
--tf accept-nodes place=\*
outPipe.0=places \
--merge inPipe.0=motorway inPipe.1=places
语法可能不那么透明,但想法是两个线程都从相同的标准输入中读取并基本上互相窃取数据。
不知何故,我需要让每个线程都有自己的 STDIN(或另一个临时内存流),并在它们之间拆分 bzip2 的输出。
【问题讨论】:
-
如果您担心速度,请尝试查看osmium-tool。
-
最终的解决方案是放弃 osmosis 工具,因为它是用 Java 编写的(因此很慢),并改用 osmconvert/osmfilter 工具的组合。这两个工具都是用 c++ 编写的,性能比 osmosis 好 10 倍左右。特别是 osmconvert 可以进行边界框过滤,而 osmfilter 可以帮助从 osm 数据流中挑选元素。 Osm 过滤器不容易配置,文档可以用更多示例编写,但是一旦配置正确,它就可以很好地工作。
标签: linux openstreetmap stdin osmosis