首页 文章

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

提问于
浏览 160
0

我的 table 结构;

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策略来获得关键和 Value .

2 回答

  • 1

    我发现是因为缓存配置文件中的索引配置引用此链接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>
    
  • 0

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

相关问题