pkuwm 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_r382972521
##########
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:
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. What if
namespace change could be supported in the future? I would prefer to do it in a
general way: one time hash and cache the result and generally avoid race
condition. So decouple it from namespace change.
----------------------------------------------------------------
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]