Date compare fetch in the Query

classic Classic list List threaded Threaded
7 messages Options
sujay_kb@ymail.com sujay_kb@ymail.com
Reply | Threaded
Open this post in threaded view
|

Date compare fetch in the Query

This post was updated on .
Hi,

I am trying to fetch the records based on the dates:

Below is the Query:
ScanQuery<String, [JavaObject]> dataScanQuery = new ScanQuery<String, [JavaObject]>((k, p) -> p.getUpdatedDate().before(get1HourBefore()));


[JavaObject] - has Date field, i am trying to fetch the records using date operation, but every time it is fetching all the records, I think ScanQuery is failing to compare Date field
vkulichenko vkulichenko
Reply | Threaded
Open this post in threaded view
|

Re: Date compare fetch in the Query

Hi,

Can query itself doesn't do any comparisons, it simply calls the filter you provided. Does this happen?

Did you verify that the filter is implemented correctly (e.g., that get1HourBefore() returns the correct value for comparison)?

-Val
sujay_kb@ymail.com sujay_kb@ymail.com
Reply | Threaded
Open this post in threaded view
|

Re: Date compare fetch in the Query

No Filter is not happening

p.getUpdatedDate().before(get1HourBefore())  --- Both are java.util.Date Objects
vkulichenko vkulichenko
Reply | Threaded
Open this post in threaded view
|

Re: Date compare fetch in the Query

Can you provide the full test that you're running? Did you check the logs for exceptions?

-Val
sujay_kb@ymail.com sujay_kb@ymail.com
Reply | Threaded
Open this post in threaded view
|

Re: Date compare fetch in the Query

This post was updated on .
Config:

CacheConfiguration<Object, Object>  cacheConfig = new CacheConfiguration<>(cacheName);
                cacheConfig.setCacheMode(CacheMode.PARTITIONED);
                cacheConfig.setMemoryMode(CacheMemoryMode.OFFHEAP_TIERED);
                cacheConfig.setExpiryPolicyFactory(CreatedExpiryPolicy.factoryOf(new Duration(TimeUnit.MINUTES, 40)));
                cacheConfig.setEvictionPolicy(new LruEvictionPolicy(2500));
                cacheConfig.setOffHeapMaxMemory(0);
                cacheConfig.setSwapEnabled(false);
                cacheConfig.setBackups(1);
                cacheConfig.setStoreKeepBinary(false);
                //cacheConfig.setWriteBehindEnabled(true);
                cacheConfig.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
                cacheConfig.setAtomicityMode(CacheAtomicityMode.ATOMIC);
                cacheConfig.setIndexedTypes(String.class, Container.class);

Model Object:

public class Container implements Serializable {
       
        private static final long serialVersionUID = 1L;

        @QuerySqlField
        private String key;
       
        @QuerySqlField
        private Long counter;
       
        private String objectType;
       
        @QuerySqlField
        private Date updatedDate;
       
        private byte[] data;




This is the Code Details i am using, i am not getting exception..I tired with other Fields also Filter is not working at all

code is running as Client Mode, I have one Ignite Server running in other linux machine



And I tried other SqlQuery options, those also failing with Below Exception:

select * from PB_PRICE.Container where counter >= 1456885117000 and counter <= 1456885127000


javax.cache.CacheException: Failed to run reduce query locally.
Total Count:0
        at org.apache.ignite.internal.processors.query.h2.twostep.GridReduceQueryExecutor.query(GridReduceQueryExecutor.java:673)
        at org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing$2.iterator(IgniteH2Indexing.java:956)
        at org.apache.ignite.internal.processors.cache.QueryCursorImpl.iterator(QueryCursorImpl.java:61)
        at org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing$3.iterator(IgniteH2Indexing.java:990)
        at org.apache.ignite.internal.processors.cache.QueryCursorImpl.iterator(QueryCursorImpl.java:61)
        at org.apache.ignite.internal.processors.cache.QueryCursorImpl.getAll(QueryCursorImpl.java:73)
        at com.staples.catalog.dal.DataAccessLayer.getAll(DataAccessLayer.java:97)
        at com.staples.catalog.service.CacheService.getAll(CacheService.java:124)
        at com.staples.catalog.processor.CacheProcessor.getAll(CacheProcessor.java:67)
        at com.staples.catalog.api.CacheApi.getAll(CacheApi.java:67)
        at com.staples.catalog.main.price.pb.TestPBTimeFetch.execute(TestPBTimeFetch.java:58)
        at com.staples.catalog.main.price.pb.TestPBTimeFetch.main(TestPBTimeFetch.java:45)
Caused by: java.lang.NullPointerException
        at org.apache.ignite.internal.processors.query.h2.twostep.GridMergeIndexUnsorted$1.hasNext(GridMergeIndexUnsorted.java:97)
        at org.apache.ignite.internal.processors.query.h2.twostep.GridMergeIndex$IteratorCursor.next(GridMergeIndex.java:327)
        at org.apache.ignite.internal.processors.query.h2.twostep.GridMergeIndex$FetchingCursor.next(GridMergeIndex.java:358)
        at org.apache.ignite.internal.processors.query.h2.twostep.GridReduceQueryExecutor.query(GridReduceQueryExecutor.java:614)
        ... 11 more


I am using latest 1.5 final version of ignite
sujay_kb@ymail.com sujay_kb@ymail.com
Reply | Threaded
Open this post in threaded view
|

Re: Date compare fetch in the Query

This post was updated on .
Just wanted share solution i found for the crazy exception :

javax.cache.CacheException: Failed to run reduce query locally.


by putting limit to the Query i was able to fetch the data

vkulichenko vkulichenko
Reply | Threaded
Open this post in threaded view
|

Re: Date compare fetch in the Query

NPE is a known issue and it's already fixed. You can build from master and check if it works for you.

As for the original issue, can you provide the full test code? Also did you deploy classes on server nodes?

-Val