Apache点燃是否允许在不考虑群集密钥的情况下查询Cassandra表的分区键?

时间:2017-09-27 06:08:23

标签: cassandra ignite

我的表结构;

CREATE TABLE mydb.person (
    firstname text,
    lastname text,
    age int,
    birthdate timestamp,
    married boolean,
    phone text,
    PRIMARY KEY (firstname, lastname)
);

我希望所有人的详细信息都有名字' abc'。 因为我只提供分区密钥,而不是集群密钥。

仅在指定分区和群集密钥时从缓存中获取结果。

尝试了sql查询但是找不到错误表。

[错误图片] [1] https://i.stack.imgur.com/OFem2.png

缓存配置如下:          

<!-- Persistence settings for 'cache1' -->
<bean id="cache1_persistence_settings" class="org.apache.ignite.cache.store.cassandra.persistence.KeyValuePersistenceSettings">
    <constructor-arg type="org.springframework.core.io.Resource" value="classpath:persistence/primitive/persistence-settings-1.xml" />
</bean>

<!-- Ignite configuration -->
<bean id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
    <property name="cacheConfiguration">
        <list>
            <!-- Configuring persistence for "cache1" cache -->       
            <bean class="org.apache.ignite.configuration.CacheConfiguration">
                <property name="name" value="cache1"/>
                <property name="readThrough" value="false"/>
                <property name="writeThrough" value="true"/>
                <property name="writeBehindEnabled" value="true"/>
                <property name="writeBehindFlushSize" value="2"/>
                <property name="atomicityMode" value="TRANSACTIONAL"/>
                <property name="backups" value="1"/>
                <property name="cacheStoreFactory">
                    <bean class="org.apache.ignite.cache.store.cassandra.CassandraCacheStoreFactory">
                        <property name="dataSourceBean" value="cassandraAdminDataSource" />
                        <property name="persistenceSettingsBean" value="cache1_persistence_settings"/>
                    </bean>
                </property>
            </bean>
        </list>
    </property>
    <property name="clientMode" value="false"/>
    <!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. -->
    <property name="discoverySpi">
        <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
            <property name="ipFinder">
                <!--
                    Ignite provides several options for automatic discovery that can be used
                    instead os static IP based discovery. For information on all options refer
                    to our documentation: http://apacheignite.readme.io/docs/cluster-config
                -->
                <!-- Uncomment static IP finder to enable static-based discovery of initial nodes. -->
                <!--<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">-->
                <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder">
                    <property name="addresses">
                        <list>
                            <!-- In distributed environment, replace with actual host IP address. -->
                            <value>192.168.0.3:47500..47509</value>
                        </list>
                    </property>
                </bean>

并使用了pojo策略来获得关键和价值。

2 个答案:

答案 0 :(得分:1)

Apache Ignite允许通过任何字段(非强制分区和群集密钥)在缓存中进行搜索。如何在Apache Ignite中正确配置SQL,请阅读:https://apacheignite.readme.io/docs#queryentity-based-configuration

答案 1 :(得分:0)

我发现这是因为缓存配置文件中的索引配置 请参阅此链接config indexFailed to execute SQL 。只是通过添加以下行

来唤醒它
 <property name="queryEntities">
                    <list>
                        <bean class="org.apache.ignite.cache.QueryEntity">
                            <property name="keyType" value="com.manish.igniteexample.PersonKey"/>
                            <property name="valueType" value="com.manish.igniteexample.Person"/>

                            <property name="fields">
                                <map>
                                    <entry key="firstname" value="java.lang.String"/>
                                    <entry key="lastname" value="java.lang.String"/>
                                    <entry key="age" value="java.lang.Integer"/>
                                    <entry key="married" value="java.lang.Boolean"/>
                                    <entry key="birthDate" value="java.util.Date"/>
                                    <entry key="phone" value="java.lang.Integer"/>
                                </map>
                            </property>

                            <property name="indexes">
                                <list>
                                    <bean class="org.apache.ignite.cache.QueryIndex">
                                        <constructor-arg value="firstname"/>
                                    </bean>
                                    <bean class="org.apache.ignite.cache.QueryIndex">
                                        <constructor-arg value="lastname"/>
                                    </bean>
                                </list>
                            </property>
                        </bean>
                    </list>
                </property>