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 2022/02/17 14:37:37 UTC

[iotdb] branch master updated: change prefixPath in Tablet to deviceId (#5078)

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 e95789c  change prefixPath in Tablet to deviceId (#5078)
e95789c is described below

commit e95789cb190940c825ea7360f4a90857706fe4e6
Author: Jialin Qiao <qj...@mails.tsinghua.edu.cn>
AuthorDate: Thu Feb 17 22:36:57 2022 +0800

    change prefixPath in Tablet to deviceId (#5078)
    
    Co-authored-by: HTHou <hh...@outlook.com>
---
 .../java/org/apache/iotdb/session/Session.java     |  8 ++++----
 .../test/java/org/apache/iotdb/db/sql/Cases.java   |  4 ++--
 .../apache/iotdb/tsfile/write/TsFileWriter.java    |  8 ++++----
 .../apache/iotdb/tsfile/write/record/Tablet.java   | 22 +++++++++++-----------
 4 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/session/src/main/java/org/apache/iotdb/session/Session.java b/session/src/main/java/org/apache/iotdb/session/Session.java
index 2c18c2d..38d5ce7 100644
--- a/session/src/main/java/org/apache/iotdb/session/Session.java
+++ b/session/src/main/java/org/apache/iotdb/session/Session.java
@@ -1570,9 +1570,9 @@ public class Session {
       throws IoTDBConnectionException, StatementExecutionException {
     TSInsertTabletReq request = genTSInsertTabletReq(tablet, sorted);
     try {
-      getSessionConnection(tablet.prefixPath).insertTablet(request);
+      getSessionConnection(tablet.deviceId).insertTablet(request);
     } catch (RedirectException e) {
-      handleRedirection(tablet.prefixPath, e.getEndPoint());
+      handleRedirection(tablet.deviceId, e.getEndPoint());
     }
   }
 
@@ -1617,7 +1617,7 @@ public class Session {
       request.addToTypes(measurementSchema.getType().ordinal());
     }
 
-    request.setPrefixPath(tablet.prefixPath);
+    request.setPrefixPath(tablet.deviceId);
     request.setIsAligned(tablet.isAligned());
     request.setTimestamps(SessionUtils.getTimeBuffer(tablet));
     request.setValues(SessionUtils.getValueBuffer(tablet));
@@ -1724,7 +1724,7 @@ public class Session {
     if (!checkSorted(tablet)) {
       sortTablet(tablet);
     }
-    request.addToPrefixPaths(tablet.prefixPath);
+    request.addToPrefixPaths(tablet.deviceId);
     List<String> measurements = new ArrayList<>();
     List<Integer> dataTypes = new ArrayList<>();
 
diff --git a/testcontainer/src/test/java/org/apache/iotdb/db/sql/Cases.java b/testcontainer/src/test/java/org/apache/iotdb/db/sql/Cases.java
index 6758a10..7f6dfcc 100644
--- a/testcontainer/src/test/java/org/apache/iotdb/db/sql/Cases.java
+++ b/testcontainer/src/test/java/org/apache/iotdb/db/sql/Cases.java
@@ -689,7 +689,7 @@ public abstract class Cases {
         tablet.addValue("s3", rowIndex, 3L);
       }
       session.insertTablet(tablet);
-      tablet.setPrefixPath(String.format("root.sg%s.d4", i));
+      tablet.setDeviceId(String.format("root.sg%s.d4", i));
       tabletMap.put(String.format("root.sg%s.d4", i), tablet);
     }
 
@@ -728,7 +728,7 @@ public abstract class Cases {
         tablet.addValue("s3", rowIndex, 3L);
       }
       session.insertTablet(tablet);
-      tablet.setPrefixPath(String.format("root.sg%s.d4", i));
+      tablet.setDeviceId(String.format("root.sg%s.d4", i));
       tabletMap.put(String.format("root.sg%s.d4", i), tablet);
     }
 
diff --git a/tsfile/src/main/java/org/apache/iotdb/tsfile/write/TsFileWriter.java b/tsfile/src/main/java/org/apache/iotdb/tsfile/write/TsFileWriter.java
index 5c38bab..f2ced03 100644
--- a/tsfile/src/main/java/org/apache/iotdb/tsfile/write/TsFileWriter.java
+++ b/tsfile/src/main/java/org/apache/iotdb/tsfile/write/TsFileWriter.java
@@ -349,9 +349,9 @@ public class TsFileWriter implements AutoCloseable {
 
   private void checkIsTimeseriesExist(Tablet tablet, boolean isAligned)
       throws WriteProcessException {
-    IChunkGroupWriter groupWriter = tryToInitialGroupWriter(tablet.prefixPath, isAligned);
+    IChunkGroupWriter groupWriter = tryToInitialGroupWriter(tablet.deviceId, isAligned);
 
-    Path devicePath = new Path(tablet.prefixPath);
+    Path devicePath = new Path(tablet.deviceId);
     List<MeasurementSchema> schemas = tablet.getSchemas();
     if (schema.containsDevice(devicePath)) {
       checkIsAllMeasurementsInGroup(schema.getSeriesSchema(devicePath), schemas, isAligned);
@@ -509,7 +509,7 @@ public class TsFileWriter implements AutoCloseable {
     // make sure the ChunkGroupWriter for this Tablet exist
     checkIsTimeseriesExist(tablet, false);
     // get corresponding ChunkGroupWriter and write this Tablet
-    recordCount += groupWriters.get(tablet.prefixPath).write(tablet);
+    recordCount += groupWriters.get(tablet.deviceId).write(tablet);
     return checkMemorySizeAndMayFlushChunks();
   }
 
@@ -517,7 +517,7 @@ public class TsFileWriter implements AutoCloseable {
     // make sure the ChunkGroupWriter for this Tablet exist
     checkIsTimeseriesExist(tablet, true);
     // get corresponding ChunkGroupWriter and write this Tablet
-    recordCount += groupWriters.get(tablet.prefixPath).write(tablet);
+    recordCount += groupWriters.get(tablet.deviceId).write(tablet);
     return checkMemorySizeAndMayFlushChunks();
   }
 
diff --git a/tsfile/src/main/java/org/apache/iotdb/tsfile/write/record/Tablet.java b/tsfile/src/main/java/org/apache/iotdb/tsfile/write/record/Tablet.java
index d68b53c..81eb55d 100644
--- a/tsfile/src/main/java/org/apache/iotdb/tsfile/write/record/Tablet.java
+++ b/tsfile/src/main/java/org/apache/iotdb/tsfile/write/record/Tablet.java
@@ -45,13 +45,13 @@ public class Tablet {
   private static final String NOT_SUPPORT_DATATYPE = "Data type %s is not supported.";
 
   /** deviceId of this tablet */
-  public String prefixPath;
+  public String deviceId;
 
   /** the list of measurement schemas for creating the tablet */
   private List<MeasurementSchema> schemas;
 
   /** measurementId->indexOf(measurementSchema) */
-  private Map<String, Integer> measurementIndex;
+  private final Map<String, Integer> measurementIndex;
 
   /** timestamps in this tablet */
   public long[] timestamps;
@@ -62,7 +62,7 @@ public class Tablet {
   /** the number of rows to include in this tablet */
   public int rowSize;
   /** the maximum number of rows for this tablet */
-  private int maxRowNumber;
+  private final int maxRowNumber;
   /** whether this tablet store data of aligned timeseries or not */
   private boolean isAligned;
 
@@ -70,25 +70,25 @@ public class Tablet {
    * Return a tablet with default specified row number. This is the standard constructor (all Tablet
    * should be the same size).
    *
-   * @param prefixPath the name of the device specified to be written in
+   * @param deviceId the name of the device specified to be written in
    * @param schemas the list of measurement schemas for creating the tablet, only measurementId and
    *     type take effects
    */
-  public Tablet(String prefixPath, List<MeasurementSchema> schemas) {
-    this(prefixPath, schemas, DEFAULT_SIZE);
+  public Tablet(String deviceId, List<MeasurementSchema> schemas) {
+    this(deviceId, schemas, DEFAULT_SIZE);
   }
 
   /**
    * Return a tablet with the specified number of rows (maxBatchSize). Only call this constructor
    * directly for testing purposes. Tablet should normally always be default size.
    *
-   * @param prefixPath the name of the device specified to be written in
+   * @param deviceId the name of the device specified to be written in
    * @param schemas the list of measurement schemas for creating the row batch, only measurementId
    *     and type take effects
    * @param maxRowNumber the maximum number of rows for this tablet
    */
-  public Tablet(String prefixPath, List<MeasurementSchema> schemas, int maxRowNumber) {
-    this.prefixPath = prefixPath;
+  public Tablet(String deviceId, List<MeasurementSchema> schemas, int maxRowNumber) {
+    this.deviceId = deviceId;
     this.schemas = new ArrayList<>(schemas);
     this.maxRowNumber = maxRowNumber;
     measurementIndex = new HashMap<>();
@@ -110,8 +110,8 @@ public class Tablet {
     reset();
   }
 
-  public void setPrefixPath(String prefixPath) {
-    this.prefixPath = prefixPath;
+  public void setDeviceId(String deviceId) {
+    this.deviceId = deviceId;
   }
 
   public void setSchemas(List<MeasurementSchema> schemas) {