ディスクシェルフ上に作成したい辞書を100メガバイトという大きなサイズにします。私はMPIを使用してマスターリストのクリーンビットを生成するためにpyparを使用しています。これを達成する最良の方法は何ですか?例:ここでは既存の辞書を使用してシェルフを作成する方法
# much earlier
masterDict = shelve.open('aShelveFile')
# .. . . . .
# then we work out which parts of masterDict to keep
# and we put into aCleanDict
# then use mpi pypar to send the cleaned bits to the master rank
if pypar.rank() == 0:
tempdict = {}
for p in range(1,pypar.size()):
tempdict.append(pypar.receive(p))
for l1 in tempdict:
for l2 in l1:
realDict.append(l2)
for p in range(1,pypar.size()):
pypar.send(realDict,p)
# now realDict has all the cleaned bits
# which we send to the other hosts
else:
pypar.send(aCleanDict, 0)
aCleanDict = pypar.receive(0)
# now to replace masterDict with aCleanDict
# note: cannot send shelve dictonaries using pypar
# insert stackover flow code here.
それを棚上げするだけで問題はありますか? – juanchopanza
既存の辞書をどのように棚上げしますか? – Martlark
私は簡単な例を加えました。これがあなたが必要としているものかどうかはわかりません。そうでない場合は、少し質問を明確にしたいかもしれません。 – juanchopanza