diff --git a/java/api/src/main/java/org/ray/api/ActorCall.java b/java/api/src/main/java/org/ray/api/ActorCall.java index 34dfee27e..5fbbcc515 100644 --- a/java/api/src/main/java/org/ray/api/ActorCall.java +++ b/java/api/src/main/java/org/ray/api/ActorCall.java @@ -23,632 +23,632 @@ interface ActorCall { default RayObject call(RayFunc1 f) { Object[] args = new Object[]{}; - return Ray.internal().callActor(f, (RayActor) this, args); + return Ray.internal().callActor((RayActor) this, f, args); } default void call(RayFuncVoid1 f) { Object[] args = new Object[]{}; - Ray.internal().callActor(f, (RayActor) this, args); + Ray.internal().callActor((RayActor) this, f, args); } default RayObject call(RayFunc2 f, T0 t0) { Object[] args = new Object[]{t0}; - return Ray.internal().callActor(f, (RayActor) this, args); + return Ray.internal().callActor((RayActor) this, f, args); } default RayObject call(RayFunc2 f, RayObject t0) { Object[] args = new Object[]{t0}; - return Ray.internal().callActor(f, (RayActor) this, args); + return Ray.internal().callActor((RayActor) this, f, args); } default void call(RayFuncVoid2 f, T0 t0) { Object[] args = new Object[]{t0}; - Ray.internal().callActor(f, (RayActor) this, args); + Ray.internal().callActor((RayActor) this, f, args); } default void call(RayFuncVoid2 f, RayObject t0) { Object[] args = new Object[]{t0}; - Ray.internal().callActor(f, (RayActor) this, args); + Ray.internal().callActor((RayActor) this, f, args); } default RayObject call(RayFunc3 f, T0 t0, T1 t1) { Object[] args = new Object[]{t0, t1}; - return Ray.internal().callActor(f, (RayActor) this, args); + return Ray.internal().callActor((RayActor) this, f, args); } default RayObject call(RayFunc3 f, T0 t0, RayObject t1) { Object[] args = new Object[]{t0, t1}; - return Ray.internal().callActor(f, (RayActor) this, args); + return Ray.internal().callActor((RayActor) this, f, args); } default RayObject call(RayFunc3 f, RayObject t0, T1 t1) { Object[] args = new Object[]{t0, t1}; - return Ray.internal().callActor(f, (RayActor) this, args); + return Ray.internal().callActor((RayActor) this, f, args); } default RayObject call(RayFunc3 f, RayObject t0, RayObject t1) { Object[] args = new Object[]{t0, t1}; - return Ray.internal().callActor(f, (RayActor) this, args); + return Ray.internal().callActor((RayActor) this, f, args); } default void call(RayFuncVoid3 f, T0 t0, T1 t1) { Object[] args = new Object[]{t0, t1}; - Ray.internal().callActor(f, (RayActor) this, args); + Ray.internal().callActor((RayActor) this, f, args); } default void call(RayFuncVoid3 f, T0 t0, RayObject t1) { Object[] args = new Object[]{t0, t1}; - Ray.internal().callActor(f, (RayActor) this, args); + Ray.internal().callActor((RayActor) this, f, args); } default void call(RayFuncVoid3 f, RayObject t0, T1 t1) { Object[] args = new Object[]{t0, t1}; - Ray.internal().callActor(f, (RayActor) this, args); + Ray.internal().callActor((RayActor) this, f, args); } default void call(RayFuncVoid3 f, RayObject t0, RayObject t1) { Object[] args = new Object[]{t0, t1}; - Ray.internal().callActor(f, (RayActor) this, args); + Ray.internal().callActor((RayActor) this, f, args); } default RayObject call(RayFunc4 f, T0 t0, T1 t1, T2 t2) { Object[] args = new Object[]{t0, t1, t2}; - return Ray.internal().callActor(f, (RayActor) this, args); + return Ray.internal().callActor((RayActor) this, f, args); } default RayObject call(RayFunc4 f, T0 t0, T1 t1, RayObject t2) { Object[] args = new Object[]{t0, t1, t2}; - return Ray.internal().callActor(f, (RayActor) this, args); + return Ray.internal().callActor((RayActor) this, f, args); } default RayObject call(RayFunc4 f, T0 t0, RayObject t1, T2 t2) { Object[] args = new Object[]{t0, t1, t2}; - return Ray.internal().callActor(f, (RayActor) this, args); + return Ray.internal().callActor((RayActor) this, f, args); } default RayObject call(RayFunc4 f, T0 t0, RayObject t1, RayObject t2) { Object[] args = new Object[]{t0, t1, t2}; - return Ray.internal().callActor(f, (RayActor) this, args); + return Ray.internal().callActor((RayActor) this, f, args); } default RayObject call(RayFunc4 f, RayObject t0, T1 t1, T2 t2) { Object[] args = new Object[]{t0, t1, t2}; - return Ray.internal().callActor(f, (RayActor) this, args); + return Ray.internal().callActor((RayActor) this, f, args); } default RayObject call(RayFunc4 f, RayObject t0, T1 t1, RayObject t2) { Object[] args = new Object[]{t0, t1, t2}; - return Ray.internal().callActor(f, (RayActor) this, args); + return Ray.internal().callActor((RayActor) this, f, args); } default RayObject call(RayFunc4 f, RayObject t0, RayObject t1, T2 t2) { Object[] args = new Object[]{t0, t1, t2}; - return Ray.internal().callActor(f, (RayActor) this, args); + return Ray.internal().callActor((RayActor) this, f, args); } default RayObject call(RayFunc4 f, RayObject t0, RayObject t1, RayObject t2) { Object[] args = new Object[]{t0, t1, t2}; - return Ray.internal().callActor(f, (RayActor) this, args); + return Ray.internal().callActor((RayActor) this, f, args); } default void call(RayFuncVoid4 f, T0 t0, T1 t1, T2 t2) { Object[] args = new Object[]{t0, t1, t2}; - Ray.internal().callActor(f, (RayActor) this, args); + Ray.internal().callActor((RayActor) this, f, args); } default void call(RayFuncVoid4 f, T0 t0, T1 t1, RayObject t2) { Object[] args = new Object[]{t0, t1, t2}; - Ray.internal().callActor(f, (RayActor) this, args); + Ray.internal().callActor((RayActor) this, f, args); } default void call(RayFuncVoid4 f, T0 t0, RayObject t1, T2 t2) { Object[] args = new Object[]{t0, t1, t2}; - Ray.internal().callActor(f, (RayActor) this, args); + Ray.internal().callActor((RayActor) this, f, args); } default void call(RayFuncVoid4 f, T0 t0, RayObject t1, RayObject t2) { Object[] args = new Object[]{t0, t1, t2}; - Ray.internal().callActor(f, (RayActor) this, args); + Ray.internal().callActor((RayActor) this, f, args); } default void call(RayFuncVoid4 f, RayObject t0, T1 t1, T2 t2) { Object[] args = new Object[]{t0, t1, t2}; - Ray.internal().callActor(f, (RayActor) this, args); + Ray.internal().callActor((RayActor) this, f, args); } default void call(RayFuncVoid4 f, RayObject t0, T1 t1, RayObject t2) { Object[] args = new Object[]{t0, t1, t2}; - Ray.internal().callActor(f, (RayActor) this, args); + Ray.internal().callActor((RayActor) this, f, args); } default void call(RayFuncVoid4 f, RayObject t0, RayObject t1, T2 t2) { Object[] args = new Object[]{t0, t1, t2}; - Ray.internal().callActor(f, (RayActor) this, args); + Ray.internal().callActor((RayActor) this, f, args); } default void call(RayFuncVoid4 f, RayObject t0, RayObject t1, RayObject t2) { Object[] args = new Object[]{t0, t1, t2}; - Ray.internal().callActor(f, (RayActor) this, args); + Ray.internal().callActor((RayActor) this, f, args); } default RayObject call(RayFunc5 f, T0 t0, T1 t1, T2 t2, T3 t3) { Object[] args = new Object[]{t0, t1, t2, t3}; - return Ray.internal().callActor(f, (RayActor) this, args); + return Ray.internal().callActor((RayActor) this, f, args); } default RayObject call(RayFunc5 f, T0 t0, T1 t1, T2 t2, RayObject t3) { Object[] args = new Object[]{t0, t1, t2, t3}; - return Ray.internal().callActor(f, (RayActor) this, args); + return Ray.internal().callActor((RayActor) this, f, args); } default RayObject call(RayFunc5 f, T0 t0, T1 t1, RayObject t2, T3 t3) { Object[] args = new Object[]{t0, t1, t2, t3}; - return Ray.internal().callActor(f, (RayActor) this, args); + return Ray.internal().callActor((RayActor) this, f, args); } default RayObject call(RayFunc5 f, T0 t0, T1 t1, RayObject t2, RayObject t3) { Object[] args = new Object[]{t0, t1, t2, t3}; - return Ray.internal().callActor(f, (RayActor) this, args); + return Ray.internal().callActor((RayActor) this, f, args); } default RayObject call(RayFunc5 f, T0 t0, RayObject t1, T2 t2, T3 t3) { Object[] args = new Object[]{t0, t1, t2, t3}; - return Ray.internal().callActor(f, (RayActor) this, args); + return Ray.internal().callActor((RayActor) this, f, args); } default RayObject call(RayFunc5 f, T0 t0, RayObject t1, T2 t2, RayObject t3) { Object[] args = new Object[]{t0, t1, t2, t3}; - return Ray.internal().callActor(f, (RayActor) this, args); + return Ray.internal().callActor((RayActor) this, f, args); } default RayObject call(RayFunc5 f, T0 t0, RayObject t1, RayObject t2, T3 t3) { Object[] args = new Object[]{t0, t1, t2, t3}; - return Ray.internal().callActor(f, (RayActor) this, args); + return Ray.internal().callActor((RayActor) this, f, args); } default RayObject call(RayFunc5 f, T0 t0, RayObject t1, RayObject t2, RayObject t3) { Object[] args = new Object[]{t0, t1, t2, t3}; - return Ray.internal().callActor(f, (RayActor) this, args); + return Ray.internal().callActor((RayActor) this, f, args); } default RayObject call(RayFunc5 f, RayObject t0, T1 t1, T2 t2, T3 t3) { Object[] args = new Object[]{t0, t1, t2, t3}; - return Ray.internal().callActor(f, (RayActor) this, args); + return Ray.internal().callActor((RayActor) this, f, args); } default RayObject call(RayFunc5 f, RayObject t0, T1 t1, T2 t2, RayObject t3) { Object[] args = new Object[]{t0, t1, t2, t3}; - return Ray.internal().callActor(f, (RayActor) this, args); + return Ray.internal().callActor((RayActor) this, f, args); } default RayObject call(RayFunc5 f, RayObject t0, T1 t1, RayObject t2, T3 t3) { Object[] args = new Object[]{t0, t1, t2, t3}; - return Ray.internal().callActor(f, (RayActor) this, args); + return Ray.internal().callActor((RayActor) this, f, args); } default RayObject call(RayFunc5 f, RayObject t0, T1 t1, RayObject t2, RayObject t3) { Object[] args = new Object[]{t0, t1, t2, t3}; - return Ray.internal().callActor(f, (RayActor) this, args); + return Ray.internal().callActor((RayActor) this, f, args); } default RayObject call(RayFunc5 f, RayObject t0, RayObject t1, T2 t2, T3 t3) { Object[] args = new Object[]{t0, t1, t2, t3}; - return Ray.internal().callActor(f, (RayActor) this, args); + return Ray.internal().callActor((RayActor) this, f, args); } default RayObject call(RayFunc5 f, RayObject t0, RayObject t1, T2 t2, RayObject t3) { Object[] args = new Object[]{t0, t1, t2, t3}; - return Ray.internal().callActor(f, (RayActor) this, args); + return Ray.internal().callActor((RayActor) this, f, args); } default RayObject call(RayFunc5 f, RayObject t0, RayObject t1, RayObject t2, T3 t3) { Object[] args = new Object[]{t0, t1, t2, t3}; - return Ray.internal().callActor(f, (RayActor) this, args); + return Ray.internal().callActor((RayActor) this, f, args); } default RayObject call(RayFunc5 f, RayObject t0, RayObject t1, RayObject t2, RayObject t3) { Object[] args = new Object[]{t0, t1, t2, t3}; - return Ray.internal().callActor(f, (RayActor) this, args); + return Ray.internal().callActor((RayActor) this, f, args); } default void call(RayFuncVoid5 f, T0 t0, T1 t1, T2 t2, T3 t3) { Object[] args = new Object[]{t0, t1, t2, t3}; - Ray.internal().callActor(f, (RayActor) this, args); + Ray.internal().callActor((RayActor) this, f, args); } default void call(RayFuncVoid5 f, T0 t0, T1 t1, T2 t2, RayObject t3) { Object[] args = new Object[]{t0, t1, t2, t3}; - Ray.internal().callActor(f, (RayActor) this, args); + Ray.internal().callActor((RayActor) this, f, args); } default void call(RayFuncVoid5 f, T0 t0, T1 t1, RayObject t2, T3 t3) { Object[] args = new Object[]{t0, t1, t2, t3}; - Ray.internal().callActor(f, (RayActor) this, args); + Ray.internal().callActor((RayActor) this, f, args); } default void call(RayFuncVoid5 f, T0 t0, T1 t1, RayObject t2, RayObject t3) { Object[] args = new Object[]{t0, t1, t2, t3}; - Ray.internal().callActor(f, (RayActor) this, args); + Ray.internal().callActor((RayActor) this, f, args); } default void call(RayFuncVoid5 f, T0 t0, RayObject t1, T2 t2, T3 t3) { Object[] args = new Object[]{t0, t1, t2, t3}; - Ray.internal().callActor(f, (RayActor) this, args); + Ray.internal().callActor((RayActor) this, f, args); } default void call(RayFuncVoid5 f, T0 t0, RayObject t1, T2 t2, RayObject t3) { Object[] args = new Object[]{t0, t1, t2, t3}; - Ray.internal().callActor(f, (RayActor) this, args); + Ray.internal().callActor((RayActor) this, f, args); } default void call(RayFuncVoid5 f, T0 t0, RayObject t1, RayObject t2, T3 t3) { Object[] args = new Object[]{t0, t1, t2, t3}; - Ray.internal().callActor(f, (RayActor) this, args); + Ray.internal().callActor((RayActor) this, f, args); } default void call(RayFuncVoid5 f, T0 t0, RayObject t1, RayObject t2, RayObject t3) { Object[] args = new Object[]{t0, t1, t2, t3}; - Ray.internal().callActor(f, (RayActor) this, args); + Ray.internal().callActor((RayActor) this, f, args); } default void call(RayFuncVoid5 f, RayObject t0, T1 t1, T2 t2, T3 t3) { Object[] args = new Object[]{t0, t1, t2, t3}; - Ray.internal().callActor(f, (RayActor) this, args); + Ray.internal().callActor((RayActor) this, f, args); } default void call(RayFuncVoid5 f, RayObject t0, T1 t1, T2 t2, RayObject t3) { Object[] args = new Object[]{t0, t1, t2, t3}; - Ray.internal().callActor(f, (RayActor) this, args); + Ray.internal().callActor((RayActor) this, f, args); } default void call(RayFuncVoid5 f, RayObject t0, T1 t1, RayObject t2, T3 t3) { Object[] args = new Object[]{t0, t1, t2, t3}; - Ray.internal().callActor(f, (RayActor) this, args); + Ray.internal().callActor((RayActor) this, f, args); } default void call(RayFuncVoid5 f, RayObject t0, T1 t1, RayObject t2, RayObject t3) { Object[] args = new Object[]{t0, t1, t2, t3}; - Ray.internal().callActor(f, (RayActor) this, args); + Ray.internal().callActor((RayActor) this, f, args); } default void call(RayFuncVoid5 f, RayObject t0, RayObject t1, T2 t2, T3 t3) { Object[] args = new Object[]{t0, t1, t2, t3}; - Ray.internal().callActor(f, (RayActor) this, args); + Ray.internal().callActor((RayActor) this, f, args); } default void call(RayFuncVoid5 f, RayObject t0, RayObject t1, T2 t2, RayObject t3) { Object[] args = new Object[]{t0, t1, t2, t3}; - Ray.internal().callActor(f, (RayActor) this, args); + Ray.internal().callActor((RayActor) this, f, args); } default void call(RayFuncVoid5 f, RayObject t0, RayObject t1, RayObject t2, T3 t3) { Object[] args = new Object[]{t0, t1, t2, t3}; - Ray.internal().callActor(f, (RayActor) this, args); + Ray.internal().callActor((RayActor) this, f, args); } default void call(RayFuncVoid5 f, RayObject t0, RayObject t1, RayObject t2, RayObject t3) { Object[] args = new Object[]{t0, t1, t2, t3}; - Ray.internal().callActor(f, (RayActor) this, args); + Ray.internal().callActor((RayActor) this, f, args); } default RayObject call(RayFunc6 f, T0 t0, T1 t1, T2 t2, T3 t3, T4 t4) { Object[] args = new Object[]{t0, t1, t2, t3, t4}; - return Ray.internal().callActor(f, (RayActor) this, args); + return Ray.internal().callActor((RayActor) this, f, args); } default RayObject call(RayFunc6 f, T0 t0, T1 t1, T2 t2, T3 t3, RayObject t4) { Object[] args = new Object[]{t0, t1, t2, t3, t4}; - return Ray.internal().callActor(f, (RayActor) this, args); + return Ray.internal().callActor((RayActor) this, f, args); } default RayObject call(RayFunc6 f, T0 t0, T1 t1, T2 t2, RayObject t3, T4 t4) { Object[] args = new Object[]{t0, t1, t2, t3, t4}; - return Ray.internal().callActor(f, (RayActor) this, args); + return Ray.internal().callActor((RayActor) this, f, args); } default RayObject call(RayFunc6 f, T0 t0, T1 t1, T2 t2, RayObject t3, RayObject t4) { Object[] args = new Object[]{t0, t1, t2, t3, t4}; - return Ray.internal().callActor(f, (RayActor) this, args); + return Ray.internal().callActor((RayActor) this, f, args); } default RayObject call(RayFunc6 f, T0 t0, T1 t1, RayObject t2, T3 t3, T4 t4) { Object[] args = new Object[]{t0, t1, t2, t3, t4}; - return Ray.internal().callActor(f, (RayActor) this, args); + return Ray.internal().callActor((RayActor) this, f, args); } default RayObject call(RayFunc6 f, T0 t0, T1 t1, RayObject t2, T3 t3, RayObject t4) { Object[] args = new Object[]{t0, t1, t2, t3, t4}; - return Ray.internal().callActor(f, (RayActor) this, args); + return Ray.internal().callActor((RayActor) this, f, args); } default RayObject call(RayFunc6 f, T0 t0, T1 t1, RayObject t2, RayObject t3, T4 t4) { Object[] args = new Object[]{t0, t1, t2, t3, t4}; - return Ray.internal().callActor(f, (RayActor) this, args); + return Ray.internal().callActor((RayActor) this, f, args); } default RayObject call(RayFunc6 f, T0 t0, T1 t1, RayObject t2, RayObject t3, RayObject t4) { Object[] args = new Object[]{t0, t1, t2, t3, t4}; - return Ray.internal().callActor(f, (RayActor) this, args); + return Ray.internal().callActor((RayActor) this, f, args); } default RayObject call(RayFunc6 f, T0 t0, RayObject t1, T2 t2, T3 t3, T4 t4) { Object[] args = new Object[]{t0, t1, t2, t3, t4}; - return Ray.internal().callActor(f, (RayActor) this, args); + return Ray.internal().callActor((RayActor) this, f, args); } default RayObject call(RayFunc6 f, T0 t0, RayObject t1, T2 t2, T3 t3, RayObject t4) { Object[] args = new Object[]{t0, t1, t2, t3, t4}; - return Ray.internal().callActor(f, (RayActor) this, args); + return Ray.internal().callActor((RayActor) this, f, args); } default RayObject call(RayFunc6 f, T0 t0, RayObject t1, T2 t2, RayObject t3, T4 t4) { Object[] args = new Object[]{t0, t1, t2, t3, t4}; - return Ray.internal().callActor(f, (RayActor) this, args); + return Ray.internal().callActor((RayActor) this, f, args); } default RayObject call(RayFunc6 f, T0 t0, RayObject t1, T2 t2, RayObject t3, RayObject t4) { Object[] args = new Object[]{t0, t1, t2, t3, t4}; - return Ray.internal().callActor(f, (RayActor) this, args); + return Ray.internal().callActor((RayActor) this, f, args); } default RayObject call(RayFunc6 f, T0 t0, RayObject t1, RayObject t2, T3 t3, T4 t4) { Object[] args = new Object[]{t0, t1, t2, t3, t4}; - return Ray.internal().callActor(f, (RayActor) this, args); + return Ray.internal().callActor((RayActor) this, f, args); } default RayObject call(RayFunc6 f, T0 t0, RayObject t1, RayObject t2, T3 t3, RayObject t4) { Object[] args = new Object[]{t0, t1, t2, t3, t4}; - return Ray.internal().callActor(f, (RayActor) this, args); + return Ray.internal().callActor((RayActor) this, f, args); } default RayObject call(RayFunc6 f, T0 t0, RayObject t1, RayObject t2, RayObject t3, T4 t4) { Object[] args = new Object[]{t0, t1, t2, t3, t4}; - return Ray.internal().callActor(f, (RayActor) this, args); + return Ray.internal().callActor((RayActor) this, f, args); } default RayObject call(RayFunc6 f, T0 t0, RayObject t1, RayObject t2, RayObject t3, RayObject t4) { Object[] args = new Object[]{t0, t1, t2, t3, t4}; - return Ray.internal().callActor(f, (RayActor) this, args); + return Ray.internal().callActor((RayActor) this, f, args); } default RayObject call(RayFunc6 f, RayObject t0, T1 t1, T2 t2, T3 t3, T4 t4) { Object[] args = new Object[]{t0, t1, t2, t3, t4}; - return Ray.internal().callActor(f, (RayActor) this, args); + return Ray.internal().callActor((RayActor) this, f, args); } default RayObject call(RayFunc6 f, RayObject t0, T1 t1, T2 t2, T3 t3, RayObject t4) { Object[] args = new Object[]{t0, t1, t2, t3, t4}; - return Ray.internal().callActor(f, (RayActor) this, args); + return Ray.internal().callActor((RayActor) this, f, args); } default RayObject call(RayFunc6 f, RayObject t0, T1 t1, T2 t2, RayObject t3, T4 t4) { Object[] args = new Object[]{t0, t1, t2, t3, t4}; - return Ray.internal().callActor(f, (RayActor) this, args); + return Ray.internal().callActor((RayActor) this, f, args); } default RayObject call(RayFunc6 f, RayObject t0, T1 t1, T2 t2, RayObject t3, RayObject t4) { Object[] args = new Object[]{t0, t1, t2, t3, t4}; - return Ray.internal().callActor(f, (RayActor) this, args); + return Ray.internal().callActor((RayActor) this, f, args); } default RayObject call(RayFunc6 f, RayObject t0, T1 t1, RayObject t2, T3 t3, T4 t4) { Object[] args = new Object[]{t0, t1, t2, t3, t4}; - return Ray.internal().callActor(f, (RayActor) this, args); + return Ray.internal().callActor((RayActor) this, f, args); } default RayObject call(RayFunc6 f, RayObject t0, T1 t1, RayObject t2, T3 t3, RayObject t4) { Object[] args = new Object[]{t0, t1, t2, t3, t4}; - return Ray.internal().callActor(f, (RayActor) this, args); + return Ray.internal().callActor((RayActor) this, f, args); } default RayObject call(RayFunc6 f, RayObject t0, T1 t1, RayObject t2, RayObject t3, T4 t4) { Object[] args = new Object[]{t0, t1, t2, t3, t4}; - return Ray.internal().callActor(f, (RayActor) this, args); + return Ray.internal().callActor((RayActor) this, f, args); } default RayObject call(RayFunc6 f, RayObject t0, T1 t1, RayObject t2, RayObject t3, RayObject t4) { Object[] args = new Object[]{t0, t1, t2, t3, t4}; - return Ray.internal().callActor(f, (RayActor) this, args); + return Ray.internal().callActor((RayActor) this, f, args); } default RayObject call(RayFunc6 f, RayObject t0, RayObject t1, T2 t2, T3 t3, T4 t4) { Object[] args = new Object[]{t0, t1, t2, t3, t4}; - return Ray.internal().callActor(f, (RayActor) this, args); + return Ray.internal().callActor((RayActor) this, f, args); } default RayObject call(RayFunc6 f, RayObject t0, RayObject t1, T2 t2, T3 t3, RayObject t4) { Object[] args = new Object[]{t0, t1, t2, t3, t4}; - return Ray.internal().callActor(f, (RayActor) this, args); + return Ray.internal().callActor((RayActor) this, f, args); } default RayObject call(RayFunc6 f, RayObject t0, RayObject t1, T2 t2, RayObject t3, T4 t4) { Object[] args = new Object[]{t0, t1, t2, t3, t4}; - return Ray.internal().callActor(f, (RayActor) this, args); + return Ray.internal().callActor((RayActor) this, f, args); } default RayObject call(RayFunc6 f, RayObject t0, RayObject t1, T2 t2, RayObject t3, RayObject t4) { Object[] args = new Object[]{t0, t1, t2, t3, t4}; - return Ray.internal().callActor(f, (RayActor) this, args); + return Ray.internal().callActor((RayActor) this, f, args); } default RayObject call(RayFunc6 f, RayObject t0, RayObject t1, RayObject t2, T3 t3, T4 t4) { Object[] args = new Object[]{t0, t1, t2, t3, t4}; - return Ray.internal().callActor(f, (RayActor) this, args); + return Ray.internal().callActor((RayActor) this, f, args); } default RayObject call(RayFunc6 f, RayObject t0, RayObject t1, RayObject t2, T3 t3, RayObject t4) { Object[] args = new Object[]{t0, t1, t2, t3, t4}; - return Ray.internal().callActor(f, (RayActor) this, args); + return Ray.internal().callActor((RayActor) this, f, args); } default RayObject call(RayFunc6 f, RayObject t0, RayObject t1, RayObject t2, RayObject t3, T4 t4) { Object[] args = new Object[]{t0, t1, t2, t3, t4}; - return Ray.internal().callActor(f, (RayActor) this, args); + return Ray.internal().callActor((RayActor) this, f, args); } default RayObject call(RayFunc6 f, RayObject t0, RayObject t1, RayObject t2, RayObject t3, RayObject t4) { Object[] args = new Object[]{t0, t1, t2, t3, t4}; - return Ray.internal().callActor(f, (RayActor) this, args); + return Ray.internal().callActor((RayActor) this, f, args); } default void call(RayFuncVoid6 f, T0 t0, T1 t1, T2 t2, T3 t3, T4 t4) { Object[] args = new Object[]{t0, t1, t2, t3, t4}; - Ray.internal().callActor(f, (RayActor) this, args); + Ray.internal().callActor((RayActor) this, f, args); } default void call(RayFuncVoid6 f, T0 t0, T1 t1, T2 t2, T3 t3, RayObject t4) { Object[] args = new Object[]{t0, t1, t2, t3, t4}; - Ray.internal().callActor(f, (RayActor) this, args); + Ray.internal().callActor((RayActor) this, f, args); } default void call(RayFuncVoid6 f, T0 t0, T1 t1, T2 t2, RayObject t3, T4 t4) { Object[] args = new Object[]{t0, t1, t2, t3, t4}; - Ray.internal().callActor(f, (RayActor) this, args); + Ray.internal().callActor((RayActor) this, f, args); } default void call(RayFuncVoid6 f, T0 t0, T1 t1, T2 t2, RayObject t3, RayObject t4) { Object[] args = new Object[]{t0, t1, t2, t3, t4}; - Ray.internal().callActor(f, (RayActor) this, args); + Ray.internal().callActor((RayActor) this, f, args); } default void call(RayFuncVoid6 f, T0 t0, T1 t1, RayObject t2, T3 t3, T4 t4) { Object[] args = new Object[]{t0, t1, t2, t3, t4}; - Ray.internal().callActor(f, (RayActor) this, args); + Ray.internal().callActor((RayActor) this, f, args); } default void call(RayFuncVoid6 f, T0 t0, T1 t1, RayObject t2, T3 t3, RayObject t4) { Object[] args = new Object[]{t0, t1, t2, t3, t4}; - Ray.internal().callActor(f, (RayActor) this, args); + Ray.internal().callActor((RayActor) this, f, args); } default void call(RayFuncVoid6 f, T0 t0, T1 t1, RayObject t2, RayObject t3, T4 t4) { Object[] args = new Object[]{t0, t1, t2, t3, t4}; - Ray.internal().callActor(f, (RayActor) this, args); + Ray.internal().callActor((RayActor) this, f, args); } default void call(RayFuncVoid6 f, T0 t0, T1 t1, RayObject t2, RayObject t3, RayObject t4) { Object[] args = new Object[]{t0, t1, t2, t3, t4}; - Ray.internal().callActor(f, (RayActor) this, args); + Ray.internal().callActor((RayActor) this, f, args); } default void call(RayFuncVoid6 f, T0 t0, RayObject t1, T2 t2, T3 t3, T4 t4) { Object[] args = new Object[]{t0, t1, t2, t3, t4}; - Ray.internal().callActor(f, (RayActor) this, args); + Ray.internal().callActor((RayActor) this, f, args); } default void call(RayFuncVoid6 f, T0 t0, RayObject t1, T2 t2, T3 t3, RayObject t4) { Object[] args = new Object[]{t0, t1, t2, t3, t4}; - Ray.internal().callActor(f, (RayActor) this, args); + Ray.internal().callActor((RayActor) this, f, args); } default void call(RayFuncVoid6 f, T0 t0, RayObject t1, T2 t2, RayObject t3, T4 t4) { Object[] args = new Object[]{t0, t1, t2, t3, t4}; - Ray.internal().callActor(f, (RayActor) this, args); + Ray.internal().callActor((RayActor) this, f, args); } default void call(RayFuncVoid6 f, T0 t0, RayObject t1, T2 t2, RayObject t3, RayObject t4) { Object[] args = new Object[]{t0, t1, t2, t3, t4}; - Ray.internal().callActor(f, (RayActor) this, args); + Ray.internal().callActor((RayActor) this, f, args); } default void call(RayFuncVoid6 f, T0 t0, RayObject t1, RayObject t2, T3 t3, T4 t4) { Object[] args = new Object[]{t0, t1, t2, t3, t4}; - Ray.internal().callActor(f, (RayActor) this, args); + Ray.internal().callActor((RayActor) this, f, args); } default void call(RayFuncVoid6 f, T0 t0, RayObject t1, RayObject t2, T3 t3, RayObject t4) { Object[] args = new Object[]{t0, t1, t2, t3, t4}; - Ray.internal().callActor(f, (RayActor) this, args); + Ray.internal().callActor((RayActor) this, f, args); } default void call(RayFuncVoid6 f, T0 t0, RayObject t1, RayObject t2, RayObject t3, T4 t4) { Object[] args = new Object[]{t0, t1, t2, t3, t4}; - Ray.internal().callActor(f, (RayActor) this, args); + Ray.internal().callActor((RayActor) this, f, args); } default void call(RayFuncVoid6 f, T0 t0, RayObject t1, RayObject t2, RayObject t3, RayObject t4) { Object[] args = new Object[]{t0, t1, t2, t3, t4}; - Ray.internal().callActor(f, (RayActor) this, args); + Ray.internal().callActor((RayActor) this, f, args); } default void call(RayFuncVoid6 f, RayObject t0, T1 t1, T2 t2, T3 t3, T4 t4) { Object[] args = new Object[]{t0, t1, t2, t3, t4}; - Ray.internal().callActor(f, (RayActor) this, args); + Ray.internal().callActor((RayActor) this, f, args); } default void call(RayFuncVoid6 f, RayObject t0, T1 t1, T2 t2, T3 t3, RayObject t4) { Object[] args = new Object[]{t0, t1, t2, t3, t4}; - Ray.internal().callActor(f, (RayActor) this, args); + Ray.internal().callActor((RayActor) this, f, args); } default void call(RayFuncVoid6 f, RayObject t0, T1 t1, T2 t2, RayObject t3, T4 t4) { Object[] args = new Object[]{t0, t1, t2, t3, t4}; - Ray.internal().callActor(f, (RayActor) this, args); + Ray.internal().callActor((RayActor) this, f, args); } default void call(RayFuncVoid6 f, RayObject t0, T1 t1, T2 t2, RayObject t3, RayObject t4) { Object[] args = new Object[]{t0, t1, t2, t3, t4}; - Ray.internal().callActor(f, (RayActor) this, args); + Ray.internal().callActor((RayActor) this, f, args); } default void call(RayFuncVoid6 f, RayObject t0, T1 t1, RayObject t2, T3 t3, T4 t4) { Object[] args = new Object[]{t0, t1, t2, t3, t4}; - Ray.internal().callActor(f, (RayActor) this, args); + Ray.internal().callActor((RayActor) this, f, args); } default void call(RayFuncVoid6 f, RayObject t0, T1 t1, RayObject t2, T3 t3, RayObject t4) { Object[] args = new Object[]{t0, t1, t2, t3, t4}; - Ray.internal().callActor(f, (RayActor) this, args); + Ray.internal().callActor((RayActor) this, f, args); } default void call(RayFuncVoid6 f, RayObject t0, T1 t1, RayObject t2, RayObject t3, T4 t4) { Object[] args = new Object[]{t0, t1, t2, t3, t4}; - Ray.internal().callActor(f, (RayActor) this, args); + Ray.internal().callActor((RayActor) this, f, args); } default void call(RayFuncVoid6 f, RayObject t0, T1 t1, RayObject t2, RayObject t3, RayObject t4) { Object[] args = new Object[]{t0, t1, t2, t3, t4}; - Ray.internal().callActor(f, (RayActor) this, args); + Ray.internal().callActor((RayActor) this, f, args); } default void call(RayFuncVoid6 f, RayObject t0, RayObject t1, T2 t2, T3 t3, T4 t4) { Object[] args = new Object[]{t0, t1, t2, t3, t4}; - Ray.internal().callActor(f, (RayActor) this, args); + Ray.internal().callActor((RayActor) this, f, args); } default void call(RayFuncVoid6 f, RayObject t0, RayObject t1, T2 t2, T3 t3, RayObject t4) { Object[] args = new Object[]{t0, t1, t2, t3, t4}; - Ray.internal().callActor(f, (RayActor) this, args); + Ray.internal().callActor((RayActor) this, f, args); } default void call(RayFuncVoid6 f, RayObject t0, RayObject t1, T2 t2, RayObject t3, T4 t4) { Object[] args = new Object[]{t0, t1, t2, t3, t4}; - Ray.internal().callActor(f, (RayActor) this, args); + Ray.internal().callActor((RayActor) this, f, args); } default void call(RayFuncVoid6 f, RayObject t0, RayObject t1, T2 t2, RayObject t3, RayObject t4) { Object[] args = new Object[]{t0, t1, t2, t3, t4}; - Ray.internal().callActor(f, (RayActor) this, args); + Ray.internal().callActor((RayActor) this, f, args); } default void call(RayFuncVoid6 f, RayObject t0, RayObject t1, RayObject t2, T3 t3, T4 t4) { Object[] args = new Object[]{t0, t1, t2, t3, t4}; - Ray.internal().callActor(f, (RayActor) this, args); + Ray.internal().callActor((RayActor) this, f, args); } default void call(RayFuncVoid6 f, RayObject t0, RayObject t1, RayObject t2, T3 t3, RayObject t4) { Object[] args = new Object[]{t0, t1, t2, t3, t4}; - Ray.internal().callActor(f, (RayActor) this, args); + Ray.internal().callActor((RayActor) this, f, args); } default void call(RayFuncVoid6 f, RayObject t0, RayObject t1, RayObject t2, RayObject t3, T4 t4) { Object[] args = new Object[]{t0, t1, t2, t3, t4}; - Ray.internal().callActor(f, (RayActor) this, args); + Ray.internal().callActor((RayActor) this, f, args); } default void call(RayFuncVoid6 f, RayObject t0, RayObject t1, RayObject t2, RayObject t3, RayObject t4) { Object[] args = new Object[]{t0, t1, t2, t3, t4}; - Ray.internal().callActor(f, (RayActor) this, args); + Ray.internal().callActor((RayActor) this, f, args); } } diff --git a/java/api/src/main/java/org/ray/api/PyActorCall.java b/java/api/src/main/java/org/ray/api/PyActorCall.java index a462a208b..c2aaecbf4 100644 --- a/java/api/src/main/java/org/ray/api/PyActorCall.java +++ b/java/api/src/main/java/org/ray/api/PyActorCall.java @@ -2,40 +2,42 @@ package org.ray.api; +import org.ray.api.function.PyActorMethod; + /** * This class provides type-safe interfaces for remote actor calls. **/ @SuppressWarnings({"rawtypes", "unchecked"}) interface PyActorCall { - default RayObject call(String functionName) { + default RayObject call(PyActorMethod pyActorMethod) { Object[] args = new Object[]{}; - return Ray.internal().callPyActor((RayPyActor)this, functionName, args); + return Ray.internal().callActor((RayPyActor)this, pyActorMethod, args); } - default RayObject call(String functionName, Object obj0) { + default RayObject call(PyActorMethod pyActorMethod, Object obj0) { Object[] args = new Object[]{obj0}; - return Ray.internal().callPyActor((RayPyActor)this, functionName, args); + return Ray.internal().callActor((RayPyActor)this, pyActorMethod, args); } - default RayObject call(String functionName, Object obj0, Object obj1) { + default RayObject call(PyActorMethod pyActorMethod, Object obj0, Object obj1) { Object[] args = new Object[]{obj0, obj1}; - return Ray.internal().callPyActor((RayPyActor)this, functionName, args); + return Ray.internal().callActor((RayPyActor)this, pyActorMethod, args); } - default RayObject call(String functionName, Object obj0, Object obj1, Object obj2) { + default RayObject call(PyActorMethod pyActorMethod, Object obj0, Object obj1, Object obj2) { Object[] args = new Object[]{obj0, obj1, obj2}; - return Ray.internal().callPyActor((RayPyActor)this, functionName, args); + return Ray.internal().callActor((RayPyActor)this, pyActorMethod, args); } - default RayObject call(String functionName, Object obj0, Object obj1, Object obj2, Object obj3) { + default RayObject call(PyActorMethod pyActorMethod, Object obj0, Object obj1, Object obj2, Object obj3) { Object[] args = new Object[]{obj0, obj1, obj2, obj3}; - return Ray.internal().callPyActor((RayPyActor)this, functionName, args); + return Ray.internal().callActor((RayPyActor)this, pyActorMethod, args); } - default RayObject call(String functionName, Object obj0, Object obj1, Object obj2, Object obj3, Object obj4) { + default RayObject call(PyActorMethod pyActorMethod, Object obj0, Object obj1, Object obj2, Object obj3, Object obj4) { Object[] args = new Object[]{obj0, obj1, obj2, obj3, obj4}; - return Ray.internal().callPyActor((RayPyActor)this, functionName, args); + return Ray.internal().callActor((RayPyActor)this, pyActorMethod, args); } } diff --git a/java/api/src/main/java/org/ray/api/RayCall.java b/java/api/src/main/java/org/ray/api/RayCall.java index 62259fba1..3f7e387ce 100644 --- a/java/api/src/main/java/org/ray/api/RayCall.java +++ b/java/api/src/main/java/org/ray/api/RayCall.java @@ -2,6 +2,8 @@ package org.ray.api; +import org.ray.api.function.PyActorClass; +import org.ray.api.function.PyRemoteFunction; import org.ray.api.function.RayFunc0; import org.ray.api.function.RayFunc1; import org.ray.api.function.RayFunc2; @@ -3843,144 +3845,144 @@ class RayCall { // =========================== // Cross-language methods. // =========================== - public static RayObject callPy(String moduleName, String functionName) { + public static RayObject call(PyRemoteFunction pyRemoteFunction) { Object[] args = new Object[]{}; - return Ray.internal().callPy(moduleName, functionName, args, null); + return Ray.internal().call(pyRemoteFunction, args, null); } - public static RayObject callPy(String moduleName, String functionName, CallOptions options) { + public static RayObject call(PyRemoteFunction pyRemoteFunction, CallOptions options) { Object[] args = new Object[]{}; - return Ray.internal().callPy(moduleName, functionName, args, options); + return Ray.internal().call(pyRemoteFunction, args, options); } - public static RayObject callPy(String moduleName, String functionName, Object obj0) { + public static RayObject call(PyRemoteFunction pyRemoteFunction, Object obj0) { Object[] args = new Object[]{obj0}; - return Ray.internal().callPy(moduleName, functionName, args, null); + return Ray.internal().call(pyRemoteFunction, args, null); } - public static RayObject callPy(String moduleName, String functionName, Object obj0, CallOptions options) { + public static RayObject call(PyRemoteFunction pyRemoteFunction, Object obj0, CallOptions options) { Object[] args = new Object[]{obj0}; - return Ray.internal().callPy(moduleName, functionName, args, options); + return Ray.internal().call(pyRemoteFunction, args, options); } - public static RayObject callPy(String moduleName, String functionName, Object obj0, Object obj1) { + public static RayObject call(PyRemoteFunction pyRemoteFunction, Object obj0, Object obj1) { Object[] args = new Object[]{obj0, obj1}; - return Ray.internal().callPy(moduleName, functionName, args, null); + return Ray.internal().call(pyRemoteFunction, args, null); } - public static RayObject callPy(String moduleName, String functionName, Object obj0, Object obj1, CallOptions options) { + public static RayObject call(PyRemoteFunction pyRemoteFunction, Object obj0, Object obj1, CallOptions options) { Object[] args = new Object[]{obj0, obj1}; - return Ray.internal().callPy(moduleName, functionName, args, options); + return Ray.internal().call(pyRemoteFunction, args, options); } - public static RayObject callPy(String moduleName, String functionName, Object obj0, Object obj1, Object obj2) { + public static RayObject call(PyRemoteFunction pyRemoteFunction, Object obj0, Object obj1, Object obj2) { Object[] args = new Object[]{obj0, obj1, obj2}; - return Ray.internal().callPy(moduleName, functionName, args, null); + return Ray.internal().call(pyRemoteFunction, args, null); } - public static RayObject callPy(String moduleName, String functionName, Object obj0, Object obj1, Object obj2, CallOptions options) { + public static RayObject call(PyRemoteFunction pyRemoteFunction, Object obj0, Object obj1, Object obj2, CallOptions options) { Object[] args = new Object[]{obj0, obj1, obj2}; - return Ray.internal().callPy(moduleName, functionName, args, options); + return Ray.internal().call(pyRemoteFunction, args, options); } - public static RayObject callPy(String moduleName, String functionName, Object obj0, Object obj1, Object obj2, Object obj3) { + public static RayObject call(PyRemoteFunction pyRemoteFunction, Object obj0, Object obj1, Object obj2, Object obj3) { Object[] args = new Object[]{obj0, obj1, obj2, obj3}; - return Ray.internal().callPy(moduleName, functionName, args, null); + return Ray.internal().call(pyRemoteFunction, args, null); } - public static RayObject callPy(String moduleName, String functionName, Object obj0, Object obj1, Object obj2, Object obj3, CallOptions options) { + public static RayObject call(PyRemoteFunction pyRemoteFunction, Object obj0, Object obj1, Object obj2, Object obj3, CallOptions options) { Object[] args = new Object[]{obj0, obj1, obj2, obj3}; - return Ray.internal().callPy(moduleName, functionName, args, options); + return Ray.internal().call(pyRemoteFunction, args, options); } - public static RayObject callPy(String moduleName, String functionName, Object obj0, Object obj1, Object obj2, Object obj3, Object obj4) { + public static RayObject call(PyRemoteFunction pyRemoteFunction, Object obj0, Object obj1, Object obj2, Object obj3, Object obj4) { Object[] args = new Object[]{obj0, obj1, obj2, obj3, obj4}; - return Ray.internal().callPy(moduleName, functionName, args, null); + return Ray.internal().call(pyRemoteFunction, args, null); } - public static RayObject callPy(String moduleName, String functionName, Object obj0, Object obj1, Object obj2, Object obj3, Object obj4, CallOptions options) { + public static RayObject call(PyRemoteFunction pyRemoteFunction, Object obj0, Object obj1, Object obj2, Object obj3, Object obj4, CallOptions options) { Object[] args = new Object[]{obj0, obj1, obj2, obj3, obj4}; - return Ray.internal().callPy(moduleName, functionName, args, options); + return Ray.internal().call(pyRemoteFunction, args, options); } - public static RayObject callPy(String moduleName, String functionName, Object obj0, Object obj1, Object obj2, Object obj3, Object obj4, Object obj5) { + public static RayObject call(PyRemoteFunction pyRemoteFunction, Object obj0, Object obj1, Object obj2, Object obj3, Object obj4, Object obj5) { Object[] args = new Object[]{obj0, obj1, obj2, obj3, obj4, obj5}; - return Ray.internal().callPy(moduleName, functionName, args, null); + return Ray.internal().call(pyRemoteFunction, args, null); } - public static RayObject callPy(String moduleName, String functionName, Object obj0, Object obj1, Object obj2, Object obj3, Object obj4, Object obj5, CallOptions options) { + public static RayObject call(PyRemoteFunction pyRemoteFunction, Object obj0, Object obj1, Object obj2, Object obj3, Object obj4, Object obj5, CallOptions options) { Object[] args = new Object[]{obj0, obj1, obj2, obj3, obj4, obj5}; - return Ray.internal().callPy(moduleName, functionName, args, options); + return Ray.internal().call(pyRemoteFunction, args, options); } - public static RayPyActor createPyActor(String moduleName, String className) { + public static RayPyActor createActor(PyActorClass pyActorClass) { Object[] args = new Object[]{}; - return Ray.internal().createPyActor(moduleName, className, args, null); + return Ray.internal().createActor(pyActorClass, args, null); } - public static RayPyActor createPyActor(String moduleName, String className, ActorCreationOptions options) { + public static RayPyActor createActor(PyActorClass pyActorClass, ActorCreationOptions options) { Object[] args = new Object[]{}; - return Ray.internal().createPyActor(moduleName, className, args, options); + return Ray.internal().createActor(pyActorClass, args, options); } - public static RayPyActor createPyActor(String moduleName, String className, Object obj0) { + public static RayPyActor createActor(PyActorClass pyActorClass, Object obj0) { Object[] args = new Object[]{obj0}; - return Ray.internal().createPyActor(moduleName, className, args, null); + return Ray.internal().createActor(pyActorClass, args, null); } - public static RayPyActor createPyActor(String moduleName, String className, Object obj0, ActorCreationOptions options) { + public static RayPyActor createActor(PyActorClass pyActorClass, Object obj0, ActorCreationOptions options) { Object[] args = new Object[]{obj0}; - return Ray.internal().createPyActor(moduleName, className, args, options); + return Ray.internal().createActor(pyActorClass, args, options); } - public static RayPyActor createPyActor(String moduleName, String className, Object obj0, Object obj1) { + public static RayPyActor createActor(PyActorClass pyActorClass, Object obj0, Object obj1) { Object[] args = new Object[]{obj0, obj1}; - return Ray.internal().createPyActor(moduleName, className, args, null); + return Ray.internal().createActor(pyActorClass, args, null); } - public static RayPyActor createPyActor(String moduleName, String className, Object obj0, Object obj1, ActorCreationOptions options) { + public static RayPyActor createActor(PyActorClass pyActorClass, Object obj0, Object obj1, ActorCreationOptions options) { Object[] args = new Object[]{obj0, obj1}; - return Ray.internal().createPyActor(moduleName, className, args, options); + return Ray.internal().createActor(pyActorClass, args, options); } - public static RayPyActor createPyActor(String moduleName, String className, Object obj0, Object obj1, Object obj2) { + public static RayPyActor createActor(PyActorClass pyActorClass, Object obj0, Object obj1, Object obj2) { Object[] args = new Object[]{obj0, obj1, obj2}; - return Ray.internal().createPyActor(moduleName, className, args, null); + return Ray.internal().createActor(pyActorClass, args, null); } - public static RayPyActor createPyActor(String moduleName, String className, Object obj0, Object obj1, Object obj2, ActorCreationOptions options) { + public static RayPyActor createActor(PyActorClass pyActorClass, Object obj0, Object obj1, Object obj2, ActorCreationOptions options) { Object[] args = new Object[]{obj0, obj1, obj2}; - return Ray.internal().createPyActor(moduleName, className, args, options); + return Ray.internal().createActor(pyActorClass, args, options); } - public static RayPyActor createPyActor(String moduleName, String className, Object obj0, Object obj1, Object obj2, Object obj3) { + public static RayPyActor createActor(PyActorClass pyActorClass, Object obj0, Object obj1, Object obj2, Object obj3) { Object[] args = new Object[]{obj0, obj1, obj2, obj3}; - return Ray.internal().createPyActor(moduleName, className, args, null); + return Ray.internal().createActor(pyActorClass, args, null); } - public static RayPyActor createPyActor(String moduleName, String className, Object obj0, Object obj1, Object obj2, Object obj3, ActorCreationOptions options) { + public static RayPyActor createActor(PyActorClass pyActorClass, Object obj0, Object obj1, Object obj2, Object obj3, ActorCreationOptions options) { Object[] args = new Object[]{obj0, obj1, obj2, obj3}; - return Ray.internal().createPyActor(moduleName, className, args, options); + return Ray.internal().createActor(pyActorClass, args, options); } - public static RayPyActor createPyActor(String moduleName, String className, Object obj0, Object obj1, Object obj2, Object obj3, Object obj4) { + public static RayPyActor createActor(PyActorClass pyActorClass, Object obj0, Object obj1, Object obj2, Object obj3, Object obj4) { Object[] args = new Object[]{obj0, obj1, obj2, obj3, obj4}; - return Ray.internal().createPyActor(moduleName, className, args, null); + return Ray.internal().createActor(pyActorClass, args, null); } - public static RayPyActor createPyActor(String moduleName, String className, Object obj0, Object obj1, Object obj2, Object obj3, Object obj4, ActorCreationOptions options) { + public static RayPyActor createActor(PyActorClass pyActorClass, Object obj0, Object obj1, Object obj2, Object obj3, Object obj4, ActorCreationOptions options) { Object[] args = new Object[]{obj0, obj1, obj2, obj3, obj4}; - return Ray.internal().createPyActor(moduleName, className, args, options); + return Ray.internal().createActor(pyActorClass, args, options); } - public static RayPyActor createPyActor(String moduleName, String className, Object obj0, Object obj1, Object obj2, Object obj3, Object obj4, Object obj5) { + public static RayPyActor createActor(PyActorClass pyActorClass, Object obj0, Object obj1, Object obj2, Object obj3, Object obj4, Object obj5) { Object[] args = new Object[]{obj0, obj1, obj2, obj3, obj4, obj5}; - return Ray.internal().createPyActor(moduleName, className, args, null); + return Ray.internal().createActor(pyActorClass, args, null); } - public static RayPyActor createPyActor(String moduleName, String className, Object obj0, Object obj1, Object obj2, Object obj3, Object obj4, Object obj5, ActorCreationOptions options) { + public static RayPyActor createActor(PyActorClass pyActorClass, Object obj0, Object obj1, Object obj2, Object obj3, Object obj4, Object obj5, ActorCreationOptions options) { Object[] args = new Object[]{obj0, obj1, obj2, obj3, obj4, obj5}; - return Ray.internal().createPyActor(moduleName, className, args, options); + return Ray.internal().createActor(pyActorClass, args, options); } } diff --git a/java/api/src/main/java/org/ray/api/function/PyActorClass.java b/java/api/src/main/java/org/ray/api/function/PyActorClass.java new file mode 100644 index 000000000..83ae1b968 --- /dev/null +++ b/java/api/src/main/java/org/ray/api/function/PyActorClass.java @@ -0,0 +1,36 @@ +package org.ray.api.function; + +/** + * A class that represents a Python actor class. + * + *
+ * example_package/
+ * ├──__init__.py
+ * └──example_module.py
+ *
+ * in example_module.py there is an actor class A.
+ *
+ * \@ray.remote
+ * class A(object):
+ *     def __init__(self, x):
+ *         self.x = x
+ *
+ * we can create this Python actor from Java:
+ *
+ * {@code
+ * RayPyActor actor = Ray.createActor(new PyActorClass("example_package.example_module", "A"),
+ *                                    "the value for x");
+ * }
+ * 
+ */ +public class PyActorClass { + // The full module name of this actor class + public final String moduleName; + // The name of this actor class + public final String className; + + public PyActorClass(String moduleName, String className) { + this.moduleName = moduleName; + this.className = className; + } +} diff --git a/java/api/src/main/java/org/ray/api/function/PyActorMethod.java b/java/api/src/main/java/org/ray/api/function/PyActorMethod.java new file mode 100644 index 000000000..c41267f6a --- /dev/null +++ b/java/api/src/main/java/org/ray/api/function/PyActorMethod.java @@ -0,0 +1,42 @@ +package org.ray.api.function; + +/** + * A class that represents a method of a Python actor. + * + * Note, information about the actor will be inferred from the actor handle, + * so it's not specified in this class. + * + *
+ * there is a Python actor class A.
+ *
+ * \@ray.remote
+ * class A(object):
+ *     def foo(self):
+ *         return "Hello world!"
+ *
+ * suppose we have got the Python actor class A's handle in Java
+ *
+ * {@code
+ * RayPyActor actor = ...; // returned from Ray.createActor or passed from Python
+ * }
+ *
+ * then we can call the actor method:
+ *
+ * {@code
+ * // A.foo returns a string, so we have to set the returnType to String.class
+ * RayObject res = actor.call(new PyActorMethod<>("foo", String.class));
+ * String x = res.get();
+ * }
+ * 
+ */ +public class PyActorMethod { + // The name of this actor method + public final String methodName; + // Type of the return value of this actor method + public final Class returnType; + + public PyActorMethod(String methodName, Class returnType) { + this.methodName = methodName; + this.returnType = returnType; + } +} diff --git a/java/api/src/main/java/org/ray/api/function/PyRemoteFunction.java b/java/api/src/main/java/org/ray/api/function/PyRemoteFunction.java new file mode 100644 index 000000000..626c8e9bd --- /dev/null +++ b/java/api/src/main/java/org/ray/api/function/PyRemoteFunction.java @@ -0,0 +1,47 @@ +package org.ray.api.function; + +/** + * A class that represents a Python remote function. + * + *
+ * example_package/
+ * ├──__init__.py
+ * └──example_module.py
+ *
+ * in example_module.py there is a function.
+ *
+ * \@ray.remote
+ * def bar(v):
+ *     return v
+ *
+ * then we can call the Python function bar:
+ *
+ * {@code
+ * // bar returns input, so we have to set the returnType to int.class if bar accepts an int
+ * RayObject res = actor.call(
+ *    new PyRemoteFunction<>("example_package.example_module", "bar", Integer.class),
+ *    1);
+ * Integer value = res.get();
+ *
+ * // bar returns input, so we have to set the returnType to String.class if bar accepts a string
+ * RayObject res = actor.call(
+ *    new PyRemoteFunction<>("example_package.example_module", "bar", String.class),
+ *    "Hello world!");
+ * String value = res.get();
+ * }
+ * 
+ */ +public class PyRemoteFunction { + // The full module name of this function + public final String moduleName; + // The name of this function + public final String functionName; + // Type of the return value of this function + public final Class returnType; + + public PyRemoteFunction(String moduleName, String functionName, Class returnType) { + this.moduleName = moduleName; + this.functionName = functionName; + this.returnType = returnType; + } +} diff --git a/java/api/src/main/java/org/ray/api/runtime/RayRuntime.java b/java/api/src/main/java/org/ray/api/runtime/RayRuntime.java index 29006e535..308f135b9 100644 --- a/java/api/src/main/java/org/ray/api/runtime/RayRuntime.java +++ b/java/api/src/main/java/org/ray/api/runtime/RayRuntime.java @@ -7,6 +7,9 @@ import org.ray.api.RayActor; import org.ray.api.RayObject; import org.ray.api.RayPyActor; import org.ray.api.WaitResult; +import org.ray.api.function.PyActorClass; +import org.ray.api.function.PyActorMethod; +import org.ray.api.function.PyRemoteFunction; import org.ray.api.function.RayFunc; import org.ray.api.id.ObjectId; import org.ray.api.id.UniqueId; @@ -95,15 +98,35 @@ public interface RayRuntime { */ RayObject call(RayFunc func, Object[] args, CallOptions options); + /** + * Invoke a remote Python function. + * + * @param pyRemoteFunction The Python function. + * @param args Arguments of the function. + * @param options The options for this call. + * @return The result object. + */ + RayObject call(PyRemoteFunction pyRemoteFunction, Object[] args, CallOptions options); + /** * Invoke a remote function on an actor. * - * @param func The remote function to run, it must be a method of the given actor. * @param actor A handle to the actor. + * @param func The remote function to run, it must be a method of the given actor. * @param args The arguments of the remote function. * @return The result object. */ - RayObject callActor(RayFunc func, RayActor actor, Object[] args); + RayObject callActor(RayActor actor, RayFunc func, Object[] args); + + /** + * Invoke a remote Python function on an actor. + * + * @param pyActor A handle to the actor. + * @param pyActorMethod The actor method. + * @param args Arguments of the function. + * @return The result object. + */ + RayObject callActor(RayPyActor pyActor, PyActorMethod pyActorMethod, Object[] args); /** * Create an actor on a remote node. @@ -117,40 +140,18 @@ public interface RayRuntime { RayActor createActor(RayFunc actorFactoryFunc, Object[] args, ActorCreationOptions options); - RuntimeContext getRuntimeContext(); - - /** - * Invoke a remote Python function. - * - * @param moduleName Module name of the Python function. - * @param functionName Name of the Python function. - * @param args Arguments of the function. - * @param options The options for this call. - * @return The result object. - */ - RayObject callPy(String moduleName, String functionName, Object[] args, CallOptions options); - - /** - * Invoke a remote Python function on an actor. - * - * @param pyActor A handle to the actor. - * @param functionName Name of the actor method. - * @param args Arguments of the function. - * @return The result object. - */ - RayObject callPyActor(RayPyActor pyActor, String functionName, Object[] args); - /** * Create a Python actor on a remote node. * - * @param moduleName Module name of the Python actor class. - * @param className Name of the Python actor class. + * @param pyActorClass The Python actor class. * @param args Arguments of the actor constructor. * @param options The options for creating actor. * @return A handle to the actor. */ - RayPyActor createPyActor(String moduleName, String className, Object[] args, - ActorCreationOptions options); + RayPyActor createActor(PyActorClass pyActorClass, Object[] args, + ActorCreationOptions options); + + RuntimeContext getRuntimeContext(); Object getAsyncContext(); diff --git a/java/runtime/src/main/java/org/ray/runtime/AbstractRayRuntime.java b/java/runtime/src/main/java/org/ray/runtime/AbstractRayRuntime.java index d8d85977b..ffdf7992d 100644 --- a/java/runtime/src/main/java/org/ray/runtime/AbstractRayRuntime.java +++ b/java/runtime/src/main/java/org/ray/runtime/AbstractRayRuntime.java @@ -11,6 +11,9 @@ import org.ray.api.RayObject; import org.ray.api.RayPyActor; import org.ray.api.WaitResult; import org.ray.api.exception.RayException; +import org.ray.api.function.PyActorClass; +import org.ray.api.function.PyActorMethod; +import org.ray.api.function.PyRemoteFunction; import org.ray.api.function.RayFunc; import org.ray.api.function.RayFuncVoid; import org.ray.api.id.ObjectId; @@ -98,7 +101,19 @@ public abstract class AbstractRayRuntime implements RayRuntime { } @Override - public RayObject callActor(RayFunc func, RayActor actor, Object[] args) { + public RayObject call(PyRemoteFunction pyRemoteFunction, Object[] args, + CallOptions options) { + checkPyArguments(args); + PyFunctionDescriptor functionDescriptor = new PyFunctionDescriptor( + pyRemoteFunction.moduleName, + "", + pyRemoteFunction.functionName); + // Python functions always have a return value, even if it's `None`. + return callNormalFunction(functionDescriptor, args, /*numReturns=*/1, options); + } + + @Override + public RayObject callActor(RayActor actor, RayFunc func, Object[] args) { FunctionDescriptor functionDescriptor = functionManager.getFunction(workerContext.getCurrentJobId(), func) .functionDescriptor; @@ -106,6 +121,15 @@ public abstract class AbstractRayRuntime implements RayRuntime { return callActorFunction(actor, functionDescriptor, args, numReturns); } + @Override + public RayObject callActor(RayPyActor pyActor, PyActorMethod pyActorMethod, Object... args) { + checkPyArguments(args); + PyFunctionDescriptor functionDescriptor = new PyFunctionDescriptor(pyActor.getModuleName(), + pyActor.getClassName(), pyActorMethod.methodName); + // Python functions always have a return value, even if it's `None`. + return callActorFunction(pyActor, functionDescriptor, args, /*numReturns=*/1); + } + @Override @SuppressWarnings("unchecked") public RayActor createActor(RayFunc actorFactoryFunc, @@ -116,6 +140,17 @@ public abstract class AbstractRayRuntime implements RayRuntime { return (RayActor) createActorImpl(functionDescriptor, args, options); } + @Override + public RayPyActor createActor(PyActorClass pyActorClass, Object[] args, + ActorCreationOptions options) { + checkPyArguments(args); + PyFunctionDescriptor functionDescriptor = new PyFunctionDescriptor( + pyActorClass.moduleName, + pyActorClass.className, + PYTHON_INIT_METHOD_NAME); + return (RayPyActor) createActorImpl(functionDescriptor, args, options); + } + private void checkPyArguments(Object[] args) { for (Object arg : args) { Preconditions.checkArgument( @@ -125,34 +160,6 @@ public abstract class AbstractRayRuntime implements RayRuntime { } } - @Override - public RayObject callPy(String moduleName, String functionName, Object[] args, - CallOptions options) { - checkPyArguments(args); - PyFunctionDescriptor functionDescriptor = new PyFunctionDescriptor(moduleName, "", - functionName); - // Python functions always have a return value, even if it's `None`. - return callNormalFunction(functionDescriptor, args, /*numReturns=*/1, options); - } - - @Override - public RayObject callPyActor(RayPyActor pyActor, String functionName, Object... args) { - checkPyArguments(args); - PyFunctionDescriptor functionDescriptor = new PyFunctionDescriptor(pyActor.getModuleName(), - pyActor.getClassName(), functionName); - // Python functions always have a return value, even if it's `None`. - return callActorFunction(pyActor, functionDescriptor, args, /*numReturns=*/1); - } - - @Override - public RayPyActor createPyActor(String moduleName, String className, Object[] args, - ActorCreationOptions options) { - checkPyArguments(args); - PyFunctionDescriptor functionDescriptor = new PyFunctionDescriptor(moduleName, className, - PYTHON_INIT_METHOD_NAME); - return (RayPyActor) createActorImpl(functionDescriptor, args, options); - } - @Override public Runnable wrapRunnable(Runnable runnable) { return runnable; diff --git a/java/runtime/src/main/java/org/ray/runtime/RayMultiWorkerNativeRuntime.java b/java/runtime/src/main/java/org/ray/runtime/RayMultiWorkerNativeRuntime.java index 535c0a6b3..045da3a31 100644 --- a/java/runtime/src/main/java/org/ray/runtime/RayMultiWorkerNativeRuntime.java +++ b/java/runtime/src/main/java/org/ray/runtime/RayMultiWorkerNativeRuntime.java @@ -8,6 +8,9 @@ import org.ray.api.RayActor; import org.ray.api.RayObject; import org.ray.api.RayPyActor; import org.ray.api.WaitResult; +import org.ray.api.function.PyActorClass; +import org.ray.api.function.PyActorMethod; +import org.ray.api.function.PyRemoteFunction; import org.ray.api.function.RayFunc; import org.ray.api.id.ObjectId; import org.ray.api.id.UniqueId; @@ -150,8 +153,19 @@ public class RayMultiWorkerNativeRuntime implements RayRuntime { } @Override - public RayObject callActor(RayFunc func, RayActor actor, Object[] args) { - return getCurrentRuntime().callActor(func, actor, args); + public RayObject call(PyRemoteFunction pyRemoteFunction, Object[] args, + CallOptions options) { + return getCurrentRuntime().call(pyRemoteFunction, args, options); + } + + @Override + public RayObject callActor(RayActor actor, RayFunc func, Object[] args) { + return getCurrentRuntime().callActor(actor, func, args); + } + + @Override + public RayObject callActor(RayPyActor pyActor, PyActorMethod pyActorMethod, Object[] args) { + return getCurrentRuntime().callActor(pyActor, pyActorMethod, args); } @Override @@ -160,28 +174,17 @@ public class RayMultiWorkerNativeRuntime implements RayRuntime { return getCurrentRuntime().createActor(actorFactoryFunc, args, options); } + @Override + public RayPyActor createActor(PyActorClass pyActorClass, Object[] args, + ActorCreationOptions options) { + return getCurrentRuntime().createActor(pyActorClass, args, options); + } + @Override public RuntimeContext getRuntimeContext() { return getCurrentRuntime().getRuntimeContext(); } - @Override - public RayObject callPy(String moduleName, String functionName, Object[] args, - CallOptions options) { - return getCurrentRuntime().callPy(moduleName, functionName, args, options); - } - - @Override - public RayObject callPyActor(RayPyActor pyActor, String functionName, Object[] args) { - return getCurrentRuntime().callPyActor(pyActor, functionName, args); - } - - @Override - public RayPyActor createPyActor(String moduleName, String className, Object[] args, - ActorCreationOptions options) { - return getCurrentRuntime().createPyActor(moduleName, className, args, options); - } - @Override public Object getAsyncContext() { return getCurrentRuntime(); diff --git a/java/runtime/src/main/java/org/ray/runtime/util/generator/RayCallGenerator.java b/java/runtime/src/main/java/org/ray/runtime/util/generator/RayCallGenerator.java index c2bfcffcd..e85604b54 100644 --- a/java/runtime/src/main/java/org/ray/runtime/util/generator/RayCallGenerator.java +++ b/java/runtime/src/main/java/org/ray/runtime/util/generator/RayCallGenerator.java @@ -23,6 +23,8 @@ public class RayCallGenerator extends BaseGenerator { newLine(""); newLine("package org.ray.api;"); newLine(""); + newLine("import org.ray.api.function.PyActorClass;"); + newLine("import org.ray.api.function.PyRemoteFunction;"); for (int i = 0; i <= MAX_PARAMETERS; i++) { newLine("import org.ray.api.function.RayFunc" + i + ";"); } @@ -112,6 +114,8 @@ public class RayCallGenerator extends BaseGenerator { newLine(""); newLine("package org.ray.api;"); newLine(""); + newLine("import org.ray.api.function.PyActorMethod;"); + newLine(""); newLine("/**"); newLine(" * This class provides type-safe interfaces for remote actor calls."); newLine(" **/"); @@ -216,11 +220,11 @@ public class RayCallGenerator extends BaseGenerator { newLine(2, String.format("Object[] args = new Object[]{%s};", args)); // 5) Construct the third line. - String callFuncArgs = "f, "; + String callFuncArgs = ""; if (forActor) { callFuncArgs += "(RayActor) this, "; } - callFuncArgs += "args, "; + callFuncArgs += "f, args, "; callFuncArgs += forActor ? "" : hasOptionsParam ? "options, " : "null, "; callFuncArgs = callFuncArgs.substring(0, callFuncArgs.length() - 2); newLine(2, String.format("%sRay.internal().%s(%s);", @@ -231,12 +235,12 @@ public class RayCallGenerator extends BaseGenerator { } /** - * Build `Ray.callPy`, `Ray.createPyActor` and `actor.call` methods with + * Build `Ray.call`, `Ray.createActor` and `actor.call` methods with * the given number of parameters. * * @param numParameters the number of parameters - * @param forActor Build `actor.call` when true, otherwise build `Ray.callPy`. - * @param forActorCreation Build `Ray.createPyActor` when true, otherwise build `Ray.callPy`. + * @param forActor Build `actor.call` when true, otherwise build `Ray.call`. + * @param forActorCreation Build `Ray.createActor` when true, otherwise build `Ray.call`. * @param hasOptionsParam Add ActorCreationOptions if forActorCreation is true; * Add CallOptions if forActorCreation is false; * No additional param if hasOptionsParam is false. @@ -261,14 +265,14 @@ public class RayCallGenerator extends BaseGenerator { String paramPrefix = ""; String funcArgs = ""; if (forActorCreation) { - paramPrefix += "String moduleName, String className"; - funcArgs += "moduleName, className"; + paramPrefix += "PyActorClass pyActorClass"; + funcArgs += "pyActorClass"; } else if (forActor) { - paramPrefix += "String functionName"; - funcArgs += "functionName"; + paramPrefix += "PyActorMethod pyActorMethod"; + funcArgs += "pyActorMethod"; } else { - paramPrefix += "String moduleName, String functionName"; - funcArgs += "moduleName, functionName"; + paramPrefix += "PyRemoteFunction pyRemoteFunction"; + funcArgs += "pyRemoteFunction"; } if (numParameters > 0) { paramPrefix += ", "; @@ -292,14 +296,15 @@ public class RayCallGenerator extends BaseGenerator { } } - String returnType = !forActorCreation ? "RayObject" : "RayPyActor"; - String funcName = forActorCreation ? "createPyActor" : forActor ? "call" : "callPy"; - String internalCallFunc = forActorCreation ? "createPyActor" : - forActor ? "callPyActor" : "callPy"; + String genericType = forActorCreation ? "" : " "; + String returnType = !forActorCreation ? "RayObject" : "RayPyActor"; + String funcName = forActorCreation ? "createActor" : "call"; + String internalCallFunc = forActorCreation ? "createActor" : + forActor ? "callActor" : "call"; funcArgs += ", args"; // Method signature. newLine(1, String.format( - "%s %s %s(%s%s) {", modifiers, + "%s%s %s %s(%s%s) {", modifiers, genericType, returnType, funcName, paramPrefix + paramList, optionsParam )); // Method body. diff --git a/java/test/src/main/java/org/ray/api/test/CrossLanguageInvocationTest.java b/java/test/src/main/java/org/ray/api/test/CrossLanguageInvocationTest.java index cdaa80348..8715e581c 100644 --- a/java/test/src/main/java/org/ray/api/test/CrossLanguageInvocationTest.java +++ b/java/test/src/main/java/org/ray/api/test/CrossLanguageInvocationTest.java @@ -11,6 +11,9 @@ import org.ray.api.Ray; import org.ray.api.RayActor; import org.ray.api.RayObject; import org.ray.api.RayPyActor; +import org.ray.api.function.PyActorClass; +import org.ray.api.function.PyActorMethod; +import org.ray.api.function.PyRemoteFunction; import org.ray.runtime.actor.NativeRayActor; import org.ray.runtime.actor.NativeRayPyActor; import org.slf4j.Logger; @@ -48,26 +51,34 @@ public class CrossLanguageInvocationTest extends BaseMultiLanguageTest { @Test public void testCallingPythonFunction() { - RayObject res = Ray.callPy(PYTHON_MODULE, "py_func", "hello".getBytes()); + RayObject res = Ray.call( + new PyRemoteFunction<>(PYTHON_MODULE, "py_func", byte[].class), + "hello".getBytes()); Assert.assertEquals(res.get(), "Response from Python: hello".getBytes()); } @Test public void testPythonCallJavaFunction() { - RayObject res = Ray.callPy(PYTHON_MODULE, "py_func_call_java_function", "hello".getBytes()); + RayObject res = Ray.call( + new PyRemoteFunction<>(PYTHON_MODULE, "py_func_call_java_function", byte[].class), + "hello".getBytes()); Assert.assertEquals(res.get(), "[Python]py_func -> [Java]bytesEcho -> hello".getBytes()); } @Test public void testCallingPythonActor() { - RayPyActor actor = Ray.createPyActor(PYTHON_MODULE, "Counter", "1".getBytes()); - RayObject res = actor.call("increase", "1".getBytes()); + RayPyActor actor = Ray.createActor(new PyActorClass(PYTHON_MODULE, "Counter"), "1".getBytes()); + RayObject res = actor.call( + new PyActorMethod<>("increase", byte[].class), + "1".getBytes()); Assert.assertEquals(res.get(), "2".getBytes()); } @Test public void testPythonCallJavaActor() { - RayObject res = Ray.callPy(PYTHON_MODULE, "py_func_call_java_actor", "1".getBytes()); + RayObject res = Ray.call( + new PyRemoteFunction<>(PYTHON_MODULE, "py_func_call_java_actor", byte[].class), + "1".getBytes()); Assert.assertEquals(res.get(), "Counter1".getBytes()); } @@ -76,7 +87,8 @@ public class CrossLanguageInvocationTest extends BaseMultiLanguageTest { public void testPassActorHandleFromPythonToJava() { // Call a python function which creates a python actor // and pass the actor handle to callPythonActorHandle. - RayObject res = Ray.callPy(PYTHON_MODULE, "py_func_pass_python_actor_handle"); + RayObject res = Ray.call( + new PyRemoteFunction<>(PYTHON_MODULE, "py_func_pass_python_actor_handle", byte[].class)); Assert.assertEquals(res.get(), "3".getBytes()); } @@ -86,15 +98,22 @@ public class CrossLanguageInvocationTest extends BaseMultiLanguageTest { RayActor javaActor = Ray.createActor(TestActor::new, "1".getBytes()); Preconditions.checkState(javaActor instanceof NativeRayActor); byte[] actorHandleBytes = ((NativeRayActor) javaActor).toBytes(); - RayObject res = Ray.callPy(PYTHON_MODULE, - "py_func_call_java_actor_from_handle", actorHandleBytes); + RayObject res = Ray.call( + new PyRemoteFunction<>(PYTHON_MODULE, + "py_func_call_java_actor_from_handle", + byte[].class), + actorHandleBytes); Assert.assertEquals(res.get(), "12".getBytes()); // Create a python actor, and pass actor handle to python. - RayPyActor pyActor = Ray.createPyActor(PYTHON_MODULE, "Counter", "1".getBytes()); + RayPyActor pyActor = Ray.createActor( + new PyActorClass(PYTHON_MODULE, "Counter"), "1".getBytes()); Preconditions.checkState(pyActor instanceof NativeRayActor); actorHandleBytes = ((NativeRayActor) pyActor).toBytes(); - res = Ray.callPy(PYTHON_MODULE, - "py_func_call_python_actor_from_handle", actorHandleBytes); + res = Ray.call( + new PyRemoteFunction<>(PYTHON_MODULE, + "py_func_call_python_actor_from_handle", + byte[].class), + actorHandleBytes); Assert.assertEquals(res.get(), "3".getBytes()); } @@ -107,10 +126,12 @@ public class CrossLanguageInvocationTest extends BaseMultiLanguageTest { public static byte[] callPythonActorHandle(byte[] value) { // This function will be called from test_cross_language_invocation.py - NativeRayPyActor actor = (NativeRayPyActor)NativeRayActor.fromBytes(value); - RayObject res = actor.call("increase", "1".getBytes()); + NativeRayPyActor actor = (NativeRayPyActor) NativeRayActor.fromBytes(value); + RayObject res = actor.call( + new PyActorMethod<>("increase", byte[].class), + "1".getBytes()); Assert.assertEquals(res.get(), "3".getBytes()); - return (byte[])res.get(); + return (byte[]) res.get(); } public static class TestActor { diff --git a/java/test/src/main/java/org/ray/api/test/RaySerializerTest.java b/java/test/src/main/java/org/ray/api/test/RaySerializerTest.java index 2080a250c..398d1277c 100644 --- a/java/test/src/main/java/org/ray/api/test/RaySerializerTest.java +++ b/java/test/src/main/java/org/ray/api/test/RaySerializerTest.java @@ -3,6 +3,7 @@ package org.ray.api.test; import org.ray.api.Ray; import org.ray.api.RayPyActor; import org.ray.api.TestUtils; +import org.ray.api.function.PyActorClass; import org.ray.runtime.context.WorkerContext; import org.ray.runtime.object.NativeRayObject; import org.ray.runtime.object.ObjectSerializer; @@ -13,7 +14,7 @@ public class RaySerializerTest extends BaseMultiLanguageTest { @Test public void testSerializePyActor() { - RayPyActor pyActor = Ray.createPyActor("test", "RaySerializerTest"); + RayPyActor pyActor = Ray.createActor(new PyActorClass("test", "RaySerializerTest")); WorkerContext workerContext = TestUtils.getRuntime().getWorkerContext(); NativeRayObject nativeRayObject = ObjectSerializer.serialize(pyActor); RayPyActor result = (RayPyActor) ObjectSerializer diff --git a/streaming/java/streaming-runtime/src/main/java/org/ray/streaming/runtime/schedule/JobSchedulerImpl.java b/streaming/java/streaming-runtime/src/main/java/org/ray/streaming/runtime/schedule/JobSchedulerImpl.java index 0b4900a84..5d827e380 100644 --- a/streaming/java/streaming-runtime/src/main/java/org/ray/streaming/runtime/schedule/JobSchedulerImpl.java +++ b/streaming/java/streaming-runtime/src/main/java/org/ray/streaming/runtime/schedule/JobSchedulerImpl.java @@ -8,6 +8,7 @@ import org.ray.api.Ray; import org.ray.api.RayActor; import org.ray.api.RayObject; import org.ray.api.RayPyActor; +import org.ray.api.function.PyActorMethod; import org.ray.streaming.api.Language; import org.ray.streaming.jobgraph.JobGraph; import org.ray.streaming.runtime.core.graph.ExecutionGraph; @@ -68,7 +69,8 @@ public class JobSchedulerImpl implements JobScheduler { case PYTHON: byte[] workerContextBytes = buildPythonWorkerContext( taskId, executionGraphPb, jobConfig); - waits.add(((RayPyActor)worker).call("init", workerContextBytes)); + waits.add(((RayPyActor)worker).call(new PyActorMethod("init", Object.class), + workerContextBytes)); break; default: throw new UnsupportedOperationException( diff --git a/streaming/java/streaming-runtime/src/main/java/org/ray/streaming/runtime/schedule/TaskAssignerImpl.java b/streaming/java/streaming-runtime/src/main/java/org/ray/streaming/runtime/schedule/TaskAssignerImpl.java index 43c12eafc..1b541e02a 100644 --- a/streaming/java/streaming-runtime/src/main/java/org/ray/streaming/runtime/schedule/TaskAssignerImpl.java +++ b/streaming/java/streaming-runtime/src/main/java/org/ray/streaming/runtime/schedule/TaskAssignerImpl.java @@ -6,6 +6,7 @@ import java.util.List; import java.util.Map; import org.ray.api.BaseActor; import org.ray.api.Ray; +import org.ray.api.function.PyActorClass; import org.ray.streaming.jobgraph.JobEdge; import org.ray.streaming.jobgraph.JobGraph; import org.ray.streaming.jobgraph.JobVertex; @@ -61,8 +62,8 @@ public class TaskAssignerImpl implements TaskAssigner { private BaseActor createWorker(JobVertex jobVertex) { switch (jobVertex.getLanguage()) { case PYTHON: - return Ray.createPyActor( - "ray.streaming.runtime.worker", "JobWorker"); + return Ray.createActor( + new PyActorClass("ray.streaming.runtime.worker", "JobWorker")); case JAVA: return Ray.createActor(JobWorker::new); default: