2016-08-15 4 views
0

いくつかのrss xmlフィードを解析しており、説明フィールドにいくつかのURLを展開する必要があります。並行動作のGroovy XmlSlurper

今私のコードはこの場合

items.collect { 
    it.description = FullText.expand(it.description) 
    return it 
} 

として書かれ、内部のURLは、そのプロセスが非常に遅くなって、一つ一つを要求しています。

だから私は

items.collectParallel { 
    it.description = FullText.expand(it.description) 
    return it 
} 

のような何かをしたいしかし、その代わりに、私は、エラーメッセージが出ます:

groovy.lang.MissingMethodException: No signature of method: groovy.util.slurpersupport.NodeChildren.collectParallel() is applicable for argument types

答えて

1

items.collectParallelブロックがcollectParallelを持っているGParsPool.withPoolブロックに囲まれる必要があります他のGParsメソッドも利用できます。

import static groovyx.gpars.GParsPool.withPool 

// ... 

withPool { 
    items.collectParallel { 
     it.description = FullText.expand(it.description) 
     return it 
    } 
} 
関連する問題