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

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


The following commit(s) were added to refs/heads/h/TableModelWrite by this push:
     new eb592d1248c fix review
eb592d1248c is described below

commit eb592d1248c4c07d41887e168f226cc40324b785
Author: HTHou <[email protected]>
AuthorDate: Mon Apr 22 15:28:56 2024 +0800

    fix review
---
 .../tsfile/timeindex/ArrayDeviceTimeIndex.java     | 32 +++++-----
 .../tsfile/timeindex/PlainDeviceTimeIndex.java     | 70 ----------------------
 2 files changed, 16 insertions(+), 86 deletions(-)

diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/tsfile/timeindex/ArrayDeviceTimeIndex.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/tsfile/timeindex/ArrayDeviceTimeIndex.java
index 528648822f4..9b105b0bf20 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/tsfile/timeindex/ArrayDeviceTimeIndex.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/tsfile/timeindex/ArrayDeviceTimeIndex.java
@@ -19,6 +19,7 @@
 
 package org.apache.iotdb.db.storageengine.dataregion.tsfile.timeindex;
 
+import org.apache.iotdb.commons.exception.IllegalPathException;
 import org.apache.iotdb.commons.path.PartialPath;
 import org.apache.iotdb.commons.utils.TimePartitionUtils;
 import org.apache.iotdb.db.exception.PartitionViolationException;
@@ -402,22 +403,8 @@ public class ArrayDeviceTimeIndex implements ITimeIndex {
     long startTime = Long.MAX_VALUE;
     long endTime = Long.MIN_VALUE;
     for (Entry<IDeviceID, Integer> entry : deviceToIndex.entrySet()) {
-      if (deviceMatchInfo.contains(entry.getKey())) {
-        hasMatchedDevice = true;
-        if (startTimes[entry.getValue()] < startTime) {
-          startTime = startTimes[entry.getValue()];
-        }
-        if (endTimes[entry.getValue()] > endTime) {
-          endTime = endTimes[entry.getValue()];
-        }
-      } else {
-        IDeviceID deviceID = entry.getKey();
-        String[] devicePath = new String[deviceID.segmentNum()];
-        for (int i = 0; i < devicePath.length; i++) {
-          devicePath[i] = deviceID.segment(i).toString();
-        }
-        if (devicePattern.matchFullPath(new PartialPath(devicePath))) {
-          deviceMatchInfo.add(entry.getKey());
+      try {
+        if (deviceMatchInfo.contains(entry.getKey())) {
           hasMatchedDevice = true;
           if (startTimes[entry.getValue()] < startTime) {
             startTime = startTimes[entry.getValue()];
@@ -425,7 +412,20 @@ public class ArrayDeviceTimeIndex implements ITimeIndex {
           if (endTimes[entry.getValue()] > endTime) {
             endTime = endTimes[entry.getValue()];
           }
+        } else {
+          if (devicePattern.matchFullPath(new 
PartialPath(entry.getKey().toString()))) {
+            deviceMatchInfo.add(entry.getKey());
+            hasMatchedDevice = true;
+            if (startTimes[entry.getValue()] < startTime) {
+              startTime = startTimes[entry.getValue()];
+            }
+            if (endTimes[entry.getValue()] > endTime) {
+              endTime = endTimes[entry.getValue()];
+            }
+          }
         }
+      } catch (IllegalPathException e) {
+        // won't reach here
       }
     }
 
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/tsfile/timeindex/PlainDeviceTimeIndex.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/tsfile/timeindex/PlainDeviceTimeIndex.java
index 5a9e21ae343..7d2fcb8dd1f 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/tsfile/timeindex/PlainDeviceTimeIndex.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/tsfile/timeindex/PlainDeviceTimeIndex.java
@@ -19,32 +19,20 @@
 
 package org.apache.iotdb.db.storageengine.dataregion.tsfile.timeindex;
 
-import org.apache.iotdb.commons.exception.IllegalPathException;
-import org.apache.iotdb.commons.path.PartialPath;
 import 
org.apache.iotdb.db.queryengine.plan.analyze.cache.schema.DataNodeDevicePathCache;
 
 import org.apache.tsfile.file.metadata.IDeviceID;
-import org.apache.tsfile.utils.Pair;
-import org.apache.tsfile.utils.RamUsageEstimator;
 import org.apache.tsfile.utils.ReadWriteIOUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.nio.ByteBuffer;
 import java.util.HashSet;
-import java.util.Map;
 import java.util.Set;
 
 public class PlainDeviceTimeIndex extends ArrayDeviceTimeIndex implements 
ITimeIndex {
 
-  private static final Logger logger = 
LoggerFactory.getLogger(PlainDeviceTimeIndex.class);
-
-  private static final long INSTANCE_SIZE =
-      RamUsageEstimator.shallowSizeOfInstance(ArrayDeviceTimeIndex.class);
-
   @Override
   public void serialize(OutputStream outputStream) throws IOException {
     throw new UnsupportedOperationException();
@@ -116,64 +104,6 @@ public class PlainDeviceTimeIndex extends 
ArrayDeviceTimeIndex implements ITimeI
     return devices;
   }
 
-  @Override
-  public Pair<Long, Long> getPossibleStartTimeAndEndTime(
-      PartialPath devicePattern, Set<IDeviceID> deviceMatchInfo) {
-    boolean hasMatchedDevice = false;
-    long startTime = Long.MAX_VALUE;
-    long endTime = Long.MIN_VALUE;
-    for (Map.Entry<IDeviceID, Integer> entry : deviceToIndex.entrySet()) {
-      try {
-        if (deviceMatchInfo.contains(entry.getKey())) {
-          hasMatchedDevice = true;
-          if (startTimes[entry.getValue()] < startTime) {
-            startTime = startTimes[entry.getValue()];
-          }
-          if (endTimes[entry.getValue()] > endTime) {
-            endTime = endTimes[entry.getValue()];
-          }
-        } else {
-          if (devicePattern.matchFullPath(
-              
DataNodeDevicePathCache.getInstance().getPartialPath(entry.getKey().toString())))
 {
-            deviceMatchInfo.add(entry.getKey());
-            hasMatchedDevice = true;
-            if (startTimes[entry.getValue()] < startTime) {
-              startTime = startTimes[entry.getValue()];
-            }
-            if (endTimes[entry.getValue()] > endTime) {
-              endTime = endTimes[entry.getValue()];
-            }
-          }
-        }
-      } catch (IllegalPathException e) {
-        // won't reach here
-      }
-    }
-
-    return hasMatchedDevice ? new Pair<>(startTime, endTime) : null;
-  }
-
-  @Override
-  public int compareDegradePriority(ITimeIndex timeIndex) {
-    if (timeIndex instanceof ArrayDeviceTimeIndex) {
-      return Long.compare(getMinStartTime(), timeIndex.getMinStartTime());
-    } else if (timeIndex instanceof FileTimeIndex) {
-      return -1;
-    } else {
-      logger.error("Wrong timeIndex type {}", timeIndex.getClass().getName());
-      throw new RuntimeException("Wrong timeIndex type " + 
timeIndex.getClass().getName());
-    }
-  }
-
-  @Override
-  public long calculateRamSize() {
-    return INSTANCE_SIZE
-        + RamUsageEstimator.sizeOfMap(
-            deviceToIndex, 
RamUsageEstimator.shallowSizeOfInstance(Integer.class))
-        + RamUsageEstimator.sizeOf(startTimes)
-        + RamUsageEstimator.sizeOf(endTimes);
-  }
-
   @Override
   public byte getTimeIndexType() {
     return PLAIN_DEVICE_TIME_INDEX_TYPE;

Reply via email to