You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ha...@apache.org on 2023/04/12 02:15:53 UTC

[iotdb] branch master updated: Optimize updateLastCache interface (#9586)

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

haonan 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 7486211e96 Optimize updateLastCache interface (#9586)
7486211e96 is described below

commit 7486211e9624552aefc547fe21254fbc9c9def38
Author: Haonan <hh...@outlook.com>
AuthorDate: Wed Apr 12 10:15:47 2023 +0800

    Optimize updateLastCache interface (#9586)
---
 .../java/org/apache/iotdb/db/engine/storagegroup/DataRegion.java | 6 ++++--
 .../org/apache/iotdb/db/metadata/cache/DataNodeSchemaCache.java  | 6 +++---
 .../apache/iotdb/db/metadata/cache/DataNodeSchemaCacheTest.java  | 9 +++++----
 3 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/DataRegion.java b/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/DataRegion.java
index 30c398e67d..56f3a5f5aa 100644
--- a/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/DataRegion.java
+++ b/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/DataRegion.java
@@ -1156,7 +1156,8 @@ public class DataRegion implements IDataRegionForQuery {
       // Update cached last value with high priority
       DataNodeSchemaCache.getInstance()
           .updateLastCache(
-              node.getDevicePath().concatNode(node.getMeasurements()[i]),
+              node.getDevicePath(),
+              node.getMeasurements()[i],
               node.composeLastTimeValuePair(i),
               true,
               latestFlushedTime);
@@ -1197,7 +1198,8 @@ public class DataRegion implements IDataRegionForQuery {
       // Update cached last value with high priority
       DataNodeSchemaCache.getInstance()
           .updateLastCache(
-              node.getDevicePath().concatNode(node.getMeasurements()[i]),
+              node.getDevicePath(),
+              node.getMeasurements()[i],
               node.composeTimeValuePair(i),
               true,
               latestFlushedTime);
diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/cache/DataNodeSchemaCache.java b/server/src/main/java/org/apache/iotdb/db/metadata/cache/DataNodeSchemaCache.java
index 9547ddab02..b962e0c358 100644
--- a/server/src/main/java/org/apache/iotdb/db/metadata/cache/DataNodeSchemaCache.java
+++ b/server/src/main/java/org/apache/iotdb/db/metadata/cache/DataNodeSchemaCache.java
@@ -218,12 +218,12 @@ public class DataNodeSchemaCache {
 
   /** get SchemaCacheEntry and update last cache */
   public void updateLastCache(
-      PartialPath seriesPath,
+      PartialPath devicePath,
+      String measurement,
       TimeValuePair timeValuePair,
       boolean highPriorityUpdate,
       Long latestFlushedTime) {
-    SchemaCacheEntry entry =
-        dualKeyCache.get(seriesPath.getDevicePath(), seriesPath.getMeasurement());
+    SchemaCacheEntry entry = dualKeyCache.get(devicePath, measurement);
     if (null == entry) {
       return;
     }
diff --git a/server/src/test/java/org/apache/iotdb/db/metadata/cache/DataNodeSchemaCacheTest.java b/server/src/test/java/org/apache/iotdb/db/metadata/cache/DataNodeSchemaCacheTest.java
index c5504f9c25..0b5910d4df 100644
--- a/server/src/test/java/org/apache/iotdb/db/metadata/cache/DataNodeSchemaCacheTest.java
+++ b/server/src/test/java/org/apache/iotdb/db/metadata/cache/DataNodeSchemaCacheTest.java
@@ -124,6 +124,7 @@ public class DataNodeSchemaCacheTest {
   @Test
   public void testLastCache() throws IllegalPathException {
     // test no cache
+    PartialPath devicePath = new PartialPath("root.sg1.d1");
     PartialPath seriesPath1 = new PartialPath("root.sg1.d1.s1");
     PartialPath seriesPath2 = new PartialPath("root.sg1.d1.s2");
     PartialPath seriesPath3 = new PartialPath("root.sg1.d1.s3");
@@ -144,7 +145,7 @@ public class DataNodeSchemaCacheTest {
 
     // put into last cache when cache not exist
     TimeValuePair timeValuePair = new TimeValuePair(timestamp, value);
-    dataNodeSchemaCache.updateLastCache(seriesPath1, timeValuePair, false, 99L);
+    dataNodeSchemaCache.updateLastCache(devicePath, "s1", timeValuePair, false, 99L);
     TimeValuePair cachedTimeValuePair = dataNodeSchemaCache.getLastCache(seriesPath1);
     Assert.assertNotNull(cachedTimeValuePair);
     Assert.assertEquals(timestamp, cachedTimeValuePair.getTimestamp());
@@ -154,7 +155,7 @@ public class DataNodeSchemaCacheTest {
 
     // same time but low priority
     TimeValuePair timeValuePair2 = new TimeValuePair(timestamp, value2);
-    dataNodeSchemaCache.updateLastCache(seriesPath1, timeValuePair2, false, 100L);
+    dataNodeSchemaCache.updateLastCache(devicePath, "s1", timeValuePair2, false, 100L);
     TimeValuePair cachedTimeValuePair2 = dataNodeSchemaCache.getLastCache(seriesPath1);
     Assert.assertNotNull(cachedTimeValuePair2);
     Assert.assertEquals(timestamp, cachedTimeValuePair2.getTimestamp());
@@ -163,7 +164,7 @@ public class DataNodeSchemaCacheTest {
     Assert.assertNull(dataNodeSchemaCache.getLastCache(seriesPath3));
 
     // same time but high priority
-    dataNodeSchemaCache.updateLastCache(seriesPath1, timeValuePair2, true, 100L);
+    dataNodeSchemaCache.updateLastCache(devicePath, "s1", timeValuePair2, true, 100L);
     cachedTimeValuePair2 = dataNodeSchemaCache.getLastCache(seriesPath1);
     Assert.assertNotNull(cachedTimeValuePair2);
     Assert.assertEquals(timestamp, cachedTimeValuePair2.getTimestamp());
@@ -173,7 +174,7 @@ public class DataNodeSchemaCacheTest {
 
     // put into last cache when cache already exist
     TimeValuePair timeValuePair3 = new TimeValuePair(timestamp2, value3);
-    dataNodeSchemaCache.updateLastCache(seriesPath1, timeValuePair3, false, 100L);
+    dataNodeSchemaCache.updateLastCache(devicePath, "s1", timeValuePair3, false, 100L);
     TimeValuePair cachedTimeValuePair3 = dataNodeSchemaCache.getLastCache(seriesPath1);
     Assert.assertNotNull(cachedTimeValuePair3);
     Assert.assertEquals(timestamp2, cachedTimeValuePair3.getTimestamp());