This is an automated email from the ASF dual-hosted git repository.
justinchen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new bbe7882f297 Made the schemaRegionMap nonnull for SchemaEngine (#15775)
bbe7882f297 is described below
commit bbe7882f29709d8d6943dc20808d78450af15152
Author: Caideyipi <[email protected]>
AuthorDate: Thu Oct 23 17:18:22 2025 +0800
Made the schemaRegionMap nonnull for SchemaEngine (#15775)
---
.../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 700666eb69a..3f59f9edf68 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
@@ -78,7 +78,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;
@@ -117,8 +117,6 @@ public class SchemaEngine {
// CacheMemoryManager
schemaMetricManager = new SchemaMetricManager(schemaEngineStatistics);
- schemaRegionMap = new ConcurrentHashMap<>();
-
initSchemaRegion();
if
(!(config.getSchemaRegionConsensusProtocolClass().equals(ConsensusFactory.RATIS_CONSENSUS))
@@ -213,11 +211,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();
}
}
@@ -232,15 +227,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();
@@ -348,7 +341,7 @@ public class SchemaEngine {
}
public int getSchemaRegionNumber() {
- return schemaRegionMap == null ? 0 : schemaRegionMap.size();
+ return schemaRegionMap.size();
}
public Map<Integer, Long> countDeviceNumBySchemaRegion(final List<Integer>
schemaIds) {