Affinity on non-key field

classic Classic list List threaded Threaded
2 messages Options
yfernando yfernando
Reply | Threaded
Open this post in threaded view
|

Affinity on non-key field

If you have a cache where you have the key as ObjectKey and value as ObjectValue, and the classes are like the following, is it possible in Ignite to have data co-location based on a non-key attribute? In this case on the private int c field in ObjectValue? I believe @AffinityKeyMapped annotation works only on Key fields? 

public class ObjectKey{ 
    private int a; 
    private int b; 

    public int getA() { 
        return a; 
    } 

    public int getB() { 
        return b; 
    } 

    public ObjectKey(int a, int b) { 
        this.a = a; 
        this.b = b; 
    } 


public class ObjectValue{ 
    private int c;
    private String someValue; 

    public int getC() { 
        return c; 
    } 

    public String getSomeValue() { 
        return someValue; 
    } 

    public ObjectValue(int c, String someValue) { 
        this.c = c; 
        this.someValue = someValue; 
    } 

_________________________________________________________

This email, its contents, and any attachments transmitted with it are intended only for the addressee(s) and may be confidential and legally privileged. We do not waive any confidentiality by misdelivery. If you have received this email in error, please notify the sender immediately and delete it. You should not copy it, forward it or otherwise use the contents, attachments or information in any way. Any liability for viruses is excluded to the fullest extent permitted by law.

Tudor Capital Europe LLP (TCE) is authorised and regulated by The Financial Conduct Authority (the FCA). TCE is registered as a limited liability partnership in England and Wales No: OC340673 with its registered office at 10 New Burlington Street, London, W1S 3BE, United Kingdom

stephendarlington stephendarlington
Reply | Threaded
Open this post in threaded view
|

Re: Affinity on non-key field

No, and it’s not really possible. The problem is with something like IgniteCache.get(), the only information it has to find the value is the key. In that sense you’d be able to co-locate the data when you saved it to the cache, but you’d have no efficient way to find it again afterwards.

Regards,
Stephen

On 30 Jul 2019, at 12:05, Yohan Fernando <[hidden email]> wrote:

If you have a cache where you have the key as ObjectKey and value as ObjectValue, and the classes are like the following, is it possible in Ignite to have data co-location based on a non-key attribute? In this case on the private int c field in ObjectValue? I believe @AffinityKeyMapped annotation works only on Key fields? 

public class ObjectKey{ 
    private int a; 
    private int b; 

    public int getA() { 
        return a; 
    } 

    public int getB() { 
        return b; 
    } 

    public ObjectKey(int a, int b) { 
        this.a = a; 
        this.b = b; 
    } 


public class ObjectValue{ 
    private int c;
    private String someValue; 

    public int getC() { 
        return c; 
    } 

    public String getSomeValue() { 
        return someValue; 
    } 

    public ObjectValue(int c, String someValue) { 
        this.c = c; 
        this.someValue = someValue; 
    } 

_________________________________________________________

This email, its contents, and any attachments transmitted with it are intended only for the addressee(s) and may be confidential and legally privileged. We do not waive any confidentiality by misdelivery. If you have received this email in error, please notify the sender immediately and delete it. You should not copy it, forward it or otherwise use the contents, attachments or information in any way. Any liability for viruses is excluded to the fullest extent permitted by law.

Tudor Capital Europe LLP (TCE) is authorised and regulated by The Financial Conduct Authority (the FCA). TCE is registered as a limited liability partnership in England and Wales No: OC340673 with its registered office at 10 New Burlington Street, London, W1S 3BE, United Kingdom