コード例 #1
0
    def contains_key(self, key: KeyType) -> Future[bool]:
        """Determines whether this map contains an entry with the key.

        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: The specified key.

        Returns:
            ``True`` if this map contains an entry for the specified key,
            ``False`` otherwise.
        """
        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.contains_key, key)

        request = replicated_map_contains_key_codec.encode_request(
            self.name, key_data)
        return self._invoke_on_key(
            request, key_data,
            replicated_map_contains_key_codec.decode_response)
コード例 #2
0
    def contains_key(self, key):
        """
        Determines whether this map contains an entry with the key.

        **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), the specified key.
        :return: (bool), ``true`` if this map contains an entry for the specified key.
        """
        check_not_none(key, "key can't be None")
        key_data = self._to_data(key)
        request = replicated_map_contains_key_codec.encode_request(
            self.name, key_data)
        return self._invoke_on_key(
            request, key_data,
            replicated_map_contains_key_codec.decode_response)