You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@amoro.apache.org by cz...@apache.org on 2024/09/21 03:08:57 UTC

(amoro) branch master updated: [hotfix] Fix null pointer exception for OverviewCache (#3215)

This is an automated email from the ASF dual-hosted git repository.

czy006 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/amoro.git


The following commit(s) were added to refs/heads/master by this push:
     new acf3db1f4 [hotfix] Fix null pointer exception for OverviewCache (#3215)
acf3db1f4 is described below

commit acf3db1f47e4d7305a7ab210870cc1de1296335b
Author: Marig_Weizhi <ma...@foxmail.com>
AuthorDate: Sat Sep 21 11:08:53 2024 +0800

    [hotfix] Fix null pointer exception for OverviewCache (#3215)
    
    fix null pointer exception for OverviewCache
---
 .../java/org/apache/amoro/server/dashboard/OverviewCache.java    | 9 +++++----
 .../apache/amoro/server/optimizing/plan/OptimizingPlanner.java   | 2 +-
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/amoro-ams/src/main/java/org/apache/amoro/server/dashboard/OverviewCache.java b/amoro-ams/src/main/java/org/apache/amoro/server/dashboard/OverviewCache.java
index 20b5b6222..50994b541 100644
--- a/amoro-ams/src/main/java/org/apache/amoro/server/dashboard/OverviewCache.java
+++ b/amoro-ams/src/main/java/org/apache/amoro/server/dashboard/OverviewCache.java
@@ -185,7 +185,8 @@ public class OverviewCache {
     long totalTableSize = 0L;
 
     // table size
-    List<MetricKey> metricKeys = metricDefineMap.get(TABLE_SUMMARY_TOTAL_FILES_SIZE);
+    List<MetricKey> metricKeys =
+        metricDefineMap.getOrDefault(TABLE_SUMMARY_TOTAL_FILES_SIZE, ImmutableList.of());
     for (MetricKey metricKey : metricKeys) {
       String tableName = fullTableName(metricKey);
       allCatalogs.add(catalog(metricKey));
@@ -197,7 +198,7 @@ public class OverviewCache {
     }
 
     // file count
-    metricKeys = metricDefineMap.get(TABLE_SUMMARY_TOTAL_FILES);
+    metricKeys = metricDefineMap.getOrDefault(TABLE_SUMMARY_TOTAL_FILES, ImmutableList.of());
     for (MetricKey metricKey : metricKeys) {
       String tableName = fullTableName(metricKey);
       allCatalogs.add(catalog(metricKey));
@@ -209,7 +210,7 @@ public class OverviewCache {
     }
 
     // health score
-    metricKeys = metricDefineMap.get(TABLE_SUMMARY_HEALTH_SCORE);
+    metricKeys = metricDefineMap.getOrDefault(TABLE_SUMMARY_HEALTH_SCORE, ImmutableList.of());
     for (MetricKey metricKey : metricKeys) {
       String tableName = fullTableName(metricKey);
       allCatalogs.add(catalog(metricKey));
@@ -221,7 +222,7 @@ public class OverviewCache {
 
     this.totalDataSize.set(totalTableSize);
     this.totalCatalog.set(allCatalogs.size());
-    this.totalTableCount.set(metricKeys.size());
+    this.totalTableCount.set(topTableItemMap.size());
     this.allTopTableItem = new ArrayList<>(topTableItemMap.values());
     addAndCheck(new OverviewDataSizeItem(ts, totalTableSize));
   }
diff --git a/amoro-ams/src/main/java/org/apache/amoro/server/optimizing/plan/OptimizingPlanner.java b/amoro-ams/src/main/java/org/apache/amoro/server/optimizing/plan/OptimizingPlanner.java
index 66f311f2f..f0c30eb43 100644
--- a/amoro-ams/src/main/java/org/apache/amoro/server/optimizing/plan/OptimizingPlanner.java
+++ b/amoro-ams/src/main/java/org/apache/amoro/server/optimizing/plan/OptimizingPlanner.java
@@ -153,7 +153,7 @@ public class OptimizingPlanner extends OptimizingEvaluator {
       return cacheAndReturnTasks(Collections.emptyList());
     }
 
-    List<PartitionEvaluator> evaluators = new ArrayList<>(partitionPlanMap.values());
+    List<PartitionEvaluator> evaluators = new ArrayList<>(needOptimizingPlanMap.values());
     // prioritize partitions with high cost to avoid starvation
     evaluators.sort(Comparator.comparing(PartitionEvaluator::getWeight, Comparator.reverseOrder()));