You can use unwrap_binary:
data = cache.get_all([Key(id=10)])
for k,v in data.items():
print(client.unwrap_binary(k))
print(v)
пн, 26 дек. 2022 г. в 11:31, Айсина Роза Мунеровна <
[email protected]>:
> Hola!
>
> I can’t use method *get_all* for caches from PyIgnite client.
> The problem is that keys are some binary strings that I do not know how to
> parse.
>
> *Here what I do: *
>
>
> class ProductFeaturesKey(
> metaclass=GenericObjectMeta,
> schema={
> 'product_sku': IntObject
> },
> type_name='io.sbmt.ProductFeaturesKey'
> ):
> pass
>
> …
>
> keys = [ProductFeaturesKey(product_sku=15052004),
> ProductFeaturesKey(product_sku=15058148)]
>
> res = cache.get_all(keys)
>
>
>
> *>> res*
> {
> (b'g\x01\x0b\x00\xa3\xb8r&%&\xd1\x01"\x00\x00\x00>8_Q\x1d\x00\x00\x00\x03\xe4\xac\xe5\x00\xcd\xa9\x1c\xa7\x18',
> 0): IoSbmtProductFeaturesValue(sku_mean_order_weight=10531.3330078125,
> sku_mean_order_quantity=21.0, sku_mean_order_item_count=15.333333015441895,
> total_cnt_orders_with_sku=12, total_cnt_retailers_with_sku=1,
> total_cnt_stores_with_sku=3, version=1),
>
> (b'g\x01\x0b\x00\xa3\xb8r&=\x80\xd1\x01"\x00\x00\x00>8_Q\x1d\x00\x00\x00\x03\xe4\xc4\xe5\x00\xcd\xa9\x1c\xa7\x18',
> 0): IoSbmtProductFeaturesValue(sku_mean_order_weight=9669.0,
> sku_mean_order_quantity=26.33333396911621,
> sku_mean_order_item_count=20.33333396911621, total_cnt_orders_with_sku=3,
> total_cnt_retailers_with_sku=2, total_cnt_stores_with_sku=3, version=1)
> }
>
>
>
> *>> res[keys[0]]*
> ...
> TypeError: unhashable type: 'ProductFeaturesKey'
>
>
>
> In the resulting dict the keys are binary strings which is odd.
> And as I see possible reason can be that original key instances are not
> hashable
> (see GenericObjectMeta definition:
> https://github.com/apache/ignite-python-thin-client/blob/master/pyignite/binary.py#L220
> ).
>
> Is there any way to extract several keys and be able to parse resulting
> keys to object?
> Single cache.get(key) method works too slow (about ~10ms on 400RPS) in
> the key loop, we want to extract all keys by one call.
>
> Thanks! Please help.
>
> Ignite version: 2.13.0
> Pyignite version: 0.5.2
>
> *--*
>
> *Роза Айсина*
>
> Старший разработчик ПО
>
> *СберМаркет* | Доставка из любимых магазинов
>
>
>
> Email: [email protected]
>
> Mob:
>
> Web: sbermarket.ru
>
> App: iOS
> <https://apps.apple.com/ru/app/%D1%81%D0%B1%D0%B5%D1%80%D0%BC%D0%B0%D1%80%D0%BA%D0%B5%D1%82-%D0%B4%D0%BE%D1%81%D1%82%D0%B0%D0%B2%D0%BA%D0%B0-%D0%BF%D1%80%D0%BE%D0%B4%D1%83%D0%BA%D1%82%D0%BE%D0%B2/id1166642457>
> и Android
> <https://play.google.com/store/apps/details?id=ru.instamart&hl=en&gl=ru>
>
>
>
> *УВЕДОМЛЕНИЕ О КОНФИДЕНЦИАЛЬНОСТИ:* это электронное сообщение и любые
> документы, приложенные к нему, содержат конфиденциальную информацию.
> Настоящим уведомляем Вас о том, что, если это сообщение не предназначено
> Вам, использование, копирование, распространение информации, содержащейся в
> настоящем сообщении, а также осуществление любых действий на основе этой
> информации, строго запрещено. Если Вы получили это сообщение по ошибке,
> пожалуйста, сообщите об этом отправителю по электронной почте и удалите это
> сообщение.
> *CONFIDENTIALITY NOTICE:* This email and any files attached to it are
> confidential. If you are not the intended recipient you are notified that
> using, copying, distributing or taking any action in reliance on the
> contents of this information is strictly prohibited. If you have received
> this email in error please notify the sender and delete this email.
>
--
Sincerely yours, Ivan Daschinskiy