15.10.4 Modifying and Submitting Tasks Under an Updated Environment

You can modify an Input/Output (IO) environment in the number of threads by using the setNumThreadsPerTask() method of the IoEnvironment. The value is updated immediately and all tasks that are submitted after updating it are executed with the updated value.

Modifying the Execution Environment Using JShell
opg4j> ioEnv.setNumThreadsPerTask(8)
opg4j> var g = session.readGraphWithProperties(...)
==> PgxGraph[name=graph,N=3,E=6,created=0]
Modifying the Execution Environment Using Java
import oracle.pgx.api.*;
import oracle.pgx.api.executionenvironment.*;

ioEnv.setNumThreadsPerTask(8);
PgxGraph g = session.readGraphWithProperties(...)

You can reset an environment to their initial values by calling the ioEnv.reset() method. Additionally, you can reset all environments at once by calling execEnv.reset() on the ExecutionEnvironment class.

You can modify CPU environments in their weight, priority and maximum number of threads using the setWeight(), setPriority() and setMaxThreads() methods:

Modifying the CPU Environment Using JShell
opg4j> analysisEnv.setWeight(50)
opg4j> fastAnalysisEnv.setMaxNumThreads(1)
opg4j> var rank = analyst.pagerank(g)
rank ==> VertexProperty[name=pagerank,type=double,graph=my-graph]
Modifying the CPU Environment Using Java
import oracle.pgx.api.*;
import oracle.pgx.api.executionenvironment.*;

analysisEnv.setWeight(50);
fastAnalysisEnv.setMaxThreads(1);
Analyst analyst = session.createAnalyst();
VertexProperty rank = analyst.pagerank(g);