Apache ignite是否允许查询Cassandra表的分区键而不考虑集群密钥?

问题描述:

我的表结构;Apache ignite是否允许查询Cassandra表的分区键而不考虑集群密钥?

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

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

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

也尝试过sql查询,但是却没有找到错误表。

[错误PIC] [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策略键和值。

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

+0

我想,我的缓存的名字是cache1的并表的人,都试过,但它unble地发现,即使使用AffinityKeyMapped&QuerySqlField了。 –

+0

它给出错误无法找到人表 –

+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>