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

jackietien pushed a commit to branch ty/object_type
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit ed293bba24bea7a09268ab845a3ae46bcc33225b
Author: Caideyipi <[email protected]>
AuthorDate: Thu Nov 27 09:47:38 2025 +0800

    Fixed the calculation error of schema cache (#16818)
    
    * ff
    
    * back-roll
    
    (cherry picked from commit ddcc64618b5eac6a01de7be6d412dd32fba8c3b7)
---
 .../relational/metadata/fetcher/cache/TableDeviceLastCache.java   | 6 +++---
 .../relational/metadata/fetcher/cache/TreeDeviceNormalSchema.java | 8 ++++++--
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/metadata/fetcher/cache/TableDeviceLastCache.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/metadata/fetcher/cache/TableDeviceLastCache.java
index 62dbfdccdeb..f2ca8108a34 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/metadata/fetcher/cache/TableDeviceLastCache.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/metadata/fetcher/cache/TableDeviceLastCache.java
@@ -120,14 +120,14 @@ public class TableDeviceLastCache {
           (measurementKey, tvPair) -> {
             if (Objects.isNull(newPair)) {
               diff.addAndGet(
-                  -((isTableModel ? 0 : (int) 
RamUsageEstimator.sizeOf(finalMeasurement))
-                      + getTVPairEntrySize(tvPair)));
+                  -(isTableModel ? 0 : (int) 
RamUsageEstimator.sizeOf(finalMeasurement))
+                      + getTVPairEntrySize(tvPair));
               return null;
             }
             if (Objects.isNull(tvPair)) {
               diff.addAndGet(
                   (isTableModel ? 0 : (int) 
RamUsageEstimator.sizeOf(finalMeasurement))
-                      + (int) RamUsageEstimator.HASHTABLE_RAM_BYTES_PER_ENTRY);
+                      + getTVPairEntrySize(newPair));
               return newPair;
             }
             return tvPair;
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/metadata/fetcher/cache/TreeDeviceNormalSchema.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/metadata/fetcher/cache/TreeDeviceNormalSchema.java
index bca4dbdaa02..4e9c2fe9fde 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/metadata/fetcher/cache/TreeDeviceNormalSchema.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/metadata/fetcher/cache/TreeDeviceNormalSchema.java
@@ -88,7 +88,10 @@ public class TreeDeviceNormalSchema implements IDeviceSchema 
{
     final SchemaCacheEntry putEntry = new SchemaCacheEntry(schema, tagMap);
     final SchemaCacheEntry cachedEntry = measurementMap.put(measurement, 
putEntry);
     return Objects.isNull(cachedEntry)
-        ? (int) (RamUsageEstimator.sizeOf(measurement) + 
SchemaCacheEntry.estimateSize(putEntry))
+        ? (int)
+            (RamUsageEstimator.sizeOf(measurement)
+                + SchemaCacheEntry.estimateSize(putEntry)
+                + RamUsageEstimator.HASHTABLE_RAM_BYTES_PER_ENTRY)
         : SchemaCacheEntry.estimateSize(putEntry) - 
SchemaCacheEntry.estimateSize(cachedEntry);
   }
 
@@ -101,7 +104,8 @@ public class TreeDeviceNormalSchema implements 
IDeviceSchema {
                 entry ->
                     Math.toIntExact(
                         RamUsageEstimator.sizeOf(entry.getKey())
-                            + SchemaCacheEntry.estimateSize(entry.getValue())))
+                            + SchemaCacheEntry.estimateSize(entry.getValue())
+                            + RamUsageEstimator.HASHTABLE_RAM_BYTES_PER_ENTRY))
             .reduce(0, Integer::sum);
   }
 }

Reply via email to