You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by GitBox <gi...@apache.org> on 2022/09/21 04:06:31 UTC

[GitHub] [iotdb] qiaojialin commented on a diff in pull request #7312: [IOTDB-4364]Reduce read amplication in compaction

qiaojialin commented on code in PR #7312:
URL: https://github.com/apache/iotdb/pull/7312#discussion_r976009090


##########
tsfile/src/main/java/org/apache/iotdb/tsfile/read/TsFileDeviceIterator.java:
##########
@@ -56,18 +55,21 @@ public Pair<String, Boolean> next() {
       throw new NoSuchElementException();
     }
     Pair<String, Pair<Long, Long>> startEndPair = queue.remove();
-    List<Pair<String, Boolean>> devices = new ArrayList<>();
     try {
-      MetadataIndexNode measurementNode =
+      // first measurement node of this device
+      this.measurementNode =
           MetadataIndexNode.deserializeFrom(
               reader.readData(startEndPair.right.left, startEndPair.right.right));
-      // if tryToGetFirstTimeseriesMetadata(node) returns null, the device is not aligned
-      boolean isAligned = reader.tryToGetFirstTimeseriesMetadata(measurementNode) != null;
+      boolean isAligned = reader.isAlignedDevice(measurementNode);
       currentDevice = new Pair<>(startEndPair.left, isAligned);
       return currentDevice;
     } catch (IOException e) {
       throw new TsFileRuntimeException(
           "Error occurred while reading a time series metadata block.");
     }
   }
+
+  public MetadataIndexNode getMeasurementNode() {

Review Comment:
   ```suggestion
     public MetadataIndexNode getFirstMeasurementNodeOfCurrentDevice() {
   ```



##########
server/src/main/java/org/apache/iotdb/db/engine/compaction/inner/utils/MultiTsFileDeviceIterator.java:
##########
@@ -134,6 +133,38 @@ public Pair<String, Boolean> nextDevice() {
     return currentDevice;
   }
 
+  /**
+   * Get all measurements and schemas of the current device from source files. Traverse all the
+   * files from the newest to the oldest in turn and start traversing the index tree from the
+   * firstMeasurementNode node to get all the measurements under the current device.
+   */
+  public Map<String, MeasurementSchema> getAllMeasurementSchemas() throws IOException {

Review Comment:
   ```suggestion
     public Map<String, MeasurementSchema> getAllSchemasOfCurrentDevice() throws IOException {
   ```



##########
tsfile/src/main/java/org/apache/iotdb/tsfile/read/TsFileDeviceIterator.java:
##########
@@ -56,18 +55,21 @@ public Pair<String, Boolean> next() {
       throw new NoSuchElementException();
     }
     Pair<String, Pair<Long, Long>> startEndPair = queue.remove();
-    List<Pair<String, Boolean>> devices = new ArrayList<>();
     try {
-      MetadataIndexNode measurementNode =
+      // first measurement node of this device
+      this.measurementNode =

Review Comment:
   // get the first measurment node of this device, to know if the device is alignd



-- 
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: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org