You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by Skollur <Sk...@idbny.com> on 2018/08/21 18:20:37 UTC

Loading Cache

Currently I am loading data with one line in java. Below ocmmand will load
all data from database to Cache.
Example: ignite.cache("CustomerCache").loadCache(null);

I would like to load data for specific period. How would I do that?




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

Re: Loading Cache

Posted by Skollur <Sk...@idbny.com>.
Tried below code, but code is not complaining in IDE..Keep seeing error
message asking to change the method loadcache() to method localloadCache().
When changed to method localloadcache(), asking to change method to
loadCache().


            ignite.cache("CustomerCache").loadCache(new
IgniteBiPredicate<Long, Customer>(){
				@Override
				public boolean apply(Object key, Customer customer) {
						return customer.<Timestamp>field("dwTimestamp").after(fromDate) &&
customer.<Timestamp>field("dwTimestamp").after(toDate);
			}}, null);



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

Re: Loading Cache

Posted by Skollur <Sk...@idbny.com>.
Thank you for reply. Is there example can you provide to load the data with
criteria i.e load data (select query) is based on date range is restricted.

i.e cache.loadcache(select * from table name where date = '02/02/108').



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

Re: Loading Cache

Posted by akurbanov <an...@gmail.com>.
Hi,

Call a method like this and pass closure that returns true for data entries
that match your criteria in apply() method:

cache.loadCache(new P2<Integer, String>() {
        @Override public boolean apply(Integer key, String val) {
        // Accept only even numbers.
        return key % 2 == 0;
    }
}, cnt);

Variable cnt is an number you may use to limit entry count, you may omit it.



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