0
votes

I am parsing some rss xml feed and need to expand some urls in the description field.

Now my code is written as

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

In this case, the urls inside are requested one by one, making its process very slow.

So I want to do something like

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

But instead I get the error message:

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

1

1 Answers

1
votes

The items.collectParallel block needs to be surrounded by a GParsPool.withPool block to have the collectParallel and other GPars methods be available, like:

import static groovyx.gpars.GParsPool.withPool

// ...

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