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 2020/08/28 09:51:34 UTC

[GitHub] [incubator-iotdb] wyh-ztf opened a new pull request #1658: IOTDB-839:Make Tablet api more friendly

wyh-ztf opened a new pull request #1658:
URL: https://github.com/apache/incubator-iotdb/pull/1658


   


----------------------------------------------------------------
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.

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



[GitHub] [incubator-iotdb] wyh-ztf commented on a change in pull request #1658: IOTDB-839:Make Tablet api more friendly

Posted by GitBox <gi...@apache.org>.
wyh-ztf commented on a change in pull request #1658:
URL: https://github.com/apache/incubator-iotdb/pull/1658#discussion_r479635719



##########
File path: tsfile/src/main/java/org/apache/iotdb/tsfile/write/record/Tablet.java
##########
@@ -95,12 +102,56 @@ public Tablet(String deviceId, List<MeasurementSchema> schemas, int maxRowNumber
     this.deviceId = deviceId;
     this.schemas = schemas;
     this.maxRowNumber = maxRowNumber;
+    mschemawithindex = new HashMap<>();
+
+    for (int i = 0; i < schemas.size(); i++) {
+      mschemawithindex.put(schemas.get(i).getMeasurementId(), i);
+    }
 
     createColumns();
 
     reset();
   }
 
+  public void addTimestamp(int rowIndex, long timestamp) {
+    timestamps[rowIndex] = timestamp;
+  }
+
+  public void addValue(String measurementId, int rowIndex, Object value) {
+    int indexOfValue = mschemawithindex.get(measurementId);
+    MeasurementSchema measurementSchema = schemas.get(indexOfValue);
+
+    switch (measurementSchema.getType()) {
+      case TEXT:
+        Binary[] sensort = (Binary[]) values[indexOfValue];

Review comment:
       ok, i will improve that




----------------------------------------------------------------
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.

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



[GitHub] [incubator-iotdb] wyh-ztf commented on a change in pull request #1658: IOTDB-839:Make Tablet api more friendly

Posted by GitBox <gi...@apache.org>.
wyh-ztf commented on a change in pull request #1658:
URL: https://github.com/apache/incubator-iotdb/pull/1658#discussion_r479617747



##########
File path: example/session/src/main/java/org/apache/iotdb/SessionExample.java
##########
@@ -247,15 +247,11 @@ private static void insertTablet() throws IoTDBConnectionException, StatementExe
 
     Tablet tablet = new Tablet("root.sg1.d1", schemaList, 100);
 
-    long[] timestamps = tablet.timestamps;
-    Object[] values = tablet.values;
-
     for (long time = 0; time < 100; time++) {
-      int row = tablet.rowSize++;
-      timestamps[row] = time;
-      for (int i = 0; i < 3; i++) {
-        long[] sensor = (long[]) values[i];
-        sensor[row] = i;
+      int rowIndex = tablet.rowSize++;
+      tablet.addTimestamp(rowIndex, time);
+      for (int s = 0; s < 3; s++) {
+        tablet.addValue(schemaList.get(s), rowIndex, (long) s);

Review comment:
       copy that,thank you

##########
File path: session/src/test/java/org/apache/iotdb/session/IoTDBSessionIT.java
##########
@@ -812,15 +811,11 @@ private void insertTabletTest1(String deviceId)
 
     Tablet tablet = new Tablet(deviceId, schemaList, 100);
 
-    long[] timestamps = tablet.timestamps;
-    Object[] values = tablet.values;
-
     for (long time = 0; time < 100; time++) {
-      int row = tablet.rowSize++;
-      timestamps[row] = time;
-      for (int i = 0; i < 3; i++) {
-        long[] sensor = (long[]) values[i];
-        sensor[row] = i;
+      int rowIndex = tablet.rowSize++;
+      tablet.addTimestamp(rowIndex, time);
+      for (int s = 0; s < 3; s++) {
+        tablet.addValue(schemaList.get(s), rowIndex, (long) s);

Review comment:
       copy that,thank you

##########
File path: tsfile/src/main/java/org/apache/iotdb/tsfile/write/record/Tablet.java
##########
@@ -95,12 +103,48 @@ public Tablet(String deviceId, List<MeasurementSchema> schemas, int maxRowNumber
     this.deviceId = deviceId;
     this.schemas = schemas;
     this.maxRowNumber = maxRowNumber;
+    mschemawithindex=new HashMap<>();
+
+    for(int i=0;i<schemas.size();i++){

Review comment:
       copy that,thank you

##########
File path: tsfile/src/main/java/org/apache/iotdb/tsfile/write/record/Tablet.java
##########
@@ -95,12 +103,48 @@ public Tablet(String deviceId, List<MeasurementSchema> schemas, int maxRowNumber
     this.deviceId = deviceId;
     this.schemas = schemas;
     this.maxRowNumber = maxRowNumber;
+    mschemawithindex=new HashMap<>();
+
+    for(int i=0;i<schemas.size();i++){
+      mschemawithindex.put(schemas.get(i),i);
+    }
 
     createColumns();
 
     reset();
   }
 
+  public void addTimestamp(int rowIndex, long timestamp) {
+    timestamps[rowIndex] = timestamp;
+  }
+
+  public void addValue(MeasurementSchema measurementSchema, int rowIndex, Object value) {
+    int indexOfValue =mschemawithindex.get(measurementSchema);

Review comment:
       copy that,thank you




----------------------------------------------------------------
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.

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



[GitHub] [incubator-iotdb] mychaow commented on a change in pull request #1658: IOTDB-839:Make Tablet api more friendly

Posted by GitBox <gi...@apache.org>.
mychaow commented on a change in pull request #1658:
URL: https://github.com/apache/incubator-iotdb/pull/1658#discussion_r479646024



##########
File path: tsfile/src/main/java/org/apache/iotdb/tsfile/write/record/Tablet.java
##########
@@ -52,6 +54,11 @@
    */
   private List<MeasurementSchema> schemas;
 
+  /**
+   * measurementId->indexOf(measurementSchema)
+   */
+  private Map<String, Integer> mschemawithindex;

Review comment:
       mschemawithindex should be camel-case name, like mSchemaWithIndex. 




----------------------------------------------------------------
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.

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



[GitHub] [incubator-iotdb] qiaojialin merged pull request #1658: [IOTDB-839] Make Tablet api more friendly

Posted by GitBox <gi...@apache.org>.
qiaojialin merged pull request #1658:
URL: https://github.com/apache/incubator-iotdb/pull/1658


   


----------------------------------------------------------------
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.

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



[GitHub] [incubator-iotdb] neuyilan commented on a change in pull request #1658: IOTDB-839:Make Tablet api more friendly

Posted by GitBox <gi...@apache.org>.
neuyilan commented on a change in pull request #1658:
URL: https://github.com/apache/incubator-iotdb/pull/1658#discussion_r479602860



##########
File path: example/session/src/main/java/org/apache/iotdb/SessionExample.java
##########
@@ -247,15 +247,11 @@ private static void insertTablet() throws IoTDBConnectionException, StatementExe
 
     Tablet tablet = new Tablet("root.sg1.d1", schemaList, 100);
 
-    long[] timestamps = tablet.timestamps;
-    Object[] values = tablet.values;
-
     for (long time = 0; time < 100; time++) {
-      int row = tablet.rowSize++;
-      timestamps[row] = time;
-      for (int i = 0; i < 3; i++) {
-        long[] sensor = (long[]) values[i];
-        sensor[row] = i;
+      int rowIndex = tablet.rowSize++;
+      tablet.addTimestamp(rowIndex, time);
+      for (int s = 0; s < 3; s++) {

Review comment:
       I think it's better to separate the rowIndex, the time column, and the value column, which would clearer to users.




----------------------------------------------------------------
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.

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



[GitHub] [incubator-iotdb] qiaojialin commented on a change in pull request #1658: IOTDB-839:Make Tablet api more friendly

Posted by GitBox <gi...@apache.org>.
qiaojialin commented on a change in pull request #1658:
URL: https://github.com/apache/incubator-iotdb/pull/1658#discussion_r479875350



##########
File path: session/src/test/java/org/apache/iotdb/session/IoTDBSessionIT.java
##########
@@ -1203,7 +1289,7 @@ private void queryForBatch() throws ClassNotFoundException, SQLException {
       }
       Assert.assertEquals(standard, resultStr.toString());
       // d1 and d2 will align
-      Assert.assertEquals(7000, count);
+      Assert.assertEquals(14000, count);

Review comment:
       It's not intuitive where 14000 comes from.
   
   I feel that the IoTDBSessionIT is out of control gradually... 
   It's time to remove duplicated methods such as insertTabletTest1-2-3.  
   Besides, there are some commented lines in test(), it should be cleaned.
   
   I create a jira issue:  https://issues.apache.org/jira/browse/IOTDB-856. 
   Better to fix it in this PR.

##########
File path: session/src/test/java/org/apache/iotdb/session/IoTDBSessionIT.java
##########
@@ -622,6 +622,17 @@ public void TestSessionInterfacesWithDisabledWAL()
       tablet.rowSize++;
     }
 
+    for (int time = 101; time <= 200; time++) {
+      int rowIndex = time - 1;
+      tablet.addTimestamp(rowIndex, time);
+      long value = 0;
+      for (int s = 0; s < 3; s++) {
+        tablet.addValue(schemaList.get(s).getMeasurementId(), rowIndex, value);
+        value++;
+      }
+      tablet.rowSize++;
+    }
+

Review comment:
       this test lacks an assert. You can do a select count(*) query and assert

##########
File path: tsfile/src/main/java/org/apache/iotdb/tsfile/write/record/Tablet.java
##########
@@ -52,6 +54,11 @@
    */
   private List<MeasurementSchema> schemas;
 
+  /**
+   * measurementId->indexOf(measurementSchema)
+   */
+  private Map<String, Integer> mSchemaWithIndex;

Review comment:
       ```suggestion
     private Map<String, Integer> measurementIndex;
   ```




----------------------------------------------------------------
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.

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



[GitHub] [incubator-iotdb] wyh-ztf commented on a change in pull request #1658: IOTDB-839:Make Tablet api more friendly

Posted by GitBox <gi...@apache.org>.
wyh-ztf commented on a change in pull request #1658:
URL: https://github.com/apache/incubator-iotdb/pull/1658#discussion_r479930013



##########
File path: session/src/test/java/org/apache/iotdb/session/IoTDBSessionIT.java
##########
@@ -1203,7 +1289,7 @@ private void queryForBatch() throws ClassNotFoundException, SQLException {
       }
       Assert.assertEquals(standard, resultStr.toString());
       // d1 and d2 will align
-      Assert.assertEquals(7000, count);
+      Assert.assertEquals(14000, count);

Review comment:
       ok,i will fix it in that PR




----------------------------------------------------------------
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.

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



[GitHub] [incubator-iotdb] wyh-ztf commented on a change in pull request #1658: IOTDB-839:Make Tablet api more friendly

Posted by GitBox <gi...@apache.org>.
wyh-ztf commented on a change in pull request #1658:
URL: https://github.com/apache/incubator-iotdb/pull/1658#discussion_r479640151



##########
File path: session/src/test/java/org/apache/iotdb/session/IoTDBSessionIT.java
##########
@@ -1087,15 +1086,13 @@ private void insertTabletTest2(String deviceId)
 
     Tablet tablet = new Tablet(deviceId, schemaList, 256);
 
-    long[] timestamps = tablet.timestamps;
-    Object[] values = tablet.values;
-
     for (long time = 0; time < 1000; time++) {
-      int row = tablet.rowSize++;
-      timestamps[row] = time;
-      for (int i = 0; i < 3; i++) {
-        long[] sensor = (long[]) values[i];
-        sensor[row] = i;
+      int rowIndex = tablet.rowSize++;
+      tablet.addTimestamp(rowIndex, time);
+      for (int s = 0; s < 3; s++) {
+        long value = 0;

Review comment:
       I added it after the loop




----------------------------------------------------------------
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.

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



[GitHub] [incubator-iotdb] qiaojialin commented on a change in pull request #1658: IOTDB-839:Make Tablet api more friendly

Posted by GitBox <gi...@apache.org>.
qiaojialin commented on a change in pull request #1658:
URL: https://github.com/apache/incubator-iotdb/pull/1658#discussion_r479597106



##########
File path: tsfile/src/main/java/org/apache/iotdb/tsfile/write/record/Tablet.java
##########
@@ -95,12 +103,48 @@ public Tablet(String deviceId, List<MeasurementSchema> schemas, int maxRowNumber
     this.deviceId = deviceId;
     this.schemas = schemas;
     this.maxRowNumber = maxRowNumber;
+    mschemawithindex=new HashMap<>();
+
+    for(int i=0;i<schemas.size();i++){
+      mschemawithindex.put(schemas.get(i),i);
+    }
 
     createColumns();
 
     reset();
   }
 
+  public void addTimestamp(int rowIndex, long timestamp) {
+    timestamps[rowIndex] = timestamp;
+  }
+
+  public void addValue(MeasurementSchema measurementSchema, int rowIndex, Object value) {

Review comment:
       ```suggestion
     public void addValue(String measurement, int rowIndex, Object value) {
   ```
   
   Using measurement id may be more friendly to users.

##########
File path: tsfile/src/main/java/org/apache/iotdb/tsfile/write/record/Tablet.java
##########
@@ -95,12 +103,48 @@ public Tablet(String deviceId, List<MeasurementSchema> schemas, int maxRowNumber
     this.deviceId = deviceId;
     this.schemas = schemas;
     this.maxRowNumber = maxRowNumber;
+    mschemawithindex=new HashMap<>();
+
+    for(int i=0;i<schemas.size();i++){

Review comment:
       There is a java-google-style.xml under the root folder, import it as the default code style and format the code.
   
   It should be something like this:
   for(int i = 0; i < schemas.size(); i++){

##########
File path: tsfile/src/main/java/org/apache/iotdb/tsfile/write/record/Tablet.java
##########
@@ -95,12 +103,48 @@ public Tablet(String deviceId, List<MeasurementSchema> schemas, int maxRowNumber
     this.deviceId = deviceId;
     this.schemas = schemas;
     this.maxRowNumber = maxRowNumber;
+    mschemawithindex=new HashMap<>();
+
+    for(int i=0;i<schemas.size();i++){
+      mschemawithindex.put(schemas.get(i),i);
+    }
 
     createColumns();
 
     reset();
   }
 
+  public void addTimestamp(int rowIndex, long timestamp) {
+    timestamps[rowIndex] = timestamp;
+  }
+
+  public void addValue(MeasurementSchema measurementSchema, int rowIndex, Object value) {
+    int indexOfValue =mschemawithindex.get(measurementSchema);
+
+    if (measurementSchema.getType() == INT64) {

Review comment:
       switch (measurementSchema.getType())




----------------------------------------------------------------
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.

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



[GitHub] [incubator-iotdb] wyh-ztf commented on a change in pull request #1658: IOTDB-839:Make Tablet api more friendly

Posted by GitBox <gi...@apache.org>.
wyh-ztf commented on a change in pull request #1658:
URL: https://github.com/apache/incubator-iotdb/pull/1658#discussion_r479929760



##########
File path: session/src/test/java/org/apache/iotdb/session/IoTDBSessionIT.java
##########
@@ -622,6 +622,17 @@ public void TestSessionInterfacesWithDisabledWAL()
       tablet.rowSize++;
     }
 
+    for (int time = 101; time <= 200; time++) {
+      int rowIndex = time - 1;
+      tablet.addTimestamp(rowIndex, time);
+      long value = 0;
+      for (int s = 0; s < 3; s++) {
+        tablet.addValue(schemaList.get(s).getMeasurementId(), rowIndex, value);
+        value++;
+      }
+      tablet.rowSize++;
+    }
+

Review comment:
       i will fix it in PR IOTDB-856:Clear up the IoTDBSessionIT




----------------------------------------------------------------
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.

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



[GitHub] [incubator-iotdb] mychaow commented on a change in pull request #1658: IOTDB-839:Make Tablet api more friendly

Posted by GitBox <gi...@apache.org>.
mychaow commented on a change in pull request #1658:
URL: https://github.com/apache/incubator-iotdb/pull/1658#discussion_r479599804



##########
File path: example/session/src/main/java/org/apache/iotdb/SessionExample.java
##########
@@ -247,15 +247,11 @@ private static void insertTablet() throws IoTDBConnectionException, StatementExe
 
     Tablet tablet = new Tablet("root.sg1.d1", schemaList, 100);
 
-    long[] timestamps = tablet.timestamps;

Review comment:
       You should not delete the previous example, user also can use the previous way to add data.  You should add new code to show how to use.

##########
File path: session/src/test/java/org/apache/iotdb/session/IoTDBSessionIT.java
##########
@@ -812,15 +811,11 @@ private void insertTabletTest1(String deviceId)
 
     Tablet tablet = new Tablet(deviceId, schemaList, 100);
 
-    long[] timestamps = tablet.timestamps;
-    Object[] values = tablet.values;
-
     for (long time = 0; time < 100; time++) {
-      int row = tablet.rowSize++;
-      timestamps[row] = time;
-      for (int i = 0; i < 3; i++) {
-        long[] sensor = (long[]) values[i];
-        sensor[row] = i;
+      int rowIndex = tablet.rowSize++;
+      tablet.addTimestamp(rowIndex, time);
+      for (int s = 0; s < 3; s++) {
+        tablet.addValue(schemaList.get(s), rowIndex, (long) s);

Review comment:
       same with the previous comment

##########
File path: example/session/src/main/java/org/apache/iotdb/SessionExample.java
##########
@@ -247,15 +247,11 @@ private static void insertTablet() throws IoTDBConnectionException, StatementExe
 
     Tablet tablet = new Tablet("root.sg1.d1", schemaList, 100);
 
-    long[] timestamps = tablet.timestamps;
-    Object[] values = tablet.values;
-
     for (long time = 0; time < 100; time++) {
-      int row = tablet.rowSize++;
-      timestamps[row] = time;
-      for (int i = 0; i < 3; i++) {
-        long[] sensor = (long[]) values[i];
-        sensor[row] = i;
+      int rowIndex = tablet.rowSize++;
+      tablet.addTimestamp(rowIndex, time);
+      for (int s = 0; s < 3; s++) {
+        tablet.addValue(schemaList.get(s), rowIndex, (long) s);

Review comment:
       It's not nesscessary to cast to long. You have done cast in the addValue.

##########
File path: tsfile/src/main/java/org/apache/iotdb/tsfile/write/record/Tablet.java
##########
@@ -95,12 +103,48 @@ public Tablet(String deviceId, List<MeasurementSchema> schemas, int maxRowNumber
     this.deviceId = deviceId;
     this.schemas = schemas;
     this.maxRowNumber = maxRowNumber;
+    mschemawithindex=new HashMap<>();
+
+    for(int i=0;i<schemas.size();i++){

Review comment:
       code should be 
   `for (int i = 0; i < schemas.size(); i++) {}`.  It's not wasteful to add blank in the code.

##########
File path: tsfile/src/main/java/org/apache/iotdb/tsfile/write/record/Tablet.java
##########
@@ -95,12 +103,48 @@ public Tablet(String deviceId, List<MeasurementSchema> schemas, int maxRowNumber
     this.deviceId = deviceId;
     this.schemas = schemas;
     this.maxRowNumber = maxRowNumber;
+    mschemawithindex=new HashMap<>();
+
+    for(int i=0;i<schemas.size();i++){
+      mschemawithindex.put(schemas.get(i),i);
+    }
 
     createColumns();
 
     reset();
   }
 
+  public void addTimestamp(int rowIndex, long timestamp) {
+    timestamps[rowIndex] = timestamp;
+  }
+
+  public void addValue(MeasurementSchema measurementSchema, int rowIndex, Object value) {
+    int indexOfValue =mschemawithindex.get(measurementSchema);

Review comment:
       add blank




----------------------------------------------------------------
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.

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



[GitHub] [incubator-iotdb] wyh-ztf commented on a change in pull request #1658: IOTDB-839:Make Tablet api more friendly

Posted by GitBox <gi...@apache.org>.
wyh-ztf commented on a change in pull request #1658:
URL: https://github.com/apache/incubator-iotdb/pull/1658#discussion_r479646729



##########
File path: tsfile/src/main/java/org/apache/iotdb/tsfile/write/record/Tablet.java
##########
@@ -52,6 +54,11 @@
    */
   private List<MeasurementSchema> schemas;
 
+  /**
+   * measurementId->indexOf(measurementSchema)
+   */
+  private Map<String, Integer> mschemawithindex;

Review comment:
       copy that.




----------------------------------------------------------------
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.

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



[GitHub] [incubator-iotdb] wyh-ztf commented on a change in pull request #1658: IOTDB-839:Make Tablet api more friendly

Posted by GitBox <gi...@apache.org>.
wyh-ztf commented on a change in pull request #1658:
URL: https://github.com/apache/incubator-iotdb/pull/1658#discussion_r479929231



##########
File path: tsfile/src/main/java/org/apache/iotdb/tsfile/write/record/Tablet.java
##########
@@ -52,6 +54,11 @@
    */
   private List<MeasurementSchema> schemas;
 
+  /**
+   * measurementId->indexOf(measurementSchema)
+   */
+  private Map<String, Integer> mSchemaWithIndex;

Review comment:
       thanks,i will improve that




----------------------------------------------------------------
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.

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



[GitHub] [incubator-iotdb] wyh-ztf commented on a change in pull request #1658: IOTDB-839:Make Tablet api more friendly

Posted by GitBox <gi...@apache.org>.
wyh-ztf commented on a change in pull request #1658:
URL: https://github.com/apache/incubator-iotdb/pull/1658#discussion_r479617827



##########
File path: example/session/src/main/java/org/apache/iotdb/SessionExample.java
##########
@@ -247,15 +247,11 @@ private static void insertTablet() throws IoTDBConnectionException, StatementExe
 
     Tablet tablet = new Tablet("root.sg1.d1", schemaList, 100);
 
-    long[] timestamps = tablet.timestamps;
-    Object[] values = tablet.values;
-
     for (long time = 0; time < 100; time++) {
-      int row = tablet.rowSize++;
-      timestamps[row] = time;
-      for (int i = 0; i < 3; i++) {
-        long[] sensor = (long[]) values[i];
-        sensor[row] = i;
+      int rowIndex = tablet.rowSize++;
+      tablet.addTimestamp(rowIndex, time);
+      for (int s = 0; s < 3; s++) {

Review comment:
       copy that,thank you




----------------------------------------------------------------
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.

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



[GitHub] [incubator-iotdb] mychaow commented on a change in pull request #1658: IOTDB-839:Make Tablet api more friendly

Posted by GitBox <gi...@apache.org>.
mychaow commented on a change in pull request #1658:
URL: https://github.com/apache/incubator-iotdb/pull/1658#discussion_r479064903



##########
File path: tsfile/src/main/java/org/apache/iotdb/tsfile/write/record/Tablet.java
##########
@@ -81,6 +82,43 @@ public Tablet(String deviceId, List<MeasurementSchema> timeseries) {
     this(deviceId, timeseries, DEFAULT_SIZE);
   }
 
+  public void addTimestamp(int rowIndex, long timestamp) {
+    timestamps[rowIndex - 1] = timestamp;
+  }
+
+  public void addValue(MeasurementSchema measurementSchema, int rowIndex, Object value) {
+
+    int indexOfValue = schemas.indexOf(measurementSchema);
+    if (measurementSchema.getType() == INT64) {
+      long[] sensor = (long[]) values[indexOfValue];
+      sensor[rowIndex - 1] = (long) value;
+      values[indexOfValue] = sensor;

Review comment:
       what is the meaning of this line?

##########
File path: tsfile/src/main/java/org/apache/iotdb/tsfile/write/record/Tablet.java
##########
@@ -81,6 +82,43 @@ public Tablet(String deviceId, List<MeasurementSchema> timeseries) {
     this(deviceId, timeseries, DEFAULT_SIZE);
   }
 
+  public void addTimestamp(int rowIndex, long timestamp) {
+    timestamps[rowIndex - 1] = timestamp;
+  }
+
+  public void addValue(MeasurementSchema measurementSchema, int rowIndex, Object value) {
+
+    int indexOfValue = schemas.indexOf(measurementSchema);

Review comment:
       It's not a good way to get the index, measurements maybe very large. You should store the measurementSchema as a map

##########
File path: tsfile/src/main/java/org/apache/iotdb/tsfile/write/record/Tablet.java
##########
@@ -81,6 +82,43 @@ public Tablet(String deviceId, List<MeasurementSchema> timeseries) {
     this(deviceId, timeseries, DEFAULT_SIZE);
   }
 
+  public void addTimestamp(int rowIndex, long timestamp) {

Review comment:
       rowIndex maybe starts with 0?




----------------------------------------------------------------
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.

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



[GitHub] [incubator-iotdb] wyh-ztf commented on a change in pull request #1658: IOTDB-839:Make Tablet api more friendly

Posted by GitBox <gi...@apache.org>.
wyh-ztf commented on a change in pull request #1658:
URL: https://github.com/apache/incubator-iotdb/pull/1658#discussion_r479617282



##########
File path: tsfile/src/main/java/org/apache/iotdb/tsfile/write/record/Tablet.java
##########
@@ -95,12 +103,48 @@ public Tablet(String deviceId, List<MeasurementSchema> schemas, int maxRowNumber
     this.deviceId = deviceId;
     this.schemas = schemas;
     this.maxRowNumber = maxRowNumber;
+    mschemawithindex=new HashMap<>();
+
+    for(int i=0;i<schemas.size();i++){
+      mschemawithindex.put(schemas.get(i),i);
+    }
 
     createColumns();
 
     reset();
   }
 
+  public void addTimestamp(int rowIndex, long timestamp) {
+    timestamps[rowIndex] = timestamp;
+  }
+
+  public void addValue(MeasurementSchema measurementSchema, int rowIndex, Object value) {
+    int indexOfValue =mschemawithindex.get(measurementSchema);
+
+    if (measurementSchema.getType() == INT64) {

Review comment:
       Thank you. I'll improve it




----------------------------------------------------------------
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.

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



[GitHub] [incubator-iotdb] wyh-ztf commented on a change in pull request #1658: IOTDB-839:Make Tablet api more friendly

Posted by GitBox <gi...@apache.org>.
wyh-ztf commented on a change in pull request #1658:
URL: https://github.com/apache/incubator-iotdb/pull/1658#discussion_r479617704



##########
File path: tsfile/src/main/java/org/apache/iotdb/tsfile/write/record/Tablet.java
##########
@@ -95,12 +103,48 @@ public Tablet(String deviceId, List<MeasurementSchema> schemas, int maxRowNumber
     this.deviceId = deviceId;
     this.schemas = schemas;
     this.maxRowNumber = maxRowNumber;
+    mschemawithindex=new HashMap<>();
+
+    for(int i=0;i<schemas.size();i++){
+      mschemawithindex.put(schemas.get(i),i);
+    }
 
     createColumns();
 
     reset();
   }
 
+  public void addTimestamp(int rowIndex, long timestamp) {
+    timestamps[rowIndex] = timestamp;
+  }
+
+  public void addValue(MeasurementSchema measurementSchema, int rowIndex, Object value) {

Review comment:
       copy that,thank you




----------------------------------------------------------------
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.

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



[GitHub] [incubator-iotdb] wyh-ztf commented on a change in pull request #1658: IOTDB-839:Make Tablet api more friendly

Posted by GitBox <gi...@apache.org>.
wyh-ztf commented on a change in pull request #1658:
URL: https://github.com/apache/incubator-iotdb/pull/1658#discussion_r479617672



##########
File path: tsfile/src/main/java/org/apache/iotdb/tsfile/write/record/Tablet.java
##########
@@ -95,12 +103,48 @@ public Tablet(String deviceId, List<MeasurementSchema> schemas, int maxRowNumber
     this.deviceId = deviceId;
     this.schemas = schemas;
     this.maxRowNumber = maxRowNumber;
+    mschemawithindex=new HashMap<>();
+
+    for(int i=0;i<schemas.size();i++){

Review comment:
       copy that,thank you




----------------------------------------------------------------
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.

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



[GitHub] [incubator-iotdb] mychaow commented on a change in pull request #1658: IOTDB-839:Make Tablet api more friendly

Posted by GitBox <gi...@apache.org>.
mychaow commented on a change in pull request #1658:
URL: https://github.com/apache/incubator-iotdb/pull/1658#discussion_r479634730



##########
File path: session/src/test/java/org/apache/iotdb/session/IoTDBSessionIT.java
##########
@@ -1119,15 +1116,13 @@ private void insertTabletTest3(String deviceId)
 
     Tablet tablet = new Tablet(deviceId, schemaList, 200);
 
-    long[] timestamps = tablet.timestamps;
-    Object[] values = tablet.values;
-
     for (long time = 500; time < 1500; time++) {
-      int row = tablet.rowSize++;
-      timestamps[row] = time;
-      for (int i = 0; i < 3; i++) {
-        long[] sensor = (long[]) values[i];
-        sensor[row] = i;
+      int rowIndex = tablet.rowSize++;
+      tablet.addTimestamp(rowIndex, time);
+      for (int s = 0; s < 3; s++) {
+        long value = 0;

Review comment:
       same with previous

##########
File path: tsfile/src/main/java/org/apache/iotdb/tsfile/write/record/Tablet.java
##########
@@ -95,12 +102,56 @@ public Tablet(String deviceId, List<MeasurementSchema> schemas, int maxRowNumber
     this.deviceId = deviceId;
     this.schemas = schemas;
     this.maxRowNumber = maxRowNumber;
+    mschemawithindex = new HashMap<>();
+
+    for (int i = 0; i < schemas.size(); i++) {
+      mschemawithindex.put(schemas.get(i).getMeasurementId(), i);
+    }
 
     createColumns();
 
     reset();
   }
 
+  public void addTimestamp(int rowIndex, long timestamp) {
+    timestamps[rowIndex] = timestamp;
+  }
+
+  public void addValue(String measurementId, int rowIndex, Object value) {
+    int indexOfValue = mschemawithindex.get(measurementId);
+    MeasurementSchema measurementSchema = schemas.get(indexOfValue);
+
+    switch (measurementSchema.getType()) {
+      case TEXT:
+        Binary[] sensort = (Binary[]) values[indexOfValue];

Review comment:
       It's too ugly to create so many new variable names. 
   `you could use {} in every case` 

##########
File path: session/src/test/java/org/apache/iotdb/session/IoTDBSessionIT.java
##########
@@ -1087,15 +1086,13 @@ private void insertTabletTest2(String deviceId)
 
     Tablet tablet = new Tablet(deviceId, schemaList, 256);
 
-    long[] timestamps = tablet.timestamps;
-    Object[] values = tablet.values;
-
     for (long time = 0; time < 1000; time++) {
-      int row = tablet.rowSize++;
-      timestamps[row] = time;
-      for (int i = 0; i < 3; i++) {
-        long[] sensor = (long[]) values[i];
-        sensor[row] = i;
+      int rowIndex = tablet.rowSize++;
+      tablet.addTimestamp(rowIndex, time);
+      for (int s = 0; s < 3; s++) {
+        long value = 0;

Review comment:
       value always is initialize to be 0




----------------------------------------------------------------
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.

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



[GitHub] [incubator-iotdb] wyh-ztf commented on a change in pull request #1658: IOTDB-839:Make Tablet api more friendly

Posted by GitBox <gi...@apache.org>.
wyh-ztf commented on a change in pull request #1658:
URL: https://github.com/apache/incubator-iotdb/pull/1658#discussion_r479617882



##########
File path: example/session/src/main/java/org/apache/iotdb/SessionExample.java
##########
@@ -247,15 +247,11 @@ private static void insertTablet() throws IoTDBConnectionException, StatementExe
 
     Tablet tablet = new Tablet("root.sg1.d1", schemaList, 100);
 
-    long[] timestamps = tablet.timestamps;

Review comment:
       copy that,thank you




----------------------------------------------------------------
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.

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