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/11 12:18:27 UTC

[iotdb] branch opti_last_cache_interface created (now 2f4aa949bf)

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

haonan pushed a change to branch opti_last_cache_interface
in repository https://gitbox.apache.org/repos/asf/iotdb.git


      at 2f4aa949bf opti_last_cache_interface

This branch includes the following new commits:

     new 2f4aa949bf opti_last_cache_interface

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[iotdb] 01/01: opti_last_cache_interface

Posted by ha...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

haonan pushed a commit to branch opti_last_cache_interface
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit 2f4aa949bf29798ce49a275976c2d17ab1daa4ca
Author: HTHou <hh...@outlook.com>
AuthorDate: Tue Apr 11 20:17:28 2023 +0800

    opti_last_cache_interface
---
 .../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());