Caideyipi commented on code in PR #18248:
URL: https://github.com/apache/iotdb/pull/18248#discussion_r3612896136


##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/TabletDecoder.java:
##########
@@ -129,16 +135,51 @@ public Pair<Object[], ByteBuffer> decodeValues(ByteBuffer 
buffer) {
     
RPCServiceThriftHandlerMetrics.getInstance().recordCompressionSizeTimer(compressedSize);
 
     long startDecodeTime = System.nanoTime();
-    Object[] columns = new Object[dataTypes.length];
-    for (int i = 0; i < dataTypes.length; i++) {
-      columns[i] = decodeColumn(uncompressed, i);
+    Object[] columns;
+    if (allValueColumnsPlain) {
+      columns =
+          QueryDataSetUtils.readTabletValuesFromBuffer(
+              uncompressed, dataTypes, dataTypes.length, rowSize);
+    } else {
+      columns = new Object[dataTypes.length];
+      for (int i = 0; i < dataTypes.length; i++) {
+        columns[i] = decodeColumn(uncompressed, i);
+      }
     }
 
     RPCServiceThriftHandlerMetrics.getInstance()
         .recordDecodeLatencyTimer(System.nanoTime() - startDecodeTime);
     return new Pair<>(columns, uncompressed);
   }
 
+  private static boolean allValueColumnsPlain(
+      TSDataType[] dataTypes, List<TSEncoding> columnEncodings) {
+    for (int i = 0; i < dataTypes.length; i++) {
+      if (columnEncodings.get(i + 1) != TSEncoding.PLAIN || 
!supportsPlainFastPath(dataTypes[i])) {
+        return false;
+      }
+    }
+    return true;
+  }
+
+  private static boolean supportsPlainFastPath(TSDataType dataType) {
+    switch (dataType) {
+      case BOOLEAN:
+      case DATE:
+      case INT32:
+      case TIMESTAMP:
+      case INT64:
+      case FLOAT:
+      case DOUBLE:
+      case STRING:
+      case BLOB:
+      case TEXT:
+        return true;
+      default:
+        return false;
+    }

Review Comment:
   Applied in 02b7f9a5df1. supportsPlainFastPath now uses an enhanced switch 
and explicitly lists every TSDataType branch.



##########
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/utils/PathUtils.java:
##########
@@ -131,6 +131,54 @@ public static List<String> 
checkIsLegalSingleMeasurementsAndUpdate(List<String>
     return res;
   }
 
+  /**
+   * Check and canonicalize single measurements in place. This avoids 
allocating another list when
+   * the input is a mutable list created by Thrift.
+   */
+  public static void 
checkIsLegalSingleMeasurementsAndUpdateInPlace(List<String> measurements)
+      throws MetadataException {
+    if (measurements == null) {
+      return;
+    }
+    for (int i = 0; i < measurements.size(); i++) {
+      String measurement = measurements.get(i);
+      measurements.set(
+          i,
+          measurement == null || measurement.isEmpty()
+              ? null
+              : checkAndReturnSingleMeasurement(measurement));
+    }
+  }
+
+  /**
+   * Check and canonicalize lists of single measurements in place. Duplicate 
measurements in one
+   * request are checked only once.
+   */
+  public static void checkIsLegalSingleMeasurementListsAndUpdateInPlace(
+      List<List<String>> measurementLists) throws MetadataException {
+    if (measurementLists == null) {
+      return;
+    }
+    Map<String, String> checkedMeasurements = new HashMap<>();

Review Comment:
   Applied the single-list fast path in 02b7f9a5df1, so it checks in place 
without allocating a request-local map. I kept request-local deduplication for 
multiple lists because tablet batches commonly target different devices with 
the same measurement schema, and measurement validation/canonicalization is 
device-independent, so repeated names can still reuse the checked result across 
devices. I also added focused coverage for the single-list path.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to