You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@geode.apache.org by "Owen Nichols (Jira)" <ji...@apache.org> on 2022/06/22 20:46:02 UTC

[jira] [Closed] (GEODE-9345) Refactor RedisSet set operations to not do so much set copying

     [ https://issues.apache.org/jira/browse/GEODE-9345?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Owen Nichols closed GEODE-9345.
-------------------------------

> Refactor RedisSet set operations to not do so much set copying
> --------------------------------------------------------------
>
>                 Key: GEODE-9345
>                 URL: https://issues.apache.org/jira/browse/GEODE-9345
>             Project: Geode
>          Issue Type: Improvement
>          Components: redis
>    Affects Versions: 1.15.0
>            Reporter: Donal Evans
>            Priority: Major
>              Labels: redis
>             Fix For: 1.15.0
>
>
> The implementation of the (unsupported at time of ticket creation) sunion, sunionstore, sdiff, sdiffstore, sinter and sinterstore commands includes potentially expensive set copying as part of the calls to {{smembers()}} and {{internalsmembers()}}:
>  
> {code:java}
> @Override
> public Set<byte[]> smembers(RedisKey key) {
>   return stripedExecute(key, () -> new HashSet<>(getRedisSet(key, true).smembers()));
> }
> @Override
> public Set<byte[]> internalsmembers(RedisKey key) {
>   return stripedExecute(key, () -> new HashSet<>(getRedisSet(key, false).smembers()));
> }{code}
> and in {{computeSetOp()}}:
>  
> {code:java}
> if (result == null) {
>   result = new ObjectOpenCustomHashSet<>(set, ByteArrays.HASH_STRATEGY);
> } else {
>   switch (setOp) {
>     case UNION:
>       result.addAll(set);
>       break;
>     case INTERSECTION:
>       set = new ObjectOpenCustomHashSet<>(set, ByteArrays.HASH_STRATEGY);
>       result.retainAll(set);
>       break;
>     case DIFF:
>       set = new ObjectOpenCustomHashSet<>(set, ByteArrays.HASH_STRATEGY);
>       result.removeAll(set);
>       break;
>   }
> }{code}
>  
> due to the need to use a custom hash set implementation to properly handle equality comparisons between byte arrays, but the current implementation used, ObjectOpenCustomHashSet, causes serialization errors when returned from {{smembers()}} and {{internalsmembers()}}.
> To avoid unnecessary set copying, a way should be found to allow an {{ObjectOpenCustomHashSet}} to be returned from {{smembers()}} and {{internalsmembers()}} without causing serialization errors. The best approach would probably be to have the implementation of {{ObjectOpenCustomHashSet}} also implement {{DataSerializableFixedID}}, which would allow it to be efficiently serialized in a backwards-compatible way.



--
This message was sent by Atlassian Jira
(v8.20.7#820007)