ignite-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From DanieleBosetti <D.Bose...@cmcmarkets.com>
Subject Re: Key fields are not part of the value object
Date Fri, 31 Aug 2018 18:58:30 GMT
Hi, thanks for replying-

Actually, even though we can use the SQL facilities to inspect the caches,
the intended usage is to have Java clients, and possibly using the jcache
api to access the data; so I really need to use cache.get(key).

I looked further into this;
for this very same cache, if data is inserted using SQL and "insert into..",
then the key fields are not placed into the value object.
But if data is placed to the cache using Java api, then the key fields are
put to the value object: by continuing with the above example, I executed:

  IgniteCache<BinaryObject, BinaryObject> cache =
  BinaryObjectBuilder keyBuilder = ig.binary().builder("domain.key");
  BinaryObjectBuilder valBuilder = ig.binary().builder("domain.val");
  BinaryObject key = keyBuilder.setField("A", 22).setField("B", 23).build();
  BinaryObject val = valBuilder
      .setField("A", 22).setField("B", 23).setField("C", 24).setField("D",
25) .build();
  cache.put(key, val);

Then, dumping the cache contents (or calling cache.get..) I get the
Note that (22,23) is (correctly) mapped to (22,23,24,25).

19:41:16.394 [main] INFO  c.t.BrowseBinaryClient - key=domain.key
[idHash=988904418, hash=802638656, A=22, B=23] val=domain.val
[idHash=908722588, hash=-1944151425, A=22, B=23, C=24, D=25]
19:41:16.394 [main] INFO  c.t.BrowseBinaryClient - key=domain.key
[idHash=496757837, hash=783969056, A=3, B=4] val=domain.val
[idHash=1548271808, hash=1464087008, A=null, B=null, C=5, D=6]
19:41:16.394 [main] INFO  c.t.BrowseBinaryClient - key=domain.key
[idHash=17600354, hash=103851104, A=1, B=2] val=domain.val
[idHash=1733056574, hash=783969056, A=null, B=null, C=3, D=4]

So it seems the difference is due to the JDBC driver writing less fields;
and I am wondering if that is intended by design (and why?)-
I would expect for JDBC to behave differently; so that when executing
"INSERT (a,b,c,d).." it placed to the cache (a,b)->(a,b,c,d) , whereas it is
now placing (a,b)->(c,d) instead.

(the reason why we are mixing SQL and java api access is that we are
planning to have both business users (using sql) and services (java)
accessing the grid.)

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

View raw message