KnightChess commented on code in PR #9158:
URL: https://github.com/apache/hudi/pull/9158#discussion_r1260502975


##########
hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/client/common/HoodieSparkEngineContext.java:
##########
@@ -207,15 +206,15 @@ public void putCachedDataIds(HoodieDataCacheKey cacheKey, 
int... ids) {
   @Override
   public List<Integer> getCachedDataIds(HoodieDataCacheKey cacheKey) {
     synchronized (cachedRddIds) {
-      return cachedRddIds.getOrDefault(cacheKey, Collections.emptyList());
+      return cachedRddIds.getOrDefault(cacheKey, new ArrayList<>());

Review Comment:
   fix this error, empty list class can not add item, I will merge two lists
   ```shell
   java.lang.UnsupportedOperationException
        at java.util.AbstractList.add(AbstractList.java:148)
        at java.util.AbstractList.add(AbstractList.java:108)
   ```
   Another way, I can new a ArrayList to addAll items, just like:
   ```java
   if (config.areReleaseResourceEnabled()) {
         HoodieSparkEngineContext sparkEngineContext = 
(HoodieSparkEngineContext) context;
         Map<Integer, JavaRDD<?>> allCachedRdds = 
sparkEngineContext.getJavaSparkContext().getPersistentRDDs();
         List<Integer> allDataIds = new 
ArrayList<>(sparkEngineContext.removeCachedDataIds(HoodieDataCacheKey.of(basePath,
 instantTime)));
         if (config.isMetadataTableEnabled()) {
           String metadataTableBasePath = 
HoodieTableMetadata.getMetadataTableBasePath(basePath);
           
allDataIds.addAll(sparkEngineContext.removeCachedDataIds(HoodieDataCacheKey.of(metadataTableBasePath,
 instantTime)));
         }
         for (int id : allDataIds) {
           if (allCachedRdds.containsKey(id)) {
             allCachedRdds.get(id).unpersist();
           }
         }
       }
   ```



-- 
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: commits-unsubscr...@hudi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to