def remove(self, key: KeyType) -> Future[typing.Optional[ValueType]]: """Removes the mapping for a key from this map if it is present. The map will not contain a mapping for the specified key once the call returns. Warning: This method uses ``__hash__`` and ``__eq__`` methods of binary form of the key, not the actual implementations of ``__hash__`` and ``__eq__`` defined in key's class. Args: key: Key of the mapping to be deleted. Returns: The previous value associated with key, or ``None`` if there was no mapping for key. """ check_not_none(key, "key can't be None") try: key_data = self._to_data(key) except SchemaNotReplicatedError as e: return self._send_schema_and_retry(e, self.remove, key) def handler(message): return self._to_object( replicated_map_remove_codec.decode_response(message)) request = replicated_map_remove_codec.encode_request( self.name, key_data) return self._invoke_on_key(request, key_data, handler)
def remove(self, key): """ Removes the mapping for a key from this map if it is present. The map will not contain a mapping for the specified key once the call returns. **Warning: This method uses __hash__ and __eq__ methods of binary form of the key, not the actual implementations of __hash__ and __eq__ defined in key's class.** :param key: (object), key of the mapping to be deleted. :return: (object), the previous value associated with key, or None if there was no mapping for key. """ check_not_none(key, "key can't be None") def handler(message): return self._to_object( replicated_map_remove_codec.decode_response(message)) key_data = self._to_data(key) request = replicated_map_remove_codec.encode_request( self.name, key_data) return self._invoke_on_key(request, key_data, handler)