-
Notifications
You must be signed in to change notification settings - Fork 4k
ARROW-1927: [Plasma] Add delete function #1427
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
c9984a4
53e24eb
baf82b9
be88990
8b6804e
ce27077
0ca115a
1d76437
424c1b7
c6df5be
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -513,9 +513,20 @@ Status PlasmaClient::Abort(const ObjectID& object_id) { | |
| } | ||
|
|
||
| Status PlasmaClient::Delete(const ObjectID& object_id) { | ||
| // TODO(rkn): In the future, we can use this method to give hints to the | ||
| // eviction policy about when an object will no longer be needed. | ||
| return Status::NotImplemented("PlasmaClient::Delete is not implemented."); | ||
| RETURN_NOT_OK(FlushReleaseHistory()); | ||
| // If the object is in used, client can't send the remove message. | ||
| if (objects_in_use_.count(object_id) > 0) { | ||
| return Status::UnknownError("PlasmaClient::Object is in use."); | ||
| } else { | ||
| // If we don't already have a reference to the object, we can try to remove the object | ||
| RETURN_NOT_OK(SendDeleteRequest(store_conn_, object_id)); | ||
| std::vector<uint8_t> buffer; | ||
| RETURN_NOT_OK(PlasmaReceive(store_conn_, MessageType_PlasmaDeleteReply, &buffer)); | ||
|
||
| ObjectID object_id2; | ||
| DCHECK_GT(buffer.size(), 0); | ||
| RETURN_NOT_OK(ReadDeleteReply(buffer.data(), buffer.size(), &object_id2)); | ||
| return Status::OK(); | ||
| } | ||
| } | ||
|
|
||
| Status PlasmaClient::Evict(int64_t num_bytes, int64_t& num_bytes_evicted) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -102,4 +102,14 @@ void EvictionPolicy::end_object_access(const ObjectID& object_id, | |
| cache_.add(object_id, entry->info.data_size + entry->info.metadata_size); | ||
| } | ||
|
|
||
| void EvictionPolicy::remove_object(const ObjectID& object_id) { | ||
| /* If the object is in the LRU cache, remove it. */ | ||
| cache_.remove(object_id); | ||
|
||
|
|
||
| auto entry = store_info_->objects[object_id].get(); | ||
| int64_t size = entry->info.data_size + entry->info.metadata_size; | ||
| ARROW_CHECK(memory_used_ >= size); | ||
| memory_used_ -= size; | ||
| } | ||
|
|
||
| } // namespace plasma | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -411,6 +411,39 @@ int PlasmaStore::abort_object(const ObjectID& object_id, Client* client) { | |
| } | ||
| } | ||
|
|
||
| int PlasmaStore::delete_object(ObjectID& object_id) { | ||
|
||
| auto entry = get_object_table_entry(&store_info_, object_id); | ||
| // TODO(rkn): This should probably not fail, but should instead throw an | ||
| // error. Maybe we should also support deleting objects that have been | ||
| // created but not sealed. | ||
| if (entry == NULL) { | ||
| // To delete an object it must be in the object table. | ||
| return PlasmaError_ObjectNonexistent; | ||
| } | ||
|
|
||
| if (entry->state != PLASMA_SEALED) { | ||
| // To delete an object it must have been sealed. | ||
| return PlasmaError_ObjectNotSealed; | ||
| } | ||
|
|
||
| if (entry->clients.size() != 0) { | ||
| // To delete an object, there must be no clients currently using it. | ||
| return PlasmaError_ObjectInUse; | ||
| } | ||
|
|
||
| eviction_policy_.remove_object(object_id); | ||
|
|
||
| dlfree(entry->pointer); | ||
| store_info_.objects.erase(object_id); | ||
| // Inform all subscribers that the object has been deleted. | ||
| ObjectInfoT notification; | ||
| notification.object_id = object_id.binary(); | ||
| notification.is_deletion = true; | ||
| push_notification(¬ification); | ||
|
|
||
| return PlasmaError_OK; | ||
| } | ||
|
|
||
| void PlasmaStore::delete_objects(const std::vector<ObjectID>& object_ids) { | ||
| for (const auto& object_id : object_ids) { | ||
| ARROW_LOG(DEBUG) << "deleting object " << object_id.hex(); | ||
|
|
@@ -626,18 +659,23 @@ Status PlasmaStore::process_message(Client* client) { | |
| RETURN_NOT_OK(ReadGetRequest(input, input_size, object_ids_to_get, &timeout_ms)); | ||
| process_get_request(client, object_ids_to_get, timeout_ms); | ||
| } break; | ||
| case MessageType_PlasmaReleaseRequest: | ||
| case MessageType_PlasmaReleaseRequest: { | ||
| RETURN_NOT_OK(ReadReleaseRequest(input, input_size, &object_id)); | ||
| release_object(object_id, client); | ||
| break; | ||
| case MessageType_PlasmaContainsRequest: | ||
| } break; | ||
| case MessageType_PlasmaDeleteRequest: { | ||
| RETURN_NOT_OK(ReadDeleteRequest(input, input_size, &object_id)); | ||
| int error_code = delete_object(object_id); | ||
| HANDLE_SIGPIPE(SendDeleteReply(client->fd, object_id, error_code), client->fd); | ||
| } break; | ||
| case MessageType_PlasmaContainsRequest: { | ||
| RETURN_NOT_OK(ReadContainsRequest(input, input_size, &object_id)); | ||
| if (contains_object(object_id) == OBJECT_FOUND) { | ||
| HANDLE_SIGPIPE(SendContainsReply(client->fd, object_id, 1), client->fd); | ||
| } else { | ||
| HANDLE_SIGPIPE(SendContainsReply(client->fd, object_id, 0), client->fd); | ||
| } | ||
| break; | ||
| } break; | ||
| case MessageType_PlasmaSealRequest: { | ||
| unsigned char digest[kDigestSize]; | ||
| RETURN_NOT_OK(ReadSealRequest(input, input_size, &object_id, &digest[0])); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In
client.hwe should probably clarify the behavior of this method. In particular, if a client callsDelete, that does not guarantee that the object will be deleted. In particular, if the object is in use by another client, then theDeletecall is a no-op, right? Can you mention this in the documentation for this method inclient.h?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it doesn't guarantee the object will be deleted for some reasons.