I am attempting to use a custom Java class as a key in an IgniteCache instance with persistence enabled. I ran into some issues, so I made this class very simple for testing the problem. This class has an int member that is set to 1 in the constructor, and then has equals overridden to return true, and hashcode overridden to return 1. I created a test that creates 100 different keys and writes each one to the cache. At the end I query the size of the cache. The first time I run this test with an empty cache, the size of the cache after writes is 1, which is what I would expect since all of the keys should be equal. However, when I run the test again, the size of the cache is 1 before the writes (which is expected), but 2 after the writes. Every time I run the test without clearing the cache will result in the cache size growing by 1. So key equality is not behaving as I would expect across runs. I do not have this issue when using String. How does Ignite define key equality if not by using equals/hashcode? Why would the same keys across runs not be treated as equal?
Custom Java Objects as Key in IgniteCache with persistence enabled
Mitchell Rathbun (BLOOMBERG/ 731 LEX) Wed, 18 Dec 2019 16:14:07 -0800
- Custom Java Objects as Key in Ignite... Mitchell Rathbun (BLOOMBERG/ 731 LEX)
- Re: Custom Java Objects as Key ... shishkovilja
- Re: Custom Java Objects as Key ... Mitchell Rathbun (BLOOMBERG/ 731 LEX)
- Re: Custom Java Objects as ... Evgenii Zhuravlev
