zoukankan      html  css  js  c++  java
  • ignite中的sql查询

      ignite中进行sql查询需要对要查询的cache和字段进行配置,可以在xml中配置,也可以在代码中配置或进行注解,我用的是xml配置:

    <!-- 配置cache -->
            <property name="cacheConfiguration">
                <list>
                    <bean class="org.apache.ignite.configuration.CacheConfiguration">
                        <property name="name" value="task_template" />
                        <property name="cacheMode" value="PARTITIONED" />
                        <property name="atomicityMode" value="TRANSACTIONAL" />
                        <property name="backups" value="2" />
                        <property name="queryEntities">
                            <list>
                                <bean class="org.apache.ignite.cache.QueryEntity">
                                    <property name="keyType" value="java.lang.Integer" />
                                    <property name="valueType"
                                        value="com.domain.read.TaskTemplate" />
                                    <property name="fields">
                                        <map>
                                            <entry key="taskTemplateId" value="java.lang.Integer" />
                                        </map>
                                    </property>
                                    <property name="indexes">
                                        <list>
                                            <bean class="org.apache.ignite.cache.QueryIndex">
                                                <constructor-arg value="taskTemplateId" />
                                            </bean>
                                        </list>
                                    </property>
                                </bean>
                            </list>
                        </property>
                    </bean>
                </list>
            </property>

      其中keyTpye和ValueType配置就是cache中储存的k和v配置  

      dao查询代码:

    public List<CacheEntryImpl> queryAll() {
            SqlQuery sql = new SqlQuery(TaskTemplate.class,
                    "taskTemplateId <> -1");
            return cache().query(sql).getAll();
        }

      得到的CacheEntryImpl可以进行遍历就得到了需要的东西.

  • 相关阅读:
    caffe绘制训练过程的loss和accuracy曲线
    第32题 最长匹配括号
    http://deepdish.io/2015/04/28/creating-lmdb-in-python/
    caffe神经网络模型的绘图
    数据制作
    mnist测试
    caffe环境搭建笔记
    图论之遍历所有点的最小距离
    DesignSurface简介
    给交换机端口设ip
  • 原文地址:https://www.cnblogs.com/garfieldcgf/p/5577649.html
Copyright © 2011-2022 走看看