Hi,

Seems you have to use Cache's query method with transformer.

public <T, R> QueryCursor<R> query(Query<T> qry, IgniteClosure<T, R>
transformer);

Usage example:

IgniteClosure<Cache.Entry<Integer, String>, Integer> transformer =
    new IgniteClosure<Cache.Entry<Integer, String>, Integer>() {
        @Override public Integer apply(Cache.Entry<Integer, String> e) {
            return e.getKey();
        }
    };

List<Integer> keys = cache.query(new ScanQuery<Integer, String>(),
transformer).getAll();


On Mon, Apr 3, 2017 at 4:17 PM, austin solomon <[email protected]>
wrote:

> Hi,
>
> My Ignite version is 1.9.0
>
> I am pushing JSON object into Ignite's cache using Apache Nifi's : GetKafka
> => PutIgniteCache processors.
> I could able to save the data in cache but the data it is in byte array
> format how can I query this.
>
> My Json object looks like this : {"id":1, "name":"USA", "population":
> 150000} .
> When  print the cache data  got the following result:
>
>               byte[] bytes = (byte[]) cache.get("1");
>               String str = new String(bytes, StandardCharsets.UTF_8);
>               System.out.println("Cache get id = "+str);
>               Iterator it=cache.iterator();
>               while(it.hasNext()){
>                   System.out.println("Cache next=="+it.next());
>               }
>
> Result:
>
>    Cache get id = {"id":1, "name":"USA", "population": 150000}
>    Cache next==Entry [key=1, val=[B@5ab14cb9]
>    Cache next==Entry [key=2, val=[B@5fb97279]
>    Cache next==Entry [key=3, val=[B@439a8f59]
>
> How can I query this data or map this as key, value.
>
>
>
>
> --
> View this message in context: http://apache-ignite-users.
> 70518.x6.nabble.com/Storing-JSON-data-on-Ignite-cache-tp11660.html
> Sent from the Apache Ignite Users mailing list archive at Nabble.com.
>

Reply via email to