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 2019/11/19 02:24:33 UTC

[GitHub] [incubator-iotdb] SilverNarcissus commented on a change in pull request #553: [IOTDB-279] Merge TsDigest into Statistics

SilverNarcissus commented on a change in pull request #553: [IOTDB-279] Merge TsDigest into Statistics
URL: https://github.com/apache/incubator-iotdb/pull/553#discussion_r347696842
 
 

 ##########
 File path: tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/statistics/Statistics.java
 ##########
 @@ -299,4 +312,272 @@ public int serialize(OutputStream outputStream) throws IOException {
     }
     return length;
   }
+
+  public static int getNullDigestSize() {
+    return Integer.BYTES;
+  }
+
+  public static int serializeNullTo(OutputStream outputStream) throws IOException {
+    return ReadWriteIOUtils.write(0, outputStream);
+  }
+
+  public static int serializeNullTo(ByteBuffer buffer) {
+    return ReadWriteIOUtils.write(0, buffer);
+  }
+
+  /**
+   * use given input stream to deserialize.
+   *
+   * @param inputStream -given input stream
+   * @return -an instance of TsDigest
+   */
+  public static Statistics deserializeFrom(InputStream inputStream, TSDataType dataType) throws IOException {
+    Statistics digest = getStatsByType(dataType);
+    int size = ReadWriteIOUtils.readInt(inputStream);
+    digest.validSizeOfArray = size;
+    digest.digestSerializedSize = Integer.BYTES;
+    if (size > 0) {
+      digest.statistics = new ByteBuffer[StatisticType.getTotalTypeNum()];
+      ByteBuffer value;
+      // check if it's an old version of TsFile
+      String key = "";
+      if (TSFileDescriptor.getInstance().getConfig().getEndian().equals("LITTLE_ENDIAN")) {
 
 Review comment:
   You should use EndianType.LITTLE_ENDIAN.toString() rather than "LITTLE_ENDIAN"

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


With regards,
Apache Git Services