Hi Matthias,

Thanks. But yes, I am comparing map with that.map … the comment is probably for 
the previous variable name.

I can use String, Int, Enum, Long type keys in the Key that I send in the Query 
getKvState … but the moment I introduce a TreeMap, even though it contains a 
simple one entry String, String, it doesn’t work … 

Thanks,
Sandeep

> On 23-Mar-2021, at 7:00 PM, Matthias Pohl <matth...@ververica.com> wrote:
> 
> Hi Sandeep,
> the equals method does not compare the this.map with that.map but 
> that.dimensions. ...at least in your commented out code. Might this be the 
> problem?
> 
> Best,
> Matthias
> 
> On Tue, Mar 23, 2021 at 5:28 AM Sandeep khanzode <sand...@shiftright.ai 
> <mailto:sand...@shiftright.ai>> wrote:
> Hi,
> 
> I have a stream that exposes the state for Queryable State.
> 
> I am using the key as follows:
> 
> public class MyKey {
>     private Long first;
>     private EnumType myType;
>     private Long second;
> 
>     private TreeMap<String, String> map;
>     @Override
>     public boolean equals(Object o) {
>         if (this == o) return true;
>         if (o == null || getClass() != o.getClass()) return false;
>         MyKey that = (MyKey) o;
>         boolean isEqual = first.longValue() == that.first.longValue() &&
>                 myTime.name().equalsIgnoreCase(that.myTime.name()) &&
>                 second.longValue() == that.second.longValue();// &&
> //                map.equals(that.dimensions);
>         return isEqual;
>     }
> 
>     @Override
>     public int hashCode() {
>         int result = first != null ? first.hashCode() : 0;
>         result = 31 * result + (myType != null ? myType.name().hashCode() : 
> 0);
>         result = 31 * result + (second != null ? second.hashCode() : 0);
> //        result = 31 * result + (map != null ? map.hashCode() : 0);
>         return result;
>     }
> }
> 
> 
> If I only set the first three members for the key class, then the key lookup 
> works correctly.
> 
> If I add the TreeMap, then the lookup always errors with the message; “No 
> state found for the given key/namespace”.
> 
> What am I dong wrong with the TreeMap as a member in the Key class for 
> equals/hashcode?
> 
> Thanks,
> Sandeep

Reply via email to