Query Entity and Affinity Key

classic Classic list List threaded Threaded
6 messages Options
narges saleh narges saleh
Reply | Threaded
Open this post in threaded view
|

Query Entity and Affinity Key

Hi All,

I have a question that might be trivial.
If I define my query entity for each in the XML configuration file and define the affinity key via CacheKeyConfiguration (again in the xml file), considering that here affinity key is defined at IgniteConfiguration level, how do I specify which cache keys (i.e., query entity key fields) will use the affinity key and which ones don't?

Say I have these 4 tables
Employee(company-id, employee-id)
Contractor(company-id, contractor-id)
Customer(company-id, customer-id)
Company(company-id, address)

How do I collocate employee, and contractors with companies but not the customers and companies? Can you provide the CacheKeyConfiguration and keyfields for each query entity?

thanks.
ezhuravlev ezhuravlev
Reply | Threaded
Open this post in threaded view
|

Re: Query Entity and Affinity Key

Hi,

You should have one cache per table(query entity) and configure separate CacheKeyConfigurations for each of the caches.

Evgenii

пн, 16 мар. 2020 г. в 11:42, narges saleh <[hidden email]>:
Hi All,

I have a question that might be trivial.
If I define my query entity for each in the XML configuration file and define the affinity key via CacheKeyConfiguration (again in the xml file), considering that here affinity key is defined at IgniteConfiguration level, how do I specify which cache keys (i.e., query entity key fields) will use the affinity key and which ones don't?

Say I have these 4 tables
Employee(company-id, employee-id)
Contractor(company-id, contractor-id)
Customer(company-id, customer-id)
Company(company-id, address)

How do I collocate employee, and contractors with companies but not the customers and companies? Can you provide the CacheKeyConfiguration and keyfields for each query entity?

thanks.
narges saleh narges saleh
Reply | Threaded
Open this post in threaded view
|

Re: Query Entity and Affinity Key

Thanks Evgenii for the reply.
How do I do that in XML configuration file if my query entities are defined solely in the xml file? What does ClassNameOfKey and fieldNameinThatClass represent? I assume I will have one bean for each cache.
<bean class="...CacheConfiguration">
<property name="keyConfiguration">
    <list>
        <bean class="org.apache.ignite.cache.CacheKeyConfiguration">
            <property name="typeName" value="ClassNameOfKey"/>
            <property name="affinityKeyFieldName"
                                                          value="fieldNameInThatClass"/>
        </bean>
    </list>
</property>
</bean>
And the bean for the query entity is:have
                      <bean class="org.apache.ignite.cache.QueryEntity">
                                <property name="keyType" value="java.lang.Integer"/>
                                <property name="valueType" value="PERSON"/>
                                <property name="tableName" value="PERSON"/>
                                <!-- Set fields for value object. -->
                                <property name="fields">
                                    <map>
                                        <entry key="CompanyId" value="java.lang.Integer"/>
                                       <entry key="EmployeeId" value="java.lang.Integer"/>  
                                        <entry key="firstName" value="java.lang.String"/>
                                        <entry key="lastName" value="java.lang.String"/>
                                    </map>
                                </property>
                                <property name="keyFields">
                                    <set>
                                        <!-- These are fields stored in the key. -->
                                        <value>CompanyId</value>
                                        <value>EmployeeId</value>
                                    </set>
                                </property>
                            </bean>


On Mon, Mar 16, 2020 at 3:22 PM Evgenii Zhuravlev <[hidden email]> wrote:
Hi,

You should have one cache per table(query entity) and configure separate CacheKeyConfigurations for each of the caches.

Evgenii

пн, 16 мар. 2020 г. в 11:42, narges saleh <[hidden email]>:
Hi All,

I have a question that might be trivial.
If I define my query entity for each in the XML configuration file and define the affinity key via CacheKeyConfiguration (again in the xml file), considering that here affinity key is defined at IgniteConfiguration level, how do I specify which cache keys (i.e., query entity key fields) will use the affinity key and which ones don't?

Say I have these 4 tables
Employee(company-id, employee-id)
Contractor(company-id, contractor-id)
Customer(company-id, customer-id)
Company(company-id, address)

How do I collocate employee, and contractors with companies but not the customers and companies? Can you provide the CacheKeyConfiguration and keyfields for each query entity?

thanks.
ezhuravlev ezhuravlev
Reply | Threaded
Open this post in threaded view
|

Re: Query Entity and Affinity Key

Hi, please share the whole config file

пн, 16 мар. 2020 г. в 15:38, narges saleh <[hidden email]>:
Thanks Evgenii for the reply.
How do I do that in XML configuration file if my query entities are defined solely in the xml file? What does ClassNameOfKey and fieldNameinThatClass represent? I assume I will have one bean for each cache.
<bean class="...CacheConfiguration">
<property name="keyConfiguration">
    <list>
        <bean class="org.apache.ignite.cache.CacheKeyConfiguration">
            <property name="typeName" value="ClassNameOfKey"/>
            <property name="affinityKeyFieldName"
                                                          value="fieldNameInThatClass"/>
        </bean>
    </list>
</property>
</bean>
And the bean for the query entity is:have
                      <bean class="org.apache.ignite.cache.QueryEntity">
                                <property name="keyType" value="java.lang.Integer"/>
                                <property name="valueType" value="PERSON"/>
                                <property name="tableName" value="PERSON"/>
                                <!-- Set fields for value object. -->
                                <property name="fields">
                                    <map>
                                        <entry key="CompanyId" value="java.lang.Integer"/>
                                       <entry key="EmployeeId" value="java.lang.Integer"/>  
                                        <entry key="firstName" value="java.lang.String"/>
                                        <entry key="lastName" value="java.lang.String"/>
                                    </map>
                                </property>
                                <property name="keyFields">
                                    <set>
                                        <!-- These are fields stored in the key. -->
                                        <value>CompanyId</value>
                                        <value>EmployeeId</value>
                                    </set>
                                </property>
                            </bean>


On Mon, Mar 16, 2020 at 3:22 PM Evgenii Zhuravlev <[hidden email]> wrote:
Hi,

You should have one cache per table(query entity) and configure separate CacheKeyConfigurations for each of the caches.

Evgenii

пн, 16 мар. 2020 г. в 11:42, narges saleh <[hidden email]>:
Hi All,

I have a question that might be trivial.
If I define my query entity for each in the XML configuration file and define the affinity key via CacheKeyConfiguration (again in the xml file), considering that here affinity key is defined at IgniteConfiguration level, how do I specify which cache keys (i.e., query entity key fields) will use the affinity key and which ones don't?

Say I have these 4 tables
Employee(company-id, employee-id)
Contractor(company-id, contractor-id)
Customer(company-id, customer-id)
Company(company-id, address)

How do I collocate employee, and contractors with companies but not the customers and companies? Can you provide the CacheKeyConfiguration and keyfields for each query entity?

thanks.
narges saleh narges saleh
Reply | Threaded
Open this post in threaded view
|

Re: Query Entity and Affinity Key

Attached. thanks.

On Mon, Mar 16, 2020 at 8:28 PM Evgenii Zhuravlev <[hidden email]> wrote:
Hi, please share the whole config file

пн, 16 мар. 2020 г. в 15:38, narges saleh <[hidden email]>:
Thanks Evgenii for the reply.
How do I do that in XML configuration file if my query entities are defined solely in the xml file? What does ClassNameOfKey and fieldNameinThatClass represent? I assume I will have one bean for each cache.
<bean class="...CacheConfiguration">
<property name="keyConfiguration">
    <list>
        <bean class="org.apache.ignite.cache.CacheKeyConfiguration">
            <property name="typeName" value="ClassNameOfKey"/>
            <property name="affinityKeyFieldName"
                                                          value="fieldNameInThatClass"/>
        </bean>
    </list>
</property>
</bean>
And the bean for the query entity is:have
                      <bean class="org.apache.ignite.cache.QueryEntity">
                                <property name="keyType" value="java.lang.Integer"/>
                                <property name="valueType" value="PERSON"/>
                                <property name="tableName" value="PERSON"/>
                                <!-- Set fields for value object. -->
                                <property name="fields">
                                    <map>
                                        <entry key="CompanyId" value="java.lang.Integer"/>
                                       <entry key="EmployeeId" value="java.lang.Integer"/>  
                                        <entry key="firstName" value="java.lang.String"/>
                                        <entry key="lastName" value="java.lang.String"/>
                                    </map>
                                </property>
                                <property name="keyFields">
                                    <set>
                                        <!-- These are fields stored in the key. -->
                                        <value>CompanyId</value>
                                        <value>EmployeeId</value>
                                    </set>
                                </property>
                            </bean>


On Mon, Mar 16, 2020 at 3:22 PM Evgenii Zhuravlev <[hidden email]> wrote:
Hi,

You should have one cache per table(query entity) and configure separate CacheKeyConfigurations for each of the caches.

Evgenii

пн, 16 мар. 2020 г. в 11:42, narges saleh <[hidden email]>:
Hi All,

I have a question that might be trivial.
If I define my query entity for each in the XML configuration file and define the affinity key via CacheKeyConfiguration (again in the xml file), considering that here affinity key is defined at IgniteConfiguration level, how do I specify which cache keys (i.e., query entity key fields) will use the affinity key and which ones don't?

Say I have these 4 tables
Employee(company-id, employee-id)
Contractor(company-id, contractor-id)
Customer(company-id, customer-id)
Company(company-id, address)

How do I collocate employee, and contractors with companies but not the customers and companies? Can you provide the CacheKeyConfiguration and keyfields for each query entity?

thanks.

sample-config.xml (14K) Download Attachment
ezhuravlev ezhuravlev
Reply | Threaded
Open this post in threaded view
|

Re: Query Entity and Affinity Key


пн, 16 мар. 2020 г. в 20:07, narges saleh <[hidden email]>:
Attached. thanks.

On Mon, Mar 16, 2020 at 8:28 PM Evgenii Zhuravlev <[hidden email]> wrote:
Hi, please share the whole config file

пн, 16 мар. 2020 г. в 15:38, narges saleh <[hidden email]>:
Thanks Evgenii for the reply.
How do I do that in XML configuration file if my query entities are defined solely in the xml file? What does ClassNameOfKey and fieldNameinThatClass represent? I assume I will have one bean for each cache.
<bean class="...CacheConfiguration">
<property name="keyConfiguration">
    <list>
        <bean class="org.apache.ignite.cache.CacheKeyConfiguration">
            <property name="typeName" value="ClassNameOfKey"/>
            <property name="affinityKeyFieldName"
                                                          value="fieldNameInThatClass"/>
        </bean>
    </list>
</property>
</bean>
And the bean for the query entity is:have
                      <bean class="org.apache.ignite.cache.QueryEntity">
                                <property name="keyType" value="java.lang.Integer"/>
                                <property name="valueType" value="PERSON"/>
                                <property name="tableName" value="PERSON"/>
                                <!-- Set fields for value object. -->
                                <property name="fields">
                                    <map>
                                        <entry key="CompanyId" value="java.lang.Integer"/>
                                       <entry key="EmployeeId" value="java.lang.Integer"/>  
                                        <entry key="firstName" value="java.lang.String"/>
                                        <entry key="lastName" value="java.lang.String"/>
                                    </map>
                                </property>
                                <property name="keyFields">
                                    <set>
                                        <!-- These are fields stored in the key. -->
                                        <value>CompanyId</value>
                                        <value>EmployeeId</value>
                                    </set>
                                </property>
                            </bean>


On Mon, Mar 16, 2020 at 3:22 PM Evgenii Zhuravlev <[hidden email]> wrote:
Hi,

You should have one cache per table(query entity) and configure separate CacheKeyConfigurations for each of the caches.

Evgenii

пн, 16 мар. 2020 г. в 11:42, narges saleh <[hidden email]>:
Hi All,

I have a question that might be trivial.
If I define my query entity for each in the XML configuration file and define the affinity key via CacheKeyConfiguration (again in the xml file), considering that here affinity key is defined at IgniteConfiguration level, how do I specify which cache keys (i.e., query entity key fields) will use the affinity key and which ones don't?

Say I have these 4 tables
Employee(company-id, employee-id)
Contractor(company-id, contractor-id)
Customer(company-id, customer-id)
Company(company-id, address)

How do I collocate employee, and contractors with companies but not the customers and companies? Can you provide the CacheKeyConfiguration and keyfields for each query entity?

thanks.