Search in sources :

Example 6 with SpiQuery

use of org.apache.ignite.cache.query.SpiQuery in project ignite by apache.

the class IndexingSpiQuerySelfTest method testIndexingSpiWithDisabledQueryProcessor.

/**
 * @throws Exception If failed.
 */
public void testIndexingSpiWithDisabledQueryProcessor() throws Exception {
    IgniteConfiguration cfg = configuration();
    cfg.setIndexingSpi(new MyIndexingSpi());
    Ignite ignite = Ignition.start(cfg);
    CacheConfiguration<Integer, Integer> ccfg = cacheConfiguration(CACHE_NAME);
    IgniteCache<Integer, Integer> cache = ignite.createCache(ccfg);
    for (int i = 0; i < 10; i++) cache.put(i, i);
    QueryCursor<Cache.Entry<Integer, Integer>> cursor = cache.query(new SpiQuery<Integer, Integer>().setArgs(2, 5));
    for (Cache.Entry<Integer, Integer> entry : cursor) System.out.println(entry);
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) SpiQuery(org.apache.ignite.cache.query.SpiQuery) Ignite(org.apache.ignite.Ignite) Cache(javax.cache.Cache) IgniteCache(org.apache.ignite.IgniteCache)

Example 7 with SpiQuery

use of org.apache.ignite.cache.query.SpiQuery in project ignite by apache.

the class IndexingSpiQuerySelfTest method testBinaryIndexingSpi.

/**
 * @throws Exception If failed.
 */
public void testBinaryIndexingSpi() throws Exception {
    IgniteConfiguration cfg = configuration();
    cfg.setIndexingSpi(new MyBinaryIndexingSpi());
    Ignite ignite = Ignition.start(cfg);
    CacheConfiguration<PersonKey, Person> ccfg = cacheConfiguration(CACHE_NAME);
    IgniteCache<PersonKey, Person> cache = ignite.createCache(ccfg);
    for (int i = 0; i < 10; i++) {
        PersonKey key = new PersonKey(i);
        cache.put(key, new Person("John Doe " + i));
    }
    QueryCursor<Cache.Entry<PersonKey, Person>> cursor = cache.query(new SpiQuery<PersonKey, Person>().setArgs(new PersonKey(2), new PersonKey(5)));
    for (Cache.Entry<PersonKey, Person> entry : cursor) System.out.println(entry);
    cache.remove(new PersonKey(9));
}
Also used : SpiQuery(org.apache.ignite.cache.query.SpiQuery) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) Ignite(org.apache.ignite.Ignite) Cache(javax.cache.Cache) IgniteCache(org.apache.ignite.IgniteCache)

Example 8 with SpiQuery

use of org.apache.ignite.cache.query.SpiQuery in project ignite by apache.

the class IndexingSpiQuerySelfTest method testSimpleIndexingSpi.

/**
 * @throws Exception If failed.
 */
public void testSimpleIndexingSpi() throws Exception {
    IgniteConfiguration cfg = configuration();
    cfg.setIndexingSpi(new MyIndexingSpi());
    Ignite ignite = Ignition.start(cfg);
    CacheConfiguration<Integer, Integer> ccfg = cacheConfiguration(CACHE_NAME);
    IgniteCache<Integer, Integer> cache = ignite.createCache(ccfg);
    for (int i = 0; i < 10; i++) cache.put(i, i);
    QueryCursor<Cache.Entry<Integer, Integer>> cursor = cache.query(new SpiQuery<Integer, Integer>().setArgs(2, 5));
    for (Cache.Entry<Integer, Integer> entry : cursor) System.out.println(entry);
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) SpiQuery(org.apache.ignite.cache.query.SpiQuery) Ignite(org.apache.ignite.Ignite) Cache(javax.cache.Cache) IgniteCache(org.apache.ignite.IgniteCache)

Aggregations

SpiQuery (org.apache.ignite.cache.query.SpiQuery)8 Cache (javax.cache.Cache)6 IgniteCache (org.apache.ignite.IgniteCache)6 Ignite (org.apache.ignite.Ignite)4 SqlFieldsQuery (org.apache.ignite.cache.query.SqlFieldsQuery)4 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)4 Map (java.util.Map)2 NoSuchElementException (java.util.NoSuchElementException)2 CacheException (javax.cache.CacheException)2 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)2 CacheEntry (org.apache.ignite.cache.CacheEntry)2 SqlQuery (org.apache.ignite.cache.query.SqlQuery)2 TextQuery (org.apache.ignite.cache.query.TextQuery)2 CacheQuery (org.apache.ignite.internal.processors.cache.query.CacheQuery)2 CacheQueryFuture (org.apache.ignite.internal.processors.cache.query.CacheQueryFuture)2 IgniteOutClosureX (org.apache.ignite.internal.util.lang.IgniteOutClosureX)2