0

非常に大きなファイル (100GB 以上) を解凍し、2 つの並列スレッドで処理する必要があります。問題は、圧縮されていないコンテンツを 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 の出力を分割する必要があります。

4

1 に答える 1

1

tee を使用して、出力を複数のプロセスに分割できます

bzip2 north-america-latest.osm.bz2 | tee >(command1) | command2

必要な数のコマンドを使用できます。

bzip2 north-america-latest.osm.bz2 | tee >(command1) >(command2) >(command3) | command4

パイプの後のコマンドはオプションです。省略した場合は、引き続き stdout に移動します。

于 2019-08-22T01:54:23.887 に答える