Implementation:Ray project Ray ParallelActorCallGenerator
| Knowledge Sources | |
|---|---|
| Domains | Distributed_Computing, Java_Runtime |
| Last Updated | 2026-02-13 16:00 GMT |
Overview
Build-time code generator that produces the type-safe Call.java and ActorCall.java source files for parallel actor task submission in Ray's Java API.
Description
ParallelActorCallGenerator extends BaseGenerator to produce method overloads for parallel actor invocation with 0 to MAX_PARAMETERS parameters. It generates two files: Call.java containing static actor() methods for parallel actor creation, and ActorCall.java containing default task() methods for invoking actor methods with and without return values. Each generated method wraps the parallel actor task submission API with appropriate generic type parameters.
Usage
Use ParallelActorCallGenerator as a build-time tool to regenerate the parallel actor call API source files. Run it with a main method to write the generated Java files to the appropriate source directory. This is needed when the maximum parameter count changes or when the API template is modified.
Code Reference
Source Location
- Repository: Ray
- File:
java/runtime/src/main/java/io/ray/runtime/util/generator/ParallelActorCallGenerator.java
Signature
public class ParallelActorCallGenerator extends BaseGenerator {
private String generateRayCallDotJava() { ... }
private String generateActorCallDotJava() { ... }
private void buildCalls(
int numParameters,
boolean forActor,
boolean forActorCreation,
boolean hasReturn) { ... }
public static void main(String[] args) throws IOException { ... }
}
Import
import io.ray.runtime.util.generator.ParallelActorCallGenerator;
I/O Contract
Input
| Parameter | Type | Description |
|---|---|---|
numParameters |
int |
Number of function parameters to generate overloads for (0 to MAX_PARAMETERS) |
forActor |
boolean |
Whether to generate actor.call style methods (true) or static Ray.call methods (false) |
forActorCreation |
boolean |
Whether to generate actor creation methods (true) or task invocation methods (false) |
hasReturn |
boolean |
Whether to generate methods for functions with a return value |
Output
| Output | Type | Description |
|---|---|---|
Call.java |
Generated source file | Contains static methods for parallel actor creation with type-safe generics |
ActorCall.java |
Generated source file | Contains default interface methods for parallel actor task calls with and without return values |
Usage Examples
// Run the generator from the command line or build system
// This generates Call.java and ActorCall.java in the parallel actor package
ParallelActorCallGenerator.main(new String[]{
"../api/src/main/java/io/ray/api/parallelactor/"
});
// The generated Call.java produces methods like:
// public static <T0, A> ParallelActorCreator<A> actor(RayFunc1<T0, A> f, T0 t0) { ... }
// The generated ActorCall.java produces methods like:
// default <R> ParallelActorTaskCaller<R> task(RayFunc1<A, R> f) { ... }
// default VoidParallelActorTaskCaller task(RayFuncVoid1<A> f) { ... }