mirror of
https://github.com/wassname/ray.git
synced 2026-08-01 12:51:09 +08:00
[Java] ObjectID::fromRandom sets proper flags (#5548)
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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<int>(TaskTransportType::DIRECT_ACTOR)) {
|
||||
static_cast<uint8_t>(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<uint8_t>(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<uint8_t>(TaskTransportType::RAYLET))
|
||||
<< "Invalid transport type flag in object ID: " << object_id.GetTransportType();
|
||||
return store_providers_[StoreProviderType::PLASMA]->Put(object, object_id);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user