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 2021/04/11 03:32:11 UTC

[GitHub] [iotdb] qiaojialin commented on a change in pull request #2802: [IOTDB-1199] Support aligned timeseries and device template

qiaojialin commented on a change in pull request #2802:
URL: https://github.com/apache/iotdb/pull/2802#discussion_r608537321



##########
File path: tsfile/src/main/java/org/apache/iotdb/tsfile/write/schema/IMeasurementSchema.java
##########
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.iotdb.tsfile.write.schema;
+
+import org.apache.iotdb.tsfile.encoding.encoder.Encoder;
+import org.apache.iotdb.tsfile.file.metadata.enums.CompressionType;
+import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+import org.apache.iotdb.tsfile.file.metadata.enums.TSEncoding;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.nio.ByteBuffer;
+import java.util.List;
+import java.util.Map;
+
+public interface IMeasurementSchema {
+
+  String getMeasurementId();
+
+  CompressionType getCompressor();
+
+  TSEncoding getEncodingType();
+
+  TSDataType getType();
+
+  void setType(TSDataType dataType);
+
+  TSEncoding getTimeTSEncoding();
+
+  Encoder getTimeEncoder();
+
+  Encoder getValueEncoder();
+
+  Map<String, String> getProps();
+
+  List<String> getValueMeasurementIdList();
+
+  List<TSDataType> getValueTSDataTypeList();
+
+  List<TSEncoding> getValueTSEncodingList();
+
+  List<Encoder> getValueEncoderList();
+
+  int getMeasurementIdColumnIndex(String measurementId);
+
+  int serializeTo(ByteBuffer buffer);
+
+  int serializeTo(OutputStream outputStream) throws IOException;
+
+  int partialSerializeTo(ByteBuffer buffer);
+
+  int partialSerializeTo(OutputStream outputStream) throws IOException;

Review comment:
       add javadoc

##########
File path: server/src/main/java/org/apache/iotdb/db/engine/memtable/AbstractMemTable.java
##########
@@ -155,33 +177,50 @@ public void insertTablet(InsertTabletPlan insertTabletPlan, int start, int end)
 
   @Override
   public void write(
-      String deviceId,
-      String measurement,
-      MeasurementSchema schema,
-      long insertTime,
-      Object objectValue) {
-    IWritableMemChunk memSeries = createIfNotExistAndGet(deviceId, measurement, schema);
+      String deviceId, IMeasurementSchema schema, long insertTime, Object objectValue) {
+    IWritableMemChunk memSeries = createIfNotExistAndGet(deviceId, schema);
     memSeries.write(insertTime, objectValue);
   }
 
   @Override
   public void write(InsertTabletPlan insertTabletPlan, int start, int end) {
+    int columnIndex = 0;
     updatePlanIndexes(insertTabletPlan.getIndex());
     for (int i = 0; i < insertTabletPlan.getMeasurements().length; i++) {
-      if (insertTabletPlan.getColumns()[i] == null) {
+      if (insertTabletPlan.getColumns()[columnIndex] == null) {

Review comment:
       TODO: support insert partial columns

##########
File path: tsfile/src/main/java/org/apache/iotdb/tsfile/write/record/Tablet.java
##########
@@ -96,15 +107,33 @@ public Tablet(String deviceId, List<MeasurementSchema> schemas, int maxRowNumber
     reset();
   }
 
+  public void setDeviceId(String deviceId) {
+    this.deviceId = deviceId;
+  }
+
   public void addTimestamp(int rowIndex, long timestamp) {
     timestamps[rowIndex] = timestamp;
   }
 
   public void addValue(String measurementId, int rowIndex, Object value) {
     int indexOfValue = measurementIndex.get(measurementId);
-    MeasurementSchema measurementSchema = schemas.get(indexOfValue);
+    IMeasurementSchema measurementSchema = schemas.get(indexOfValue);
 
-    switch (measurementSchema.getType()) {
+    if (measurementSchema.getType().equals(TSDataType.VECTOR)) {
+      for (int i = 0; i < measurementSchema.getValueMeasurementIdList().size(); i++) {
+        TSDataType dataType = measurementSchema.getValueTSDataTypeList().get(i);
+        addValueOfDataType(dataType, rowIndex, measurementIndex.get(measurementId), value);

Review comment:
       the value belongs to a single series, do not traverse all series in the vector

##########
File path: tsfile/src/main/java/org/apache/iotdb/tsfile/write/schema/MeasurementSchema.java
##########
@@ -272,6 +321,32 @@ public int serializeTo(ByteBuffer buffer) {
     return byteLen;
   }
 
+  @Override
+  public int partialSerializeTo(OutputStream outputStream) throws IOException {
+    int byteLen = 0;
+
+    byteLen += ReadWriteIOUtils.write((byte) 0, outputStream);

Review comment:
       what's this for?

##########
File path: server/src/main/java/org/apache/iotdb/db/exception/metadata/AlignedTimeseriesException.java
##########
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.db.exception.metadata;
+
+import org.apache.iotdb.rpc.TSStatusCode;
+
+public class AlignedTimeseriesException extends MetadataException {
+
+  public AlignedTimeseriesException(String message, String path) {
+    super(String.format("%s (Path: %s)", message, path));

Review comment:
       make this clear

##########
File path: server/src/main/java/org/apache/iotdb/db/engine/memtable/AbstractMemTable.java
##########
@@ -256,22 +295,43 @@ public boolean isEmpty() {
   public ReadOnlyMemChunk query(
       String deviceId,
       String measurement,
-      TSDataType dataType,
-      TSEncoding encoding,
-      Map<String, String> props,
+      IMeasurementSchema schema,

Review comment:
       check if the measurement is redundant @JackieTien97 

##########
File path: server/src/main/java/org/apache/iotdb/db/engine/storagegroup/TsFileProcessor.java
##########
@@ -1055,16 +1129,12 @@ public String getStorageGroupName() {
    *
    * @param deviceId device id
    * @param measurementId measurements id
-   * @param dataType data type
-   * @param encoding encoding
    */
   @SuppressWarnings("squid:S3776") // Suppress high Cognitive Complexity warning
   public void query(
       String deviceId,
       String measurementId,
-      TSDataType dataType,
-      TSEncoding encoding,
-      Map<String, String> props,
+      IMeasurementSchema schema,

Review comment:
       check if the measurementId is redundant in schema




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