2016-08-15 8 views
0

일부 RSS XML 피드를 구문 분석 중이므로 설명 입력란에 일부 URL을 확장해야합니다.그루비 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 블록이 GParsPool.withPool 블록에 의해 포위 될 필요가 collectParallel을 가질 수를 및 기타 GPars 방법을 사용할 수 있습니다.

import static groovyx.gpars.GParsPool.withPool 

// ... 

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