@@ -388,22 +388,6 @@ static uint64_t compute_object_hash(const ObjectBuffer& obj_buffer) {
388388 return XXH64_digest (&hash_state);
389389}
390390
391- bool plasma_compute_object_hash (
392- PlasmaClient* conn, ObjectID object_id, unsigned char * digest) {
393- // Get the plasma object data. We pass in a timeout of 0 to indicate that
394- // the operation should timeout immediately.
395- ObjectBuffer object_buffer;
396- ARROW_CHECK_OK (conn->Get (&object_id, 1 , 0 , &object_buffer));
397- // If the object was not retrieved, return false.
398- if (object_buffer.data_size == -1 ) { return false ; }
399- // Compute the hash.
400- uint64_t hash = compute_object_hash (object_buffer);
401- memcpy (digest, &hash, sizeof (hash));
402- // Release the plasma object.
403- ARROW_CHECK_OK (conn->Release (object_id));
404- return true ;
405- }
406-
407391Status PlasmaClient::Seal (const ObjectID& object_id) {
408392 // Make sure this client has a reference to the object before sending the
409393 // request to Plasma.
@@ -415,7 +399,7 @@ Status PlasmaClient::Seal(const ObjectID& object_id) {
415399 object_entry->second ->is_sealed = true ;
416400 // / Send the seal request to Plasma.
417401 static unsigned char digest[kDigestSize ];
418- ARROW_CHECK ( plasma_compute_object_hash ( this , object_id, &digest[0 ]));
402+ RETURN_NOT_OK ( Hash ( object_id, &digest[0 ]));
419403 RETURN_NOT_OK (SendSealRequest (store_conn_, object_id, &digest[0 ]));
420404 // We call PlasmaClient::Release to decrement the number of instances of this
421405 // object
@@ -441,6 +425,22 @@ Status PlasmaClient::Evict(int64_t num_bytes, int64_t& num_bytes_evicted) {
441425 return ReadEvictReply (buffer.data (), num_bytes_evicted);
442426}
443427
428+ Status PlasmaClient::Hash (const ObjectID& object_id, uint8_t * digest) {
429+ // Get the plasma object data. We pass in a timeout of 0 to indicate that
430+ // the operation should timeout immediately.
431+ ObjectBuffer object_buffer;
432+ RETURN_NOT_OK (Get (&object_id, 1 , 0 , &object_buffer));
433+ // If the object was not retrieved, return false.
434+ if (object_buffer.data_size == -1 ) {
435+ return Status::PlasmaObjectNonexistent (" Object not found" );
436+ }
437+ // Compute the hash.
438+ uint64_t hash = compute_object_hash (object_buffer);
439+ memcpy (digest, &hash, sizeof (hash));
440+ // Release the plasma object.
441+ return Release (object_id);
442+ }
443+
444444Status PlasmaClient::Subscribe (int * fd) {
445445 int sock[2 ];
446446 // Create a non-blocking socket pair. This will only be used to send
@@ -461,6 +461,25 @@ Status PlasmaClient::Subscribe(int* fd) {
461461 return Status::OK ();
462462}
463463
464+ Status PlasmaClient::GetNotification (int fd, ObjectID *object_id, int64_t * data_size, int64_t * metadata_size) {
465+ uint8_t * notification = read_message_async (fd);
466+ if (notification == NULL ) {
467+ return Status::IOError (" Failed to read object notification from Plasma socket" );
468+ }
469+ auto object_info = flatbuffers::GetRoot<ObjectInfo>(notification);
470+ ARROW_CHECK (object_info->object_id ()->size () == sizeof (ObjectID));
471+ memcpy (object_id, object_info->object_id ()->data (), sizeof (ObjectID));
472+ if (object_info->is_deletion ()) {
473+ *data_size = -1 ;
474+ *metadata_size = -1 ;
475+ } else {
476+ *data_size = object_info->data_size ();
477+ *metadata_size = object_info->metadata_size ();
478+ }
479+ delete[] notification;
480+ return Status::OK ();
481+ }
482+
464483Status PlasmaClient::Connect (const std::string& store_socket_name,
465484 const std::string& manager_socket_name, int release_delay) {
466485 store_conn_ = connect_ipc_sock_retry (store_socket_name, -1 , -1 );
0 commit comments