Firstly, please run the java snippet, then run the python snippet I got this output: /home/ivandasch/.virtualenvs/pyignite-py38/bin/python /home/ivandasch/.config/JetBrains/PyCharm2022.2/scratches/scratch.py ValueType(name='test', version=1)
чт, 22 дек. 2022 г. в 10:40, Ivan Daschinsky <ivanda...@gmail.com>: > Just tried on (ignite 2.13.0 server, ignite-client on master, pyignite on > 0.6.0) > > Java code: > > import org.apache.ignite.Ignition; > import org.apache.ignite.binary.BinaryObject; > import org.apache.ignite.client.ClientCache; > import org.apache.ignite.client.IgniteClient; > import org.apache.ignite.configuration.ClientConfiguration; > > class Scratch { > public static void main(String[] args) { > try (IgniteClient client = Ignition.startClient(new > ClientConfiguration() > .setAddresses("127.0.0.1:10800", "127.0.0.1:10801", " > 127.0.0.1:10802"))) { > > ClientCache<Object, Object> cache = > client.getOrCreateCache("test").withKeepBinary(); > > BinaryObject key = > client.binary().builder("KeyType").setField("id", 10, > Integer.class).build(); > BinaryObject val = > client.binary().builder("ValueType").setField("name", "test", > String.class).build(); > > cache.put(key, val); > } > } > } > > Python code: > > from pyignite import Client > from pyignite import GenericObjectMeta > from pyignite.datatypes import IntObject, String > > class Key( > metaclass=GenericObjectMeta, > type_name="KeyType", > schema={ > 'id': IntObject, > }, > version=1, > ): > pass > > class Value( > metaclass=GenericObjectMeta, > type_name="ValueType", > schema={ > 'name': String, > }, > version=1, > ): > pass > > client = Client() > client.connect([('127.0.0.1', 10800 + i) for i in range(0, 3)]) > cache = client.get_or_create_cache("test") > > print(cache.get(Key(id=10))) > > Everything works as expected. > > I guess that you used the version of ignite-core (thin-client) older than > 2.14.0. > In that version, compactFooter equals to false, but on server side and > pyignite it is by default enabled. > > But pyignite has an ability to detect this param after fetching the data. > That is the reason why you code started working after fetching few data by > a scan query. > > чт, 22 дек. 2022 г. в 09:13, Ivan Daschinsky <ivanda...@gmail.com>: > >> Couls you please specify the exact versions of pyignite and ignite-core >> (java thin client)? >> >> ср, 21 дек. 2022 г., 18:36 Айсина Роза Мунеровна < >> roza.ays...@sbermarket.ru>: >> >>> Hola again! >>> >>> I accidently discovered some strange behaviour when trying to get value >>> by key in Python. >>> >>> I do this in part 3: >>> >>> cache = ignite_client.get_cache("PUBLIC_ProductFeatures") >>> key = IoSbmtProductFeaturesKey(product_sku=15052004) >>> cursor = cache.scan(partitions=1) >>> >>> # Uncomment to see error >>> # value = cache.get(key) >>> >>> true_key, true_value = next(cursor) # THIS LINE IS CRUCIAL!!!11 >>> print("true_key: ", true_key) >>> print("true_value:", true_value) >>> >>> value = cache.get(key) >>> >>> >>> So if data from cursor is read first then everything works as expected. >>> If there is no cursor or reading data from it happens AFTER >>> cache.get(key) - everything fails and key is not found. >>> >>> Is it ok? >>> Maybe there is some dynamic binding of classes? >>> Looks really weird. >>> >>> Help please! >>> >>> On 20 Dec 2022, at 1:35 PM, Айсина Роза Мунеровна < >>> roza.ays...@sbermarket.ru> wrote: >>> >>> Hola! >>> I can’t get data by key in Python in caches created in Java with binary >>> objects. >>> >>> 1. Cache was created though DDL in SQL API: >>> >>> CREATE TABLE IF NOT EXISTS PUBLIC.ProductFeatures >>> ( >>> product_sku INT PRIMARY KEY, >>> total_cnt_orders_with_sku INT >>> ) >>> WITH "CACHE_NAME=PUBLIC_ProductFeatures, >>> KEY_TYPE=io.sbmt.ProductFeaturesKey, >>> VALUE_TYPE=io.sbmt.ProductFeaturesValue, >>> AFFINITY_KEY=product_sku, >>> TEMPLATE=PARTITIONED, >>> BACKUPS=1” >>> >>> 2. Java apps uploads data to this cache through Key-Value API with >>> binary object underneath: >>> >>> ClientCache<BinaryObject, BinaryObject> igniteCache = igniteClient >>> .cache(config.getCacheName()) >>> .withKeepBinary(); >>> >>> final BinaryObjectBuilder keyBuilder = >>> igniteClient.binary().builder(config.getKeyType()); >>> final BinaryObjectBuilder valueBuilder = >>> igniteClient.binary().builder(config.getValueType()); >>> >>> keyBuilder.setField(column.name, id); >>> valueBuilder.setField(column.name, id); >>> >>> final BinaryObject key = keyBuilder.build(); >>> final BinaryObject value = valueBuilder.build(); >>> >>> igniteCache.put(key, value); >>> >>> >>> 3. In Python client I create Complex Object class and try to get data >>> from this cache: >>> >>> class IoSbmtProductFeaturesKey( >>> metaclass=GenericObjectMeta, >>> schema={ >>> 'product_sku': IntObject >>> }, >>> type_name='io.sbmt.ProductFeaturesKey' >>> ): >>> pass >>> >>> >>> ignite_client.register_binary_type(IoSbmtProductFeaturesKey) >>> >>> key = IoSbmtProductFeaturesKey(product_sku=15052004) >>> cache = ignite_client.get_cache("PUBLIC_ProductFeatures") >>> value = cache.get(key) >>> >>> cursor = cache.scan(partitions=1) # to check that key really exists >>> true_key, true_value = next(cursor) >>> >>> >>> What I see: >>> >>> >>> *true_key* >>> IoSbmtProductFeaturesKey(product_sku=15052004, version=1) >>> >>> *key* >>> IoSbmtProductFeaturesKey(product_sku=15052004, version=1) >>> >>> *true_key == key* >>> True >>> >>> *cache.get(true_key)* >>> IoSbmtProductFeaturesValue(total_cnt_orders_with_sku=12, version=1) >>> >>> *cache.get(true_key) == true_value* >>> True >>> >>> *cache.get(key)* >>> >>> *type(cache.get(key))* >>> <class 'NoneType'> >>> >>> So I can’t create Python analogue of Java binary class that is stored as >>> key in the cache. >>> I tried also to change case in schema of python class, check all this on >>> cache with composite key, to not specify *type_id* - nothing helps :( >>> >>> Please help. >>> >>> *--* >>> >>> *Роза Айсина* >>> Старший разработчик ПО >>> *СберМаркет* | Доставка из любимых магазинов >>> >>> >>> Email: roza.ays...@sbermarket.ru >>> 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. >>> *--* >>> >>> *Роза Айсина* >>> Старший разработчик ПО >>> *СберМаркет* | Доставка из любимых магазинов >>> >>> >>> Email: roza.ays...@sbermarket.ru >>> 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> >>> >>> >>> >>> >>> >>> *--* >>> >>> *Роза Айсина* >>> >>> Старший разработчик ПО >>> >>> *СберМаркет* | Доставка из любимых магазинов >>> >>> >>> >>> Email: roza.ays...@sbermarket.ru >>> >>> 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 > -- Sincerely yours, Ivan Daschinskiy