0

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

Hao Tan
  • 1,530
  • 2
  • 13
  • 20

1 Answers1

1

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
    }
}
Gergely Toth
  • 6,638
  • 2
  • 38
  • 40