diff --git a/java/api/src/main/java/org/ray/api/id/ObjectId.java b/java/api/src/main/java/org/ray/api/id/ObjectId.java index 83df2a8ca..4d6cf0976 100644 --- a/java/api/src/main/java/org/ray/api/id/ObjectId.java +++ b/java/api/src/main/java/org/ray/api/id/ObjectId.java @@ -12,8 +12,6 @@ public class ObjectId extends BaseId implements Serializable { public static final int LENGTH = 20; - public static final ObjectId NIL = genNil(); - /** * Create an ObjectId from a ByteBuffer. */ @@ -21,21 +19,17 @@ public class ObjectId extends BaseId implements Serializable { return new ObjectId(byteBuffer2Bytes(bb)); } - /** - * Generate a nil ObjectId. - */ - private static ObjectId genNil() { - byte[] b = new byte[LENGTH]; - Arrays.fill(b, (byte) 0xFF); - return new ObjectId(b); - } - /** * Generate an ObjectId with random value. */ public static ObjectId fromRandom() { + // This is tightly coupled with ObjectID definition in C++. If that changes, + // this must be changed as well. + // The following logic should be kept consistent with `ObjectID::FromRandom` in + // C++. byte[] b = new byte[LENGTH]; new Random().nextBytes(b); + Arrays.fill(b, TaskId.LENGTH, LENGTH, (byte) 0); return new ObjectId(b); } diff --git a/src/ray/core_worker/object_interface.cc b/src/ray/core_worker/object_interface.cc index 81a42a7ee..cb4e68a41 100644 --- a/src/ray/core_worker/object_interface.cc +++ b/src/ray/core_worker/object_interface.cc @@ -28,7 +28,7 @@ void GroupObjectIdsByStoreProvider( // to whether it's from direct actor call before we can choose memory store provider. if (object_id.IsReturnObject() && object_id.GetTransportType() == - static_cast(TaskTransportType::DIRECT_ACTOR)) { + static_cast(TaskTransportType::DIRECT_ACTOR)) { type = StoreProviderType::MEMORY; } @@ -51,13 +51,16 @@ CoreWorkerObjectInterface::CoreWorkerObjectInterface( Status CoreWorkerObjectInterface::Put(const RayObject &object, ObjectID *object_id) { ObjectID put_id = ObjectID::ForPut(worker_context_.GetCurrentTaskID(), worker_context_.GetNextPutIndex(), - /*transport_type=*/0); + static_cast(TaskTransportType::RAYLET)); *object_id = put_id; return Put(object, put_id); } Status CoreWorkerObjectInterface::Put(const RayObject &object, const ObjectID &object_id) { + RAY_CHECK(object_id.GetTransportType() == + static_cast(TaskTransportType::RAYLET)) + << "Invalid transport type flag in object ID: " << object_id.GetTransportType(); return store_providers_[StoreProviderType::PLASMA]->Put(object, object_id); }