Returns the number of items in the map. Returns: int: The number of items in the map.
(self)
| 507 | raise InvalidArgumentException(message=f'Key: {mapkey} is not in the map.') from None |
| 508 | |
| 509 | def size(self) -> int: |
| 510 | """Returns the number of items in the map. |
| 511 | |
| 512 | Returns: |
| 513 | int: The number of items in the map. |
| 514 | |
| 515 | """ |
| 516 | op_type = DatastructureOperationType.MapSize |
| 517 | with ObservableRequestHandler(op_type, self._impl.observability_instruments) as ds_obs_handler: |
| 518 | ds_obs_handler.create_kv_span(self._impl._request_builder._collection_dtls.get_details_as_dict()) |
| 519 | kv_op_type = KeyValueOperationType.LookupIn |
| 520 | with ObservableRequestHandler(kv_op_type, self._impl.observability_instruments) as obs_handler: |
| 521 | op = count('') |
| 522 | req, transcoder = self._impl.request_builder.build_lookup_in_request(self._key, |
| 523 | (op,), |
| 524 | obs_handler, |
| 525 | parent_span=ds_obs_handler.wrapped_span) # noqa: E501 |
| 526 | sd_res: LookupInResult = self._execute_op(self._impl.lookup_in, |
| 527 | req, |
| 528 | obs_handler, |
| 529 | ds_obs_handler.wrapped_span, |
| 530 | create_type=True, |
| 531 | transcoder=transcoder) |
| 532 | return sd_res.value[0].get('value', None) |
| 533 | |
| 534 | def exists(self, key: str) -> bool: |
| 535 | """Checks whether a specific key exists in the map. |