Hi, we tried to set id in Key as our affinity key. Our c++ Key is defined 
namespace ignite 
{ 
namespace binary 
{ 
struct Key 
{ 
    std::string id; 
    bool flag; 
    Key() 
        : id() , flag(false) 
    { 
    } 

    Key(const std::string& id, bool flag = false) 
        : id(id) 
        , flag(flag) 
    { 
    } 

    Key(const  Key& rhs) 
        : id(rhs.id) 
        , flag(rhs.flag) 
    { 
    } 

    bool operator<(const Key& rhs) const 
    { 
        return (id == rhs.id) ? 
          flag < rhs.flag : id < rhs.id; 
    } 

    bool operator==(const Key& rhs) const 
    { 
        return id == rhs.id && flag == rhs.flag; 
    } 

    bool operator!=(const Key& rhs) const 
    { 
        return !(*this == rhs); 
    } 

    ~Key() 
    { 
    } 

    // METHODS 
    bool isEmpty() const { return id.empty(); } 
}; 
template<> 
struct BinaryType<Key> 
{ 
    static int32_t GetTypeId() 
    { 
        return GetBinaryStringHashCode("Key"); 
    } 

    static void GetTypeName(native_std::string& dst) 
    { 
        dst = "Key"; 
    } 

    static int32_t GetFieldId(const char* name) 
    { 
        return GetBinaryStringHashCode(name); 
    } 

    static bool IsNull(const Key& key) 
    { 
        return und.isEmpty(); 
    } 

    static void GetNull(Key& key) 
    { 
        key = Key(); 
    } 

    static void Write(BinaryWriter& writer, Key& key) 
    { 
        writer.WriteString("id", key.id); 
        writer.WriteBool("flag", key.flag); 
    } 

    static void Read(BinaryReader& reader, Key& key) 
    { 
        key.id = reader.ReadString("id"); 
        key.flag = reader.ReadBool("flag"); 
    } 
}; 
} 
} 

The cache key configuration is
<util:list id="cacheKeyConfiguration">
      <bean class="org.apache.ignite.cache.CacheKeyConfiguration">
        <property name="typeName" value="Key"/>
        <property name="affinityKeyFieldName" value="id"/>
      </bean>
    </util:list>

However, after we populated data we find some keys with same ids but
different flag does not reside on the same cache node. Do I missed anything
is the configuration ? Thanks
    



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Reply via email to