You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by waipy <ad...@gmail.com> on 2021/05/06 14:53:20 UTC

Get always return null in java thick client for data inserted in python thin client

Hello, I am trying to read some data on my java client nodes that has been
inserted on the server nodes by a python thin client.

The cache is a key-value for types int-HashSet. I can insert the data
flawlessly in python, I can read the data in the java client using a
ScanQuery, using an EntryProcessor also works (well it prints the data on
the server node) but I always get null when doing a get operation on the
client. If I insert the data from the java client, the get returns the
correct data.

I am sure I am missing something here that causes this behaviour and I am
stuck here...

*Python code:*
/ignite_client = Client(timeout=30.0)
ignite_client.connect(hosts_list)
pub_list_cache = ignite_client.get_or_create_cache('pub_list')
for key, pub_list in pub_lists.items():
    pub_list_cache.put(key, (CollectionObject.HASH_SET, pub_list))
ignite_client.close()/

*Java code:*
/TcpDiscoverySpi spi = new TcpDiscoverySpi();
TcpDiscoveryZookeeperIpFinder ipFinder = new
TcpDiscoveryZookeeperIpFinder();
ipFinder.setZkConnectionString("localhost:12181");
spi.setIpFinder(ipFinder);
IgniteConfiguration cfg = new IgniteConfiguration()
.setDiscoverySpi(spi)
.setPeerClassLoadingEnabled(true);
Ignition.setClientMode(true);
Ignite ignite = Ignition.start(cfg);

IgniteCache<Integer, HashSet&lt;String>> cache = ignite.cache("pub_list");
System.out.println(cache.get(idgroup));
try (QueryCursor<Cache.Entry&lt;Integer, HashSet&lt;String>>> qryCursor =
cache.query(new ScanQuery<>())) {
    qryCursor.forEach(entry -> {
    System.out.println("Key = " + entry.getKey());
    entry.getValue().forEach(System.out::println);
    });
}/

As said before, the get operation returns null, the scanquery prints all the
items in the cache. If i do the insert on java and then the get, I also get
the items.

Thanks in advance 



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Re: Get always return null in java thick client for data inserted in python thin client

Posted by Ivan Daschinsky <iv...@apache.org>.
Hi, you should use IgniteCache<Long, Set> in java. Pythoninc int maps
directly to Long in java.
If you want use Integer, you should put in python using key_hint like this:
>> cache.put(1, (CollectionObject.HASH_SET, [1, 2, 3]), key_hint=IntObject)

чт, 6 мая 2021 г. в 17:53, waipy <ad...@gmail.com>:
>
> Hello, I am trying to read some data on my java client nodes that has been
> inserted on the server nodes by a python thin client.
>
> The cache is a key-value for types int-HashSet. I can insert the data
> flawlessly in python, I can read the data in the java client using a
> ScanQuery, using an EntryProcessor also works (well it prints the data on
> the server node) but I always get null when doing a get operation on the
> client. If I insert the data from the java client, the get returns the
> correct data.
>
> I am sure I am missing something here that causes this behaviour and I am
> stuck here...
>
> *Python code:*
> /ignite_client = Client(timeout=30.0)
> ignite_client.connect(hosts_list)
> pub_list_cache = ignite_client.get_or_create_cache('pub_list')
> for key, pub_list in pub_lists.items():
>     pub_list_cache.put(key, (CollectionObject.HASH_SET, pub_list))
> ignite_client.close()/
>
> *Java code:*
> /TcpDiscoverySpi spi = new TcpDiscoverySpi();
> TcpDiscoveryZookeeperIpFinder ipFinder = new
> TcpDiscoveryZookeeperIpFinder();
> ipFinder.setZkConnectionString("localhost:12181");
> spi.setIpFinder(ipFinder);
> IgniteConfiguration cfg = new IgniteConfiguration()
> .setDiscoverySpi(spi)
> .setPeerClassLoadingEnabled(true);
> Ignition.setClientMode(true);
> Ignite ignite = Ignition.start(cfg);
>
> IgniteCache<Integer, HashSet&lt;String>> cache = ignite.cache("pub_list");
> System.out.println(cache.get(idgroup));
> try (QueryCursor<Cache.Entry&lt;Integer, HashSet&lt;String>>> qryCursor =
> cache.query(new ScanQuery<>())) {
>     qryCursor.forEach(entry -> {
>     System.out.println("Key = " + entry.getKey());
>     entry.getValue().forEach(System.out::println);
>     });
> }/
>
> As said before, the get operation returns null, the scanquery prints all the
> items in the cache. If i do the insert on java and then the get, I also get
> the items.
>
> Thanks in advance
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/