mirror of
https://github.com/wassname/ray.git
synced 2026-06-28 02:01:24 +08:00
Cross language serialization for primitive types (#7711)
* Cross language serialization for Java and Python * Use strict types when Python serializing * Handle recursive objects in Python; Pin msgpack >= 0.6.0, < 1.0.0 * Disable gc for optimizing msgpack loads * Fix merge bug * Java call Python use returnType; Fix ClassLoaderTest * Fix RayMethodsTest * Fix checkstyle * Fix lint * prepare_args raises exception if try to transfer a non-deserializable object to another language * Fix CrossLanguageInvocationTest.java, Python msgpack treat float as double * Minor fixes * Fix compile error on linux * Fix lint in java/BUILD.bazel * Fix test_failure * Fix lint * Class<?> to Class<T>; Refine metadata bytes. * Rename FST to Fst; sort java dependencies * Change Class<?>[] to Optional<Class<?>>; sort requirements in setup.py * Improve CrossLanguageInvocationTest * Refactor MessagePackSerializer.java * Refactor MessagePackSerializer.java; Refine CrossLanguageInvocationTest.java * Remove unnecessary dependencies for Java; Add getReturnType() for RayFunction in Java * Fix bug * Remove custom cross language type support * Replace Serializer.Meta with MutableBoolean * Remove @SuppressWarnings support from checkstyle.xml; Add null test in CrossLanguageInvocationTest.java * Refine MessagePackSerializer.pack * Ray.get support RayObject as input * Improve comments and error info * Remove classLoader argument from serializer * Separate msgpack from pickle5 in Python * Pair<byte[], MutableBoolean> to Pair<byte[], Boolean> * Remove public static <T> T get(RayObject<T> object), use RayObject.get() instead * Refine test * small fixes Co-authored-by: 刘宝 <po.lb@antfin.com> Co-authored-by: Hao Chen <chenh1024@gmail.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package org.ray.api;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Callable;
|
||||
import org.ray.api.id.ObjectId;
|
||||
@@ -62,23 +63,41 @@ public final class Ray extends RayCall {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an object from the object store.
|
||||
* Get an object by id from the object store.
|
||||
*
|
||||
* @param objectId The ID of the object to get.
|
||||
* @param objectType The type of the object to get.
|
||||
* @return The Java object.
|
||||
*/
|
||||
public static <T> T get(ObjectId objectId) {
|
||||
return runtime.get(objectId);
|
||||
public static <T> T get(ObjectId objectId, Class<T> objectType) {
|
||||
return runtime.get(objectId, objectType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of objects from the object store.
|
||||
* Get a list of objects by ids from the object store.
|
||||
*
|
||||
* @param objectIds The list of object IDs.
|
||||
* @param objectType The type of object.
|
||||
* @return A list of Java objects.
|
||||
*/
|
||||
public static <T> List<T> get(List<ObjectId> objectIds) {
|
||||
return runtime.get(objectIds);
|
||||
public static <T> List<T> get(List<ObjectId> objectIds, Class<T> objectType) {
|
||||
return runtime.get(objectIds, objectType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of objects by RayObjects from the object store.
|
||||
*
|
||||
* @param objectList A list of RayObject to get.
|
||||
* @return A list of Java objects.
|
||||
*/
|
||||
public static <T> List<T> get(List<RayObject<T>> objectList) {
|
||||
List<ObjectId> objectIds = new ArrayList<>();
|
||||
Class<T> objectType = null;
|
||||
for (RayObject<T> o : objectList) {
|
||||
objectIds.add(o.getId());
|
||||
objectType = o.getType();
|
||||
}
|
||||
return runtime.get(objectIds, objectType);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -19,5 +19,10 @@ public interface RayObject<T> {
|
||||
*/
|
||||
ObjectId getId();
|
||||
|
||||
/**
|
||||
* Get the Object type.
|
||||
*/
|
||||
Class<T> getType();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -39,17 +39,19 @@ public interface RayRuntime {
|
||||
* Get an object from the object store.
|
||||
*
|
||||
* @param objectId The ID of the object to get.
|
||||
* @param objectType The type of the object to get.
|
||||
* @return The Java object.
|
||||
*/
|
||||
<T> T get(ObjectId objectId);
|
||||
<T> T get(ObjectId objectId, Class<T> objectType);
|
||||
|
||||
/**
|
||||
* Get a list of objects from the object store.
|
||||
*
|
||||
* @param objectIds The list of object IDs.
|
||||
* @param objectType The type of object.
|
||||
* @return A list of Java objects.
|
||||
*/
|
||||
<T> List<T> get(List<ObjectId> objectIds);
|
||||
<T> List<T> get(List<ObjectId> objectIds, Class<T> objectType);
|
||||
|
||||
/**
|
||||
* Wait for a list of RayObjects to be locally available, until specified number of objects are
|
||||
|
||||
Reference in New Issue
Block a user