with ignite 2.10.0 C/S deploy mode, I'm trying to mix using K/V and sql query
in a certain cache. Ignite server config like
this(cacheconfiguration-queryEntities attribute):
                    <property name="queryEntities">
                        <list>
                            <bean
class="org.apache.ignite.cache.QueryEntity">
                                <property name="keyType"
value="java.lang.Integer" />
                                <property name="keyFieldName" value="uid"/>
                                <property name="valueType"
value="com.chinacnd.cdc_idm.IgniteClients.SampleBean" />
                                <property name="fields">
                                    <map>
                                        <entry key="uid"
value="java.lang.Integer" />
                                        <entry key="attr1"
value="java.lang.String" />
                                        <entry key="attr2"
value="java.lang.String" />
                                    </map>
                                </property>
                                <property name="indexes">
                                    <list>
                                        <bean
class="org.apache.ignite.cache.QueryIndex">
                                            <constructor-arg value="attr1"/>
                                        </bean>
                                    </list>
                                </property>
                            </bean>
                        </list>
                    </property>

And after ignite server started, I run client code like:
                try (IgniteClient client = Ignition.startClient(cfg)) {
                        ClientCache<Integer, SampleBean> cc =
client.getOrCreateCache("FUTURE_TEST_CACHE_");
                        System.out.format("ignite cache '%s' created....\n", 
cc);

                        for (int i = 1; i < 10; i++) {
                                SampleBean bean = new SampleBean();
                                bean.setUid(100 + i);
                                bean.setAttr1("attribute1 10" + i);
                                bean.setAttr2("attribute2 10" + i);
                                cc.put(bean.getUid(), bean);
                        }// 1. initialized cache data by KV-mode
                        System.out.println("ignite cache putting 10 element 
over.");
                        SampleBean bean = cc.get(105);// 1.a load by KV mode
                        System.out.format("Load from cache: '%s'.\n", bean);

                        // cc.query(new SqlFieldsQuery("insert into 
SampleBean(uid, attr1, attr2)
values(?, ?, ?) ").setArgs(106, "attribute1 106", "attribute2 106"))
                        //              .getAll();// 2.a. Insert first
                        List list = cc.query(new SqlFieldsQuery("select * from 
SampleBean where
attr1 like 'attribute1%'"))
                                        .getAll();// 3.  Here, if using 
"2.a"can get result; otherwise only
with "1" to initialize, will be empty list ever.
                        System.out.printf("query from cache is: %s.\n", list);
                        // cc.clear();
                }


    Note that if like the post code, I comment "2.a" code, then query will
never get result put by "1.a".  cann't we mix using K/V put and sql query in
the same cache? I read the "User Guide" word by word again and again: only
see example that under the server-server mode, mix using K/V and sql query. 



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

Reply via email to