> On Feb 21, 2017, at 11:48 PM, diopek <[email protected]> wrote:
> 
> Hi Denis,
> we have ignite cache that has key value pair as the following;
> IgniteCache<Long, ArrayList&lt;MyPOJO>>
> and cache cofiguration for this cache is as the following;
> CacheConfiguration<Long, ArrayList&lt;MyPOJO>> cacheCfg = new
> CacheConfiguration<>(cacheName);
>               cacheCfg.setStartSize(startSize);
>               cacheCfg.setCacheMode(CacheMode.LOCAL);
> 
> I wrote query as the following;
> String sql = "_key >= ? && _key < ? ";
> IgniteCache<Long, ArrayList&lt;MyPOJO>> igniteCache =
> Ignition.ignite().cache(this.getCacheName());
> SqlQuery<Long, ArrayList&lt;MyPOJO>> sqlQuery = new SqlQuery<Long,
> ArrayList&lt;MyPOJO>>("ArrayList<MyPOJO>.class", sql);
> sqlQuery.setArgs(min, max);
> igniteCache.query(sqlQuery).getAll();
> 

Is there any significant reason why you store a list of MyPojos in a cache 
rather than individual objects? Just want to make a precaution that if some day 
you decide to query using MyPojo's fields than you’ll not be able to leverage 
from indexes because the objects will be inside of the lists.


> above method call returns the following exception;
> Caused by: javax.cache.CacheException: Indexing is disabled for cache:
> MY_CACHE. Use setIndexedTypes or setTypeMetadata methods on
> CacheConfiguration to enable.
>       at
> org.apache.ignite.internal.processors.cache.IgniteCacheProxy.validate(IgniteCacheProxy.java:852)
> 
> I think I need to add indexing by calling
> cacheConfig.setIndexedTypes(Long.class, Value.class)

Do it this way - cacheConfig.setIndexedTypes(Long.class, ArrayList.class).

—
Denis

> But my value class is ArrayList<MyPOJO> not sure how to specify *.class file
> for this generic collection type. Can you please advise. Thanks,
> 
> 
> 
> --
> View this message in context: 
> http://apache-ignite-users.70518.x6.nabble.com/Ignite-cache-range-query-using-cache-keys-tp10717p10785.html
> Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Reply via email to