Github user BryanCutler commented on the issue:
https://github.com/apache/spark/pull/18281
@ajaysaini725 , I was just about to update my PR with an updated trait that
makes some small improvements when I saw you're update. I'll post what I have
in case if you would like to use it here
```scala
private[ml] trait HasParallelism extends Params {
/**
* param to control the level of parallelism
* Default: 1
*
* @group expertParam
*/
val parallelism: IntParam = new IntParam(this, "parallelism",
"set the level of parallelism to be used", ParamValidators.gtEq(1))
/** @group getParam */
@Since("2.3.0")
def getParallelism: Int = $(parallelism)
/** @group setParam */
@Since("2.3.0")
def setNumParallelEval(value: Int): this.type = set(parallelism, value)
/**
* Create an ExecutionContext that is determined from the param
[parallelism]. If this param
* is set to 1, a same-thread executor will be used to run in serial
otherwise a thread-pool
* with max threads set to the param value.
*/
@Since("2.3.0")
def getExecutionContext(maxThreads: Int): ExecutionContext = {
maxThreads match {
case 1 =>
ThreadUtils.sameThread
case n =>
ExecutionContext.fromExecutorService(
ThreadUtils.newDaemonCachedThreadPool(s"${this.getClass.getSimpleName}-thread-pool",
n))
}
}
setDefault(parallelism -> 1)
}
```
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]