You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by Denis Magda <dm...@gridgain.com> on 2015/11/27 07:59:52 UTC

Re: Not able to perform cache queries

Hi,

What do you mean saying that you're not able to perform SQL queries?
Do you get an error, empty or partial result set? Please be more specific.

In any case I want to draw your attention that if there is still some data
in a cache storage that has to be loaded then it won't be loaded
automatically during a SQL query execution regardless whether readThrough is
enabled or not.

If you're sure that all the data is loaded please make a call like this to
check the cache size:
cache.size(CachePeekMode.PRIMARY).

And please properly subscribe to the user list (this way we will not have to
manually approve your emails). All you need to do is send an email to
“user-subscribe@ignite.apache.org” and follow simple instructions in the
reply.

Regards,
Denis




--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Not-able-to-perform-cache-queries-tp2067p2069.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: Not able to perform cache queries

Posted by Denis Magda <dm...@gridgain.com>.
Hi,

Could you share a runnable example, that demonstrates the issue, over GitHub
or some other way?

For me it's unclear how readThrough or writeThrough can affect a result of a
SQL query having in mind that the full data set has already been loaded from
the storage and the data set is not being changed while queries are being
executed. This is exactly your case, correct?

As an example to can refer to CacheDummyStoreExample. However you need to
modify it a bit:

1) Activate indexing for the cache used in the example
cacheCfg.setIndexedTypes(Long.class, Person.class);

2) Add and call the following function

    private static void personsQuery() {
        IgniteCache<Integer, Person> cache =
            Ignition.ignite().cache("CacheDummyStoreExample");

        String sql = "select * from Person";

        QueryCursor<Cache.Entry&lt;Integer, Person>> cursor =
            cache.query(new SqlQuery<Integer,
                            Person>(Person.class, sql));

        List<Cache.Entry&lt;Integer, Person>> cursResult = cursor.getAll();

        System.out.println("size persons = " + cursResult.size());
    }

--
Denis



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Not-able-to-perform-cache-queries-tp2067p2092.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: Not able to perform cache queries

Posted by "gauri.jagtap" <ga...@gmail.com>.
Hi,

I was able to execute queries on cache after disabling Readthrough,
WriteThrough configuration. But with the same query when I use Readthrough,
WriteThrough configuration I am getting empty result set.
I am referring to ignite examples, there I couldn't find queries executed
after enabling store configuration.
It will be great help if you can provide me such example.

Thank you




--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Not-able-to-perform-cache-queries-tp2067p2087.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: Not able to perform cache queries

Posted by Denis Magda <dm...@gridgain.com>.
The only strange thing I see in your code is the following line

IgniteCache<Integer, ProtocolCache> cache =
Ignition.ignite().cache(CACHE_NAME); 

Here you get instance of a cache name CACHE_NAME, that according to the
generic holds ProtocolCache, but right after tries to query PersonCache
objects. Probably CACHE_NAME is not a valid one, please double-check that
this is not your case.

BTW, open CacheQueryExample, that is a part of Ignite, add the function
below to it and execute it

    private static void personsQuery() {
        IgniteCache<Integer, Person> cache =
Ignition.ignite().cache(PERSON_CACHE);

        String sql = "select * from Person";

        QueryCursor<Cache.Entry&lt;Integer, Person>> cursor =
cache.query(new SqlQuery<Integer,
            Person>(Person.class, sql));

        List<Cache.Entry&lt;Integer, Person>> cursResult = cursor.getAll();

        System.out.println("size persons = " + cursResult.size());
    }

Everything should work fine on your side and if it's so then I would
recommend you look into how the example works. Probably the example will
help you to find something that is missing on your side.

If nothing helps then please send me a reproducible example.

--
Denis



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Not-able-to-perform-cache-queries-tp2067p2071.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: Not able to perform cache queries

Posted by "gauri.jagtap" <ga...@gmail.com>.
Hi,

I am getting empty result set, but I can see cache is loaded with all data.
Checked the cache size using "cache.size(CachePeekMode.PRIMARY)" and I am
getting expected cache size.
But when I am performing "select * " operation using "cache.query(...)" I am
getting empty resultset.

Thank you



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Not-able-to-perform-cache-queries-tp2067p2070.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.