xyuanlu commented on code in PR #2619:
URL: https://github.com/apache/helix/pull/2619#discussion_r1335094742


##########
meta-client/src/main/java/org/apache/helix/metaclient/impl/zk/ZkMetaClientCache.java:
##########
@@ -106,26 +103,56 @@ public int countDirectChildren(final String key) {
         throw new MetaClientException("Not implemented yet.");
     }
 
+    private void populateAllCache() {
+        if (_cacheData) {

Review Comment:
   Add to do here as we could do parallel update in future. 



##########
meta-client/src/main/java/org/apache/helix/metaclient/impl/zk/ZkMetaClientCache.java:
##########
@@ -106,26 +103,56 @@ public int countDirectChildren(final String key) {
         throw new MetaClientException("Not implemented yet.");
     }
 
+    private void populateAllCache() {
+        if (_cacheData) {
+            try {
+                List<String> children = _cacheClient.getChildren(_rootEntry);
+                for (String child : children) {
+                    String childPath = _rootEntry + "/" + child;
+                    T dataRecord = _cacheClient.readData(childPath, true);

Review Comment:
   can we do batch read? 



##########
meta-client/src/main/java/org/apache/helix/metaclient/impl/zk/ZkMetaClientCache.java:
##########
@@ -82,16 +87,8 @@ public T get(final String key) {
     @Override
     public List<T> get(List<String> keys) {
         List<T> dataList = new ArrayList<>();
-        if (_cacheData) {
-            for (String key : keys) {
-                getDataCacheMap().computeIfAbsent(key, k -> 
_cacheClient.readData(k, true));
-                dataList.add(getDataCacheMap().get(key));
-            }
-        }
-        else {
-            for (String key : keys) {
-                dataList.add(_cacheClient.readData(key, true));
-            }
+        for (String key : keys) {
+            dataList.add(get(key));

Review Comment:
   same as above.



##########
meta-client/src/main/java/org/apache/helix/metaclient/impl/zk/ZkMetaClientCache.java:
##########
@@ -70,10 +69,16 @@ public ZkMetaClientCache(ZkMetaClientConfig config, 
MetaClientCacheConfig cacheC
         }
     }
 
+    /**
+     * Get data for a given key.
+     * If datacache is enabled, will fetch for cache. If it doesn't exist
+     * returns null (for when initial populating cache is in progress).
+     * @param key key to identify the entry
+     * @return data for the key
+     */
     @Override
     public T get(final String key) {
         if (_cacheData) {
-            getDataCacheMap().computeIfAbsent(key, k -> 
_cacheClient.readData(k, true));
             return getDataCacheMap().get(key);

Review Comment:
   shall we differentiate if key is not in ZK, or it is in ZK but not populated 
to cache yet?



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to