Can we query the keys as well? Adding QuerySqlField? I think this only
applies to the values right?

Op wo 22 mrt 2023 om 16:08 schreef Stephen Darlington <
stephen.darling...@gridgain.com>:

> You don’t want to look through all the keys. That’s why Ignite has SQL.
>
> On 22 Mar 2023, at 14:44, Humphrey Lopez <hmmlo...@gmail.com> wrote:
>
> We have FAT keys that contain information about the Values we store.
> KEY
> - Object A
> - Object B
>
> VALUE
> - Object Y
>
> The KEY we are using contains several (small) objects as fields. We have
> added to Object A a new field A.TYPE so when searching through the cache we
> could filter on that type.
> I guess we will need to first get all the keys that match that A.TYPE and
> then get the objects with those objects, I think looping through the keys
> will be quicker than looping through all the values.
> Maybe we can query/filter the keys in BinaryMode, and then get all
> corresponding values? Just thinking out loud. We don't want to be
> deserializing unnecessarily values (Object.Y). Maybe with QuerySqlFields on
> the key?
>
> Humphrey
>
> Op wo 22 mrt 2023 om 15:18 schreef Rick Lee <eerick...@gmail.com>:
>
>>
>> Why don’t u put the type to value and leave the id as the key?
>> 「Humphrey Lopez <hmmlo...@gmail.com>」在 2023年3月22日 週三,下午10:16 寫道:
>>
>>> Okay transient is also not the way to go, cause we want to be able to
>>> filter sometimes on that field, so it should be there in the cache. But
>>> thanks for clarifying that the Equals and HashCode is not being used on
>>> BinaryObjects.
>>>
>>> Op wo 22 mrt 2023 om 14:51 schreef Humphrey Lopez <hmmlo...@gmail.com>:
>>>
>>>> I see marking the field as Transient Ignite won't serialize it to
>>>> BinaryObject, is that the way to go?
>>>>
>>>> Humphrey
>>>>
>>>> Op wo 22 mrt 2023 om 14:37 schreef Humphrey Lopez <hmmlo...@gmail.com>:
>>>>
>>>>> Thanks for clarifying that. Is there a way to mark a property/field to
>>>>> be excluded when storing?
>>>>>
>>>>> Humphrey
>>>>>
>>>>> Op wo 22 mrt 2023 om 14:20 schreef Stephen Darlington <
>>>>> stephen.darling...@gridgain.com>:
>>>>>
>>>>>> Ignite doesn’t use your equals or hashCode implementation. Data is
>>>>>> stored as a BinaryObject, and it’s that that is compared for equality.
>>>>>>
>>>>>> On 22 Mar 2023, at 12:14, Humphrey Lopez <hmmlo...@gmail.com> wrote:
>>>>>>
>>>>>> They are in the example only checking the first field when overriding
>>>>>> the equals. And hashCode always returns 1.
>>>>>>
>>>>>> Op wo 22 mrt 2023 om 13:06 schreef Prigoreanu, Alexandru <
>>>>>> prigoreanu.alexan...@anteash.com>:
>>>>>>
>>>>>>> hashCode and equals should depend on the same fields.
>>>>>>>
>>>>>>> On Wed, Mar 22, 2023 at 8:02 AM Humphrey Lopez <hmmlo...@gmail.com>
>>>>>>> wrote:
>>>>>>>
>>>>>>>> Hello, when having a key which equals another key, when trying to
>>>>>>>> retrieve from cache it does not return the expected value. Is this a 
>>>>>>>> bug?
>>>>>>>>
>>>>>>>> I have a reproducible below in kotlin but in java we get the same
>>>>>>>> result (test with Ignite 2.10 and  2.14) and java 11 and 19.
>>>>>>>>
>>>>>>>>
>>>>>>>> import org.apache.ignite.Ignition
>>>>>>>> import org.apache.ignite.configuration.CacheConfiguration
>>>>>>>> import org.assertj.core.api.SoftAssertions
>>>>>>>> import org.junit.jupiter.api.Test
>>>>>>>>
>>>>>>>> class MyTest {
>>>>>>>>
>>>>>>>>     private val key1 = MyKey("ABC", "DEF")
>>>>>>>>     private val key2 = MyKey("ABC", "xxx")
>>>>>>>>
>>>>>>>>     @Test
>>>>>>>>     fun testEquals() {
>>>>>>>>         SoftAssertions.assertSoftly {
>>>>>>>>             it.assertThat(key1).isEqualTo(key2)
>>>>>>>>             it.assertThat(key1 == key2).isTrue
>>>>>>>>         }
>>>>>>>>     }
>>>>>>>>
>>>>>>>>     @Test
>>>>>>>>     fun testWithMap() {
>>>>>>>>         val map = mapOf(Pair(key1, "key1"))
>>>>>>>>
>>>>>>>>         SoftAssertions.assertSoftly {
>>>>>>>>             it.assertThat(map.containsKey(key1)).isTrue
>>>>>>>>             it.assertThat(map.containsKey(key2)).isTrue
>>>>>>>>         }
>>>>>>>>
>>>>>>>>     }
>>>>>>>>
>>>>>>>>     @Test
>>>>>>>>     fun testWithIgnite() {
>>>>>>>>         val ignite = Ignition.start();
>>>>>>>>         val cache = ignite.createCache(CacheConfiguration<MyKey, 
>>>>>>>> String>("mycache"))
>>>>>>>>
>>>>>>>>         cache.put(key1, "key1")
>>>>>>>>         SoftAssertions.assertSoftly {
>>>>>>>>             it.assertThat(cache.containsKey(key1)).isTrue
>>>>>>>>             it.assertThat(cache.containsKey(key2)).isTrue
>>>>>>>>         }
>>>>>>>>     }
>>>>>>>>
>>>>>>>>     private data class MyKey(val id: String, val type: String) {
>>>>>>>>         override fun equals(other: Any?): Boolean {
>>>>>>>>             if (other is MyKey)
>>>>>>>>                 return id == other.id
>>>>>>>>             return false
>>>>>>>>         }
>>>>>>>>
>>>>>>>>         override fun hashCode(): Int {
>>>>>>>>             return 1
>>>>>>>>         }
>>>>>>>>     }
>>>>>>>> }
>>>>>>>>
>>>>>>>>
>>>>>>
>

Reply via email to