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

justinchen pushed a commit to branch dev/1.3
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/dev/1.3 by this push:
     new 2cd887ed408 [To dev/1.3] Made the schemaRegionMap nonnull for 
SchemaEngine (#15775)  (#15777)
2cd887ed408 is described below

commit 2cd887ed408c247a062b720a9d9e5696c6a56cee
Author: Caideyipi <[email protected]>
AuthorDate: Mon Oct 27 12:19:53 2025 +0800

    [To dev/1.3] Made the schemaRegionMap nonnull for SchemaEngine (#15775)  
(#15777)
---
 .../apache/iotdb/db/schemaengine/SchemaEngine.java | 27 ++++++++--------------
 1 file changed, 10 insertions(+), 17 deletions(-)

diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/SchemaEngine.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/SchemaEngine.java
index cf5dc24169f..9b766b4c514 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/SchemaEngine.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/SchemaEngine.java
@@ -76,7 +76,7 @@ public class SchemaEngine {
   private final SchemaRegionLoader schemaRegionLoader;
 
   @SuppressWarnings("java:S3077")
-  private volatile Map<SchemaRegionId, ISchemaRegion> schemaRegionMap;
+  private final Map<SchemaRegionId, ISchemaRegion> schemaRegionMap = new 
ConcurrentHashMap<>();
 
   private ScheduledExecutorService timedForceMLogThread;
 
@@ -115,8 +115,6 @@ public class SchemaEngine {
     // CacheMemoryManager
     schemaMetricManager = new SchemaMetricManager(schemaEngineStatistics);
 
-    schemaRegionMap = new ConcurrentHashMap<>();
-
     initSchemaRegion();
 
     if 
(!(config.getSchemaRegionConsensusProtocolClass().equals(ConsensusFactory.RATIS_CONSENSUS))
@@ -234,11 +232,8 @@ public class SchemaEngine {
   }
 
   public void forceMlog() {
-    Map<SchemaRegionId, ISchemaRegion> schemaRegionMap = this.schemaRegionMap;
-    if (schemaRegionMap != null) {
-      for (ISchemaRegion schemaRegion : schemaRegionMap.values()) {
-        schemaRegion.forceMlog();
-      }
+    for (ISchemaRegion schemaRegion : schemaRegionMap.values()) {
+      schemaRegion.forceMlog();
     }
   }
 
@@ -253,15 +248,13 @@ public class SchemaEngine {
       timedForceMLogThread = null;
     }
 
-    if (schemaRegionMap != null) {
-      // SchemaEngineStatistics will be clear after clear all schema region
-      for (ISchemaRegion schemaRegion : schemaRegionMap.values()) {
-        schemaRegion.clear();
-      }
-      schemaRegionMap.clear();
-      schemaRegionMap = null;
-      logger.info("clear schema region map.");
+    // SchemaEngineStatistics will be clear after clear all schema region
+    for (ISchemaRegion schemaRegion : schemaRegionMap.values()) {
+      schemaRegion.clear();
     }
+    schemaRegionMap.clear();
+    logger.info("clear schema region map.");
+
     // SchemaMetric should be cleared lastly
     if (schemaMetricManager != null) {
       schemaMetricManager.clear();
@@ -369,7 +362,7 @@ public class SchemaEngine {
   }
 
   public int getSchemaRegionNumber() {
-    return schemaRegionMap == null ? 0 : schemaRegionMap.size();
+    return schemaRegionMap.size();
   }
 
   public Map<Integer, Long> countDeviceNumBySchemaRegion(List<Integer> 
schemaIds) {

Reply via email to