I tried your suggestion but unfortunately to no effect yet. I restarted the 
cluster every time I tried something new.



It seems it is now the following that causes a problem:

cfg.setKeyConfiguration(new CacheKeyConfiguration(TestKey.class.getName(), 
"b")); // using this line, i get the incorrect behavior



cfg.setKeyConfiguration(new CacheKeyConfiguration(TestKey.class.getName(), 
"some_field_that_does_not_exist")); // this results in ok query behavior (but 
obviously not the affinity I want as the field does not exist. i think it just 
takes the full key as affinity here because they field does not exist



The lines that configure my cache are now:



        CacheConfiguration<TestKey, TestValue> cfg = new 
CacheConfiguration<>(TEST);

        cfg.setSqlSchema("PUBLIC");

        cfg.setName("Test");

        cfg.setKeyConfiguration(new 
CacheKeyConfiguration(TestKey.class.getName(), "b"));

        cfg.setIndexedTypes(TestKey.class, TestValue.class);



-Floris



________________________________
From: Denis Mekhanikov <dmekhani...@gmail.com>
Sent: Friday, August 3, 2018 5:35 PM
To: user@ignite.apache.org
Subject: Re: SQL SELECT with AffinityKeyMapped - no results [External]

Floris,

Binary metadata may be saved in work/binary_meta directory.
Try cleaning this directory and see if it helps. You will also need to restart 
the whole cluster.
Note, that it may lead to impossibility to read persisted data, if you have any.

Denis

пт, 3 авг. 2018 г. в 18:15, Floris Van Nee 
<florisvan...@optiver.com<mailto:florisvan...@optiver.com>>:
Thank you for your quick reply. That does look a lot like what I’m experiencing.

However, I did some testing but so far I did not get the workaround to work. I 
put the following in the XML config file:

        <property name="binaryConfiguration">
            <bean class="org.apache.ignite.configuration.BinaryConfiguration">
                <property name="classNames">
                    <list>
                        
<value>org.apache.ignite.examples.streaming.TestKey</value>
                    </list>
                </property>
            </bean>
        </property>

Furthermore, when I create the cache, I pass a config with:
cfg.setKeyConfiguration(new CacheKeyConfiguration(TestKey.class.getName(), 
"b"));

According to the ticket this should be sufficient. Could I still be missing 
something here?

-Floris

From: Denis Mekhanikov 
[mailto:dmekhani...@gmail.com<mailto:dmekhani...@gmail.com>]
Sent: Friday 03 August 2018 4:05 PM
To: user@ignite.apache.org<mailto:user@ignite.apache.org>
Subject: Re: SQL SELECT with AffinityKeyMapped - no results [External]

Floris,

Most probably, you hit a bug, that was introduced in Ignite 2.0: 
https://issues.apache.org/jira/browse/IGNITE-5795<https://webvpn.optiver.com/jira/browse/,DanaInfo=.aituxixFhxjmsqM26w,SSL+IGNITE-5795>

Because of this bug @AffinityKeyMapped annotation is ignored in classes, that 
are used in query entity configuration.
As far as I can see, this is exactly your case.

It's going to be fixed in Ignite 2.7.

There is a workaround for this problem: you can list the problematic classes in 
BinaryConfiguration#classNames<https://webvpn.optiver.com/releases/latest/javadoc/org/apache/ignite/configuration/,DanaInfo=.aihplxjFhxjmsqM26w,SSL+BinaryConfiguration.html#setClassNames-java.util.Collection->
 configuration property.
Binary configuration should be specified as 
IgniteConfiguration#binaryConfiguration<https://webvpn.optiver.com/releases/latest/javadoc/org/apache/ignite/configuration/,DanaInfo=.aihplxjFhxjmsqM26w,SSL+IgniteConfiguration.html#setBinaryConfiguration-org.apache.ignite.configuration.BinaryConfiguration->.
This configuration should be the same on all nodes.
You may also need to configure 
CacheConfiguration#keyConfiguration<https://webvpn.optiver.com/releases/latest/javadoc/org/apache/ignite/configuration/,DanaInfo=.aihplxjFhxjmsqM26w,SSL+CacheConfiguration.html#setKeyConfiguration-org.apache.ignite.cache.CacheKeyConfiguration...->
 for your cache.

Denis

пт, 3 авг. 2018 г. в 16:58, Floris Van Nee 
<florisvan...@optiver.com<mailto:florisvan...@optiver.com>>:
Hi all,

I have defined two classes in Java – one for a key and one for a value. Suppose 
they look like this:

    public static class Key implements Serializable {
        public String a;
        @QuerySqlField
        @AffinityKeyMapped
        public String b;
    }
    public static class Value implements Serializable {
        @QuerySqlField
        public int c;
    }

I then define a distributed cache (in Java) for this key/value pair and fill it 
with values (in Java).
Now, I run the following in SQL:
SELECT * FROM kv_table;
I indeed see results of all the stuff that I inserted into the cache.

However, when I try to select a certain value, it returns no results:
SELECT * FROM kv_table WHERE b = ‘test’;
I get expected results when filtering on any column that is not defined as 
AffinityKeyMapped.
The only case where I get wrong results is for the AffinityKeyMapped column - I 
always get a wrong result (most of the time zero rows, for some values I do get 
one row, but I expect to see more rows). Also when I remove the 
AffinityKeyMapped annotation and run my test again, everything works as 
expected.
I run just a single server node and execute my query using the SQLLine tool 
that Ignite ships with.

Is it possible that there is a bug in the code that handles this affinity key 
mapping for SQL queries? Or am I doing something wrong here?

-Floris

Reply via email to