ignite-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dkarachentsev <dkarachent...@gridgain.com>
Subject Re: ScanQuery log all entries
Date Tue, 18 Apr 2017 07:43:08 GMT
Hi,

Yes, you understand correctly. Here is example:

private static void sqlQuery() {
        IgniteCache<AffinityKey&lt;Long>, Person> cache =
Ignition.ignite().cache(PERSON_CACHE);

        // SQL clause which selects salaries based on range.
        String sql = "salary > ? and salary <= ?";

        // People with salaries between 1000 and 2000.
        try (QueryCursor<Cache.Entry&lt;AffinityKey&lt;Long>, Person>>
cursor =
                 cache.query(new SqlQuery<AffinityKey&lt;Long>,
Person>(Person.class, sql).
                 setArgs(1000, 2000))) {

            // Cursor is Iterable, so you may iterate over it with for each
loop.
            for (Cache.Entry<AffinityKey&lt;Long>, Person> entry : cursor)
                System.out.println("Key: " + entry.getKey() + ", Value: " +
entry.getValue());
        }
}

It's based on
https://github.com/apache/ignite/blob/master/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheQueryExample.java

-Dmitry.



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/ScanQuery-log-all-entries-tp11970p12017.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Mime
View raw message