I actually don’t see your suggested version is simpler: the key is hashed
two times (maybe JVM could cache hashcode) which causes more cpu time. It
is more natural to just compute one time of key hash. Right, in our case
here namespace could not change, but it is just a special case here. I
would prefer to do it in a general way: one time hash and cache the result
and generally avoid race condition.


On Sat, Feb 22, 2020 at 11:00 PM GitBox <[email protected]> wrote:

> narendly commented on a change in pull request #799: [MSDS] Add REST
> endpoint to get mapping of all sharding keys by realm
> URL: https://github.com/apache/helix/pull/799#discussion_r382970187
>
>
>
>  ##########
>  File path:
> helix-rest/src/main/java/org/apache/helix/rest/metadatastore/ZkMetadataStoreDirectory.java
>  ##########
>  @@ -111,6 +111,16 @@ public ZkMetadataStoreDirectory(Map<String, String>
> routingZkAddressMap)
>      return allShardingKeys;
>    }
>
> +  @Override
> +  public Map<String, List<String>> getShardingKeysByRealm(String
> namespace) {
> +    Map<String, List<String>> shardingKeysByRealmMap =
> _realmToShardingKeysMap.get(namespace);
> +    if (shardingKeysByRealmMap == null) {
> +      throw new NoSuchElementException("Namespace " + namespace + " does
> not exist!");
> +    }
> +
> +    return shardingKeysByRealmMap;
>
>  Review comment:
>    That's a very good point and I am glad that you've considered potential
> cases like the one you described in your comments.
>
>    The potential race condition you raised would be valid if we allowed
> `namespace`s to be removed, but thanks to the way we define namespaces,
> they are never removed (only updated). So I don't think we need to be
> worried about that particular race condition here - do you agree? If so, we
> could simplify the code as originally suggested.
>
> ----------------------------------------------------------------
> This is an automated message from the Apache Git Service.
> To respond to the message, please log on to GitHub and use the
> URL above to go to the specific comment.
>
> For queries about this service, please contact Infrastructure at:
> [email protected]
>
>
> With regards,
> Apache Git Services
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>

Reply via email to