This is an automated email from the ASF dual-hosted git repository.

caogaofei pushed a commit to branch beyyes/fix_sonar
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit 3620e3b6e4666af950725a3d68e1480b148117da
Author: Beyyes <[email protected]>
AuthorDate: Wed Jun 21 10:52:15 2023 +0800

    fix sonar code smells in tsfile/file/metadata
---
 .../tsfile/file/metadata/AlignedChunkMetadata.java |  1 +
 .../file/metadata/AlignedTimeSeriesMetadata.java   |  3 +-
 .../tsfile/file/metadata/ChunkGroupMetadata.java   |  3 +-
 .../iotdb/tsfile/file/metadata/ChunkMetadata.java  | 10 ++-
 .../file/metadata/enums/CompressionType.java       | 22 ++++--
 .../file/metadata/enums/MetadataIndexNodeType.java | 11 +--
 .../tsfile/file/metadata/enums/TSDataType.java     | 37 ++++++---
 .../tsfile/file/metadata/enums/TSEncoding.java     |  1 +
 .../file/metadata/statistics/BinaryStatistics.java | 26 +++---
 .../metadata/statistics/BooleanStatistics.java     | 18 +++--
 .../file/metadata/statistics/DoubleStatistics.java | 18 +++--
 .../file/metadata/statistics/FloatStatistics.java  | 17 ++--
 .../metadata/statistics/IntegerStatistics.java     | 18 +++--
 .../file/metadata/statistics/LongStatistics.java   | 92 +++++++++++-----------
 .../file/metadata/statistics/Statistics.java       | 60 ++++++++------
 .../file/metadata/statistics/TimeStatistics.java   | 13 ++-
 16 files changed, 205 insertions(+), 145 deletions(-)

diff --git 
a/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/AlignedChunkMetadata.java
 
b/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/AlignedChunkMetadata.java
index fd7d9d02f15..a15dc645cc1 100644
--- 
a/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/AlignedChunkMetadata.java
+++ 
b/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/AlignedChunkMetadata.java
@@ -16,6 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+
 package org.apache.iotdb.tsfile.file.metadata;
 
 import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
diff --git 
a/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/AlignedTimeSeriesMetadata.java
 
b/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/AlignedTimeSeriesMetadata.java
index f49d8142691..21cde1c7665 100644
--- 
a/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/AlignedTimeSeriesMetadata.java
+++ 
b/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/AlignedTimeSeriesMetadata.java
@@ -16,6 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+
 package org.apache.iotdb.tsfile.file.metadata;
 
 import org.apache.iotdb.tsfile.file.metadata.statistics.Statistics;
@@ -42,7 +43,7 @@ public class AlignedTimeSeriesMetadata implements 
ITimeSeriesMetadata {
 
   /**
    * If the vector contains only one sub sensor, just return the sub sensor's 
Statistics Otherwise,
-   * return the Statistics of the time column
+   * return the Statistics of the time column.
    */
   @Override
   public Statistics getStatistics() {
diff --git 
a/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/ChunkGroupMetadata.java
 
b/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/ChunkGroupMetadata.java
index 7560d64b6a4..5c992142100 100644
--- 
a/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/ChunkGroupMetadata.java
+++ 
b/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/ChunkGroupMetadata.java
@@ -16,11 +16,12 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+
 package org.apache.iotdb.tsfile.file.metadata;
 
 import java.util.List;
 
-/** Only maintained when writing, not serialized to TsFile */
+/** Only maintained when writing, not serialized to TsFile. */
 public class ChunkGroupMetadata {
 
   private String device;
diff --git 
a/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/ChunkMetadata.java 
b/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/ChunkMetadata.java
index 312f83a84fa..7e6164912c1 100644
--- 
a/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/ChunkMetadata.java
+++ 
b/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/ChunkMetadata.java
@@ -16,6 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+
 package org.apache.iotdb.tsfile.file.metadata;
 
 import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
@@ -58,7 +59,7 @@ public class ChunkMetadata implements IChunkMetadata {
 
   private boolean modified;
 
-  /** ChunkLoader of metadata, used to create ChunkReaderWrap */
+  /** ChunkLoader of metadata, used to create ChunkReaderWrap. */
   private IChunkLoader chunkLoader;
 
   private Statistics<? extends Serializable> statistics;
@@ -124,7 +125,8 @@ public class ChunkMetadata implements IChunkMetadata {
   @Override
   public String toString() {
     return String.format(
-        "measurementId: %s, datatype: %s, version: %d, Statistics: %s, 
deleteIntervalList: %s, filePath: %s",
+        "measurementId: %s, datatype: %s, version: %d, "
+            + "Statistics: %s, deleteIntervalList: %s, filePath: %s",
         measurementUid, tsDataType, version, statistics, deleteIntervalList, 
filePath);
   }
 
@@ -323,8 +325,8 @@ public class ChunkMetadata implements IChunkMetadata {
   }
 
   public void mergeChunkMetadata(ChunkMetadata chunkMetadata) {
-    Statistics<? extends Serializable> statistics = 
chunkMetadata.getStatistics();
-    this.statistics.mergeStatistics(statistics);
+    Statistics<? extends Serializable> chunkMetadataStatistics = 
chunkMetadata.getStatistics();
+    this.statistics.mergeStatistics(chunkMetadataStatistics);
     this.ramSize = calculateRamSize();
   }
 
diff --git 
a/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/enums/CompressionType.java
 
b/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/enums/CompressionType.java
index 9afa137f27c..7ddc3be4576 100644
--- 
a/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/enums/CompressionType.java
+++ 
b/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/enums/CompressionType.java
@@ -16,24 +16,27 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+
 package org.apache.iotdb.tsfile.file.metadata.enums;
 
 public enum CompressionType {
-  /** Do not comprocess */
+  /** Do not comprocess. */
   UNCOMPRESSED("", (byte) 0),
 
-  /** SNAPPY */
+  /** SNAPPY. */
   SNAPPY(".snappy", (byte) 1),
 
-  /** GZIP */
+  /** GZIP. */
   GZIP(".gzip", (byte) 2),
 
-  /** LZ4 */
+  /** LZ4. */
   // NOTICE: To ensure the compatibility of existing files, do not change the 
byte LZ4 binds to.
   LZ4(".lz4", (byte) 7),
-  /** ZSTD */
+
+  /** ZSTD. */
   ZSTD(".zstd", (byte) 8),
-  /** LZMA2 */
+
+  /** LZMA2. */
   LZMA2(".lzma2", (byte) 9);
 
   private final String extensionName;
@@ -49,6 +52,7 @@ public enum CompressionType {
    *
    * @param compressor byte number
    * @return CompressionType
+   * @throws IllegalArgumentException illegal argument
    */
   public static CompressionType deserialize(byte compressor) {
     switch (compressor) {
@@ -73,7 +77,11 @@ public enum CompressionType {
     return Byte.BYTES;
   }
 
-  /** @return byte number */
+  /**
+   * get serialized size
+   *
+   * @return byte of index
+   */
   public byte serialize() {
     return this.index;
   }
diff --git 
a/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/enums/MetadataIndexNodeType.java
 
b/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/enums/MetadataIndexNodeType.java
index dc866f47e60..20fdc46c3b8 100644
--- 
a/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/enums/MetadataIndexNodeType.java
+++ 
b/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/enums/MetadataIndexNodeType.java
@@ -24,7 +24,7 @@ import java.io.IOException;
 import java.nio.ByteBuffer;
 
 /**
- * The type of MetadataIndexNode
+ * The type of MetadataIndexNode.
  *
  * <p>INTERNAL_DEVICE: internal nodes of the index tree's device level 
LEAF_DEVICE: leaf nodes of
  * the index tree's device level, points to measurement level 
INTERNAL_MEASUREMENT: internal nodes
@@ -32,16 +32,16 @@ import java.nio.ByteBuffer;
  * level, points to TimeseriesMetadata
  */
 public enum MetadataIndexNodeType {
-  /** INTERNAL_DEVICE */
+  /** INTERNAL_DEVICE. */
   INTERNAL_DEVICE((byte) 0),
 
-  /** LEAF_DEVICE */
+  /** LEAF_DEVICE. */
   LEAF_DEVICE((byte) 1),
 
-  /** INTERNAL_MEASUREMENT */
+  /** INTERNAL_MEASUREMENT. */
   INTERNAL_MEASUREMENT((byte) 2),
 
-  /** INTERNAL_MEASUREMENT */
+  /** INTERNAL_MEASUREMENT. */
   LEAF_MEASUREMENT((byte) 3);
 
   private final byte type;
@@ -55,6 +55,7 @@ public enum MetadataIndexNodeType {
    *
    * @param i byte number
    * @return MetadataIndexNodeType
+   * @throws IllegalArgumentException illegal argument
    */
   public static MetadataIndexNodeType deserialize(byte i) {
     switch (i) {
diff --git 
a/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/enums/TSDataType.java
 
b/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/enums/TSDataType.java
index 583a6cd5a24..200bfbfd75f 100644
--- 
a/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/enums/TSDataType.java
+++ 
b/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/enums/TSDataType.java
@@ -16,6 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+
 package org.apache.iotdb.tsfile.file.metadata.enums;
 
 import org.apache.iotdb.tsfile.exception.write.UnSupportedDataTypeException;
@@ -25,28 +26,28 @@ import java.io.IOException;
 import java.nio.ByteBuffer;
 
 public enum TSDataType {
-  /** BOOLEAN */
+  /** BOOLEAN. */
   BOOLEAN((byte) 0),
 
-  /** INT32 */
+  /** INT32. */
   INT32((byte) 1),
 
-  /** INT64 */
+  /** INT64. */
   INT64((byte) 2),
 
-  /** FLOAT */
+  /** FLOAT. */
   FLOAT((byte) 3),
 
-  /** DOUBLE */
+  /** DOUBLE. */
   DOUBLE((byte) 4),
 
-  /** TEXT */
+  /** TEXT. */
   TEXT((byte) 5),
 
-  /** VECTOR */
+  /** VECTOR. */
   VECTOR((byte) 6),
 
-  /** UNKNOWN */
+  /** UNKNOWN. */
   UNKNOWN((byte) 7);
 
   private final byte type;
@@ -126,12 +127,21 @@ public enum TSDataType {
     }
   }
 
-  /** @return byte number */
+  /**
+   * get type byte
+   *
+   * @return byte number
+   */
   public byte serialize() {
     return type;
   }
 
-  /** @return whether a numeric datatype */
+  /**
+   * numeric datatype judgement
+   *
+   * @return whether it is a numeric datatype
+   * @throws UnSupportedDataTypeException meets unSupported DataType
+   */
   public boolean isNumeric() {
     switch (this) {
       case INT32:
@@ -149,7 +159,12 @@ public enum TSDataType {
     }
   }
 
-  /** @return whether a comparable datatype */
+  /**
+   * comparable datatype judgement
+   *
+   * @return whether it is a comparable datatype
+   * @throws UnSupportedDataTypeException meets unSupported DataType
+   */
   public boolean isComparable() {
     switch (this) {
       case INT32:
diff --git 
a/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/enums/TSEncoding.java
 
b/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/enums/TSEncoding.java
index 75eae76cb7c..56cecda02e9 100644
--- 
a/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/enums/TSEncoding.java
+++ 
b/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/enums/TSEncoding.java
@@ -16,6 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+
 package org.apache.iotdb.tsfile.file.metadata.enums;
 
 public enum TSEncoding {
diff --git 
a/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/statistics/BinaryStatistics.java
 
b/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/statistics/BinaryStatistics.java
index 65a7363ba97..d19cb68d2dc 100644
--- 
a/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/statistics/BinaryStatistics.java
+++ 
b/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/statistics/BinaryStatistics.java
@@ -16,6 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+
 package org.apache.iotdb.tsfile.file.metadata.statistics;
 
 import org.apache.iotdb.tsfile.exception.filter.StatisticsClassException;
@@ -42,10 +43,7 @@ public class BinaryStatistics extends Statistics<Binary> {
     return TSDataType.TEXT;
   }
 
-  /**
-   * The output of this method should be identical to the method 
"serializeStats(OutputStream
-   * outputStream)"
-   */
+  /** The output of this method should be identical to the method 
"serializeStats(outputStream)". */
   @Override
   public int getStatsSize() {
     return 4 + firstValue.getValues().length + 4 + 
lastValue.getValues().length;
@@ -62,11 +60,11 @@ public class BinaryStatistics extends Statistics<Binary> {
     this.lastValue = last;
   }
 
-  private void updateStats(Binary firstValue, Binary lastValue) {
+  private void updateLastStats(Binary lastValue) {
     this.lastValue = lastValue;
   }
 
-  private void updateStats(Binary firstValue, Binary lastValue, long 
startTime, long endTime) {
+  private void updateLastStats(Binary firstValue, Binary lastValue, long 
startTime, long endTime) {
     // only if endTime greater or equals to the current endTime need we update 
the last value
     // only if startTime less or equals to the current startTime need we 
update the first value
     // otherwise, just ignore
@@ -119,7 +117,7 @@ public class BinaryStatistics extends Statistics<Binary> {
       initializeStats(stringStats.getFirstValue(), stringStats.getLastValue());
       isEmpty = false;
     } else {
-      updateStats(
+      updateLastStats(
           stringStats.getFirstValue(),
           stringStats.getLastValue(),
           stats.getStartTime(),
@@ -133,7 +131,7 @@ public class BinaryStatistics extends Statistics<Binary> {
       initializeStats(value, value);
       isEmpty = false;
     } else {
-      updateStats(value, value);
+      updateLastStats(value);
     }
   }
 
@@ -171,9 +169,15 @@ public class BinaryStatistics extends Statistics<Binary> {
 
   @Override
   public boolean equals(Object o) {
-    if (this == o) return true;
-    if (o == null || getClass() != o.getClass()) return false;
-    if (!super.equals(o)) return false;
+    if (this == o) {
+      return true;
+    }
+    if (o == null || getClass() != o.getClass()) {
+      return false;
+    }
+    if (!super.equals(o)) {
+      return false;
+    }
     BinaryStatistics that = (BinaryStatistics) o;
     return Objects.equals(firstValue, that.firstValue) && 
Objects.equals(lastValue, that.lastValue);
   }
diff --git 
a/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/statistics/BooleanStatistics.java
 
b/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/statistics/BooleanStatistics.java
index 300a3492dd3..c092068e419 100644
--- 
a/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/statistics/BooleanStatistics.java
+++ 
b/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/statistics/BooleanStatistics.java
@@ -16,6 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+
 package org.apache.iotdb.tsfile.file.metadata.statistics;
 
 import org.apache.iotdb.tsfile.exception.filter.StatisticsClassException;
@@ -41,10 +42,7 @@ public class BooleanStatistics extends Statistics<Boolean> {
     return TSDataType.BOOLEAN;
   }
 
-  /**
-   * The output of this method should be identical to the method 
"serializeStats(OutputStream
-   * outputStream)"
-   */
+  /** The output of this method should be identical to the method 
"serializeStats(outputStream)". */
   @Override
   public int getStatsSize() {
     return 10;
@@ -177,9 +175,15 @@ public class BooleanStatistics extends Statistics<Boolean> 
{
 
   @Override
   public boolean equals(Object o) {
-    if (this == o) return true;
-    if (o == null || getClass() != o.getClass()) return false;
-    if (!super.equals(o)) return false;
+    if (this == o) {
+      return true;
+    }
+    if (o == null || getClass() != o.getClass()) {
+      return false;
+    }
+    if (!super.equals(o)) {
+      return false;
+    }
     BooleanStatistics that = (BooleanStatistics) o;
     return firstValue == that.firstValue
         && lastValue == that.lastValue
diff --git 
a/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/statistics/DoubleStatistics.java
 
b/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/statistics/DoubleStatistics.java
index 4176a7d8ac3..fabeb4e5db9 100644
--- 
a/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/statistics/DoubleStatistics.java
+++ 
b/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/statistics/DoubleStatistics.java
@@ -16,6 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+
 package org.apache.iotdb.tsfile.file.metadata.statistics;
 
 import org.apache.iotdb.tsfile.exception.filter.StatisticsClassException;
@@ -43,10 +44,7 @@ public class DoubleStatistics extends Statistics<Double> {
     return TSDataType.DOUBLE;
   }
 
-  /**
-   * The output of this method should be identical to the method 
"serializeStats(OutputStream
-   * outputStream)"
-   */
+  /** The output of this method should be identical to the method 
"serializeStats(outputStream)". */
   @Override
   public int getStatsSize() {
     return 40;
@@ -213,9 +211,15 @@ public class DoubleStatistics extends Statistics<Double> {
 
   @Override
   public boolean equals(Object o) {
-    if (this == o) return true;
-    if (o == null || getClass() != o.getClass()) return false;
-    if (!super.equals(o)) return false;
+    if (this == o) {
+      return true;
+    }
+    if (o == null || getClass() != o.getClass()) {
+      return false;
+    }
+    if (!super.equals(o)) {
+      return false;
+    }
     double e = 0.00001;
     DoubleStatistics that = (DoubleStatistics) o;
     return Math.abs(that.minValue - minValue) < e
diff --git 
a/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/statistics/FloatStatistics.java
 
b/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/statistics/FloatStatistics.java
index 30e54005079..4ba3a2646a9 100644
--- 
a/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/statistics/FloatStatistics.java
+++ 
b/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/statistics/FloatStatistics.java
@@ -44,10 +44,7 @@ public class FloatStatistics extends Statistics<Float> {
     return TSDataType.FLOAT;
   }
 
-  /**
-   * The output of this method should be identical to the method 
"serializeStats(OutputStream
-   * outputStream)"
-   */
+  /** The output of this method should be identical to the method 
"serializeStats(outputStream)". */
   @Override
   public int getStatsSize() {
     return 24;
@@ -205,9 +202,15 @@ public class FloatStatistics extends Statistics<Float> {
 
   @Override
   public boolean equals(Object o) {
-    if (this == o) return true;
-    if (o == null || getClass() != o.getClass()) return false;
-    if (!super.equals(o)) return false;
+    if (this == o) {
+      return true;
+    }
+    if (o == null || getClass() != o.getClass()) {
+      return false;
+    }
+    if (!super.equals(o)) {
+      return false;
+    }
     double e = 0.00001;
     FloatStatistics that = (FloatStatistics) o;
     return Math.abs(that.minValue - minValue) < e
diff --git 
a/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/statistics/IntegerStatistics.java
 
b/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/statistics/IntegerStatistics.java
index 1ed3174195d..d97a9403145 100644
--- 
a/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/statistics/IntegerStatistics.java
+++ 
b/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/statistics/IntegerStatistics.java
@@ -16,6 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+
 package org.apache.iotdb.tsfile.file.metadata.statistics;
 
 import org.apache.iotdb.tsfile.exception.filter.StatisticsClassException;
@@ -44,10 +45,7 @@ public class IntegerStatistics extends Statistics<Integer> {
     return TSDataType.INT32;
   }
 
-  /**
-   * The output of this method should be identical to the method 
"serializeStats(OutputStream
-   * outputStream)"
-   */
+  /** The output of this method should be identical to the method 
"serializeStats(outputStream)". */
   @Override
   public int getStatsSize() {
     return 24;
@@ -205,9 +203,15 @@ public class IntegerStatistics extends Statistics<Integer> 
{
 
   @Override
   public boolean equals(Object o) {
-    if (this == o) return true;
-    if (o == null || getClass() != o.getClass()) return false;
-    if (!super.equals(o)) return false;
+    if (this == o) {
+      return true;
+    }
+    if (o == null || getClass() != o.getClass()) {
+      return false;
+    }
+    if (!super.equals(o)) {
+      return false;
+    }
     IntegerStatistics that = (IntegerStatistics) o;
     return minValue == that.minValue
         && maxValue == that.maxValue
diff --git 
a/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/statistics/LongStatistics.java
 
b/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/statistics/LongStatistics.java
index 4df12df78cb..54cc35d4d3a 100644
--- 
a/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/statistics/LongStatistics.java
+++ 
b/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/statistics/LongStatistics.java
@@ -16,6 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+
 package org.apache.iotdb.tsfile.file.metadata.statistics;
 
 import org.apache.iotdb.tsfile.exception.filter.StatisticsClassException;
@@ -43,10 +44,7 @@ public class LongStatistics extends Statistics<Long> {
     return TSDataType.INT64;
   }
 
-  /**
-   * The output of this method should be identical to the method 
"serializeStats(OutputStream
-   * outputStream)"
-   */
+  /** The output of this method should be identical to the method 
"serializeStats(outputStream)". */
   @Override
   public int getStatsSize() {
     return 40;
@@ -60,43 +58,6 @@ public class LongStatistics extends Statistics<Long> {
     this.sumValue += sum;
   }
 
-  private void updateStats(long minValue, long maxValue, long lastValue, 
double sumValue) {
-    if (minValue < this.minValue) {
-      this.minValue = minValue;
-    }
-    if (maxValue > this.maxValue) {
-      this.maxValue = maxValue;
-    }
-    this.sumValue += sumValue;
-    this.lastValue = lastValue;
-  }
-
-  private void updateStats(
-      long minValue,
-      long maxValue,
-      long firstValue,
-      long lastValue,
-      double sumValue,
-      long startTime,
-      long endTime) {
-    if (minValue < this.minValue) {
-      this.minValue = minValue;
-    }
-    if (maxValue > this.maxValue) {
-      this.maxValue = maxValue;
-    }
-    this.sumValue += sumValue;
-    // only if endTime greater or equals to the current endTime need we update 
the last value
-    // only if startTime less or equals to the current startTime need we 
update the first value
-    // otherwise, just ignore
-    if (startTime <= this.getStartTime()) {
-      this.firstValue = firstValue;
-    }
-    if (endTime >= this.getEndTime()) {
-      this.lastValue = lastValue;
-    }
-  }
-
   @Override
   public Long getMinValue() {
     return minValue;
@@ -155,6 +116,43 @@ public class LongStatistics extends Statistics<Long> {
     }
   }
 
+  private void updateStats(long minValue, long maxValue, long lastValue, 
double sumValue) {
+    if (minValue < this.minValue) {
+      this.minValue = minValue;
+    }
+    if (maxValue > this.maxValue) {
+      this.maxValue = maxValue;
+    }
+    this.sumValue += sumValue;
+    this.lastValue = lastValue;
+  }
+
+  private void updateStats(
+      long minValue,
+      long maxValue,
+      long firstValue,
+      long lastValue,
+      double sumValue,
+      long startTime,
+      long endTime) {
+    if (minValue < this.minValue) {
+      this.minValue = minValue;
+    }
+    if (maxValue > this.maxValue) {
+      this.maxValue = maxValue;
+    }
+    this.sumValue += sumValue;
+    // only if endTime greater or equals to the current endTime need we update 
the last value
+    // only if startTime less or equals to the current startTime need we 
update the first value
+    // otherwise, just ignore
+    if (startTime <= this.getStartTime()) {
+      this.firstValue = firstValue;
+    }
+    if (endTime >= this.getEndTime()) {
+      this.lastValue = lastValue;
+    }
+  }
+
   @Override
   public long calculateRamSize() {
     return LONG_STATISTICS_FIXED_RAM_SIZE;
@@ -214,9 +212,15 @@ public class LongStatistics extends Statistics<Long> {
 
   @Override
   public boolean equals(Object o) {
-    if (this == o) return true;
-    if (o == null || getClass() != o.getClass()) return false;
-    if (!super.equals(o)) return false;
+    if (this == o) {
+      return true;
+    }
+    if (o == null || getClass() != o.getClass()) {
+      return false;
+    }
+    if (!super.equals(o)) {
+      return false;
+    }
     LongStatistics that = (LongStatistics) o;
     return minValue == that.minValue
         && maxValue == that.maxValue
diff --git 
a/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/statistics/Statistics.java
 
b/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/statistics/Statistics.java
index 60093266d67..c516065d6c9 100644
--- 
a/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/statistics/Statistics.java
+++ 
b/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/statistics/Statistics.java
@@ -16,6 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+
 package org.apache.iotdb.tsfile.file.metadata.statistics;
 
 import org.apache.iotdb.tsfile.exception.filter.StatisticsClassException;
@@ -49,11 +50,11 @@ public abstract class Statistics<T extends Serializable> {
 
   private static final Logger LOG = LoggerFactory.getLogger(Statistics.class);
   /**
-   * isEmpty being false means this statistic has been initialized and the max 
and min is not null;
+   * isEmpty being false means this statistic has been initialized and the max 
and min is not null.
    */
   protected boolean isEmpty = true;
 
-  /** number of time-value points */
+  /** number of time-value points. */
   private int count = 0;
 
   private long startTime = Long.MAX_VALUE;
@@ -66,6 +67,7 @@ public abstract class Statistics<T extends Serializable> {
    *
    * @param type - data type
    * @return Statistics
+   * @throws UnknownColumnTypeException if the type is unknown
    */
   public static Statistics<? extends Serializable> getStatsByType(TSDataType 
type) {
     switch (type) {
@@ -131,11 +133,38 @@ public abstract class Statistics<T extends Serializable> {
 
   abstract int serializeStats(OutputStream outputStream) throws IOException;
 
-  /** read data from the inputStream. */
+  /**
+   * read data from the inputStream.
+   *
+   * @param inputStream input stream
+   * @throws IOException exception when operating stream
+   */
   public abstract void deserialize(InputStream inputStream) throws IOException;
 
   public abstract void deserialize(ByteBuffer byteBuffer);
 
+  public static Statistics<? extends Serializable> deserialize(
+      InputStream inputStream, TSDataType dataType) throws IOException {
+    Statistics<? extends Serializable> statistics = getStatsByType(dataType);
+    
statistics.setCount(ReadWriteForEncodingUtils.readUnsignedVarInt(inputStream));
+    statistics.setStartTime(ReadWriteIOUtils.readLong(inputStream));
+    statistics.setEndTime(ReadWriteIOUtils.readLong(inputStream));
+    statistics.deserialize(inputStream);
+    statistics.isEmpty = false;
+    return statistics;
+  }
+
+  public static Statistics<? extends Serializable> deserialize(
+      ByteBuffer buffer, TSDataType dataType) {
+    Statistics<? extends Serializable> statistics = getStatsByType(dataType);
+    statistics.setCount(ReadWriteForEncodingUtils.readUnsignedVarInt(buffer));
+    statistics.setStartTime(ReadWriteIOUtils.readLong(buffer));
+    statistics.setEndTime(ReadWriteIOUtils.readLong(buffer));
+    statistics.deserialize(buffer);
+    statistics.isEmpty = false;
+    return statistics;
+  }
+
   public abstract T getMinValue();
 
   public abstract T getMaxValue();
@@ -149,7 +178,7 @@ public abstract class Statistics<T extends Serializable> {
   public abstract long getSumLongValue();
 
   /**
-   * merge parameter to this statistic
+   * merge parameter to this statistic.
    *
    * @throws StatisticsClassException cannot merge statistics
    */
@@ -331,33 +360,12 @@ public abstract class Statistics<T extends Serializable> {
    *
    * @param min min timestamp
    * @param max max timestamp
+   * @throws UnsupportedOperationException throw exception when executing this 
method
    */
   public void updateStats(long min, long max) {
     throw new UnsupportedOperationException();
   }
 
-  public static Statistics<? extends Serializable> deserialize(
-      InputStream inputStream, TSDataType dataType) throws IOException {
-    Statistics<? extends Serializable> statistics = getStatsByType(dataType);
-    
statistics.setCount(ReadWriteForEncodingUtils.readUnsignedVarInt(inputStream));
-    statistics.setStartTime(ReadWriteIOUtils.readLong(inputStream));
-    statistics.setEndTime(ReadWriteIOUtils.readLong(inputStream));
-    statistics.deserialize(inputStream);
-    statistics.isEmpty = false;
-    return statistics;
-  }
-
-  public static Statistics<? extends Serializable> deserialize(
-      ByteBuffer buffer, TSDataType dataType) {
-    Statistics<? extends Serializable> statistics = getStatsByType(dataType);
-    statistics.setCount(ReadWriteForEncodingUtils.readUnsignedVarInt(buffer));
-    statistics.setStartTime(ReadWriteIOUtils.readLong(buffer));
-    statistics.setEndTime(ReadWriteIOUtils.readLong(buffer));
-    statistics.deserialize(buffer);
-    statistics.isEmpty = false;
-    return statistics;
-  }
-
   public long getStartTime() {
     return startTime;
   }
diff --git 
a/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/statistics/TimeStatistics.java
 
b/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/statistics/TimeStatistics.java
index 60ce5581878..71533ae6011 100644
--- 
a/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/statistics/TimeStatistics.java
+++ 
b/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/statistics/TimeStatistics.java
@@ -16,6 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+
 package org.apache.iotdb.tsfile.file.metadata.statistics;
 
 import org.apache.iotdb.tsfile.exception.filter.StatisticsClassException;
@@ -30,16 +31,14 @@ public class TimeStatistics extends Statistics<Long> {
 
   static final int TIME_STATISTICS_FIXED_RAM_SIZE = 40;
   private static final String TIME = "Time";
+  private static final String UPDATE_STATS = "update stats";
 
   @Override
   public TSDataType getType() {
     return TSDataType.VECTOR;
   }
 
-  /**
-   * The output of this method should be identical to the method 
"serializeStats(OutputStream
-   * outputStream)"
-   */
+  /** The output of this method should be identical to the method 
"serializeStats(outputStream)". */
   @Override
   public int getStatsSize() {
     return 0;
@@ -99,17 +98,17 @@ public class TimeStatistics extends Statistics<Long> {
 
   @Override
   void updateStats(long value) {
-    throw new StatisticsClassException(String.format(STATS_UNSUPPORTED_MSG, 
TIME, "update stats"));
+    throw new StatisticsClassException(String.format(STATS_UNSUPPORTED_MSG, 
TIME, UPDATE_STATS));
   }
 
   @Override
   void updateStats(long[] values, int batchSize) {
-    throw new StatisticsClassException(String.format(STATS_UNSUPPORTED_MSG, 
TIME, "update stats"));
+    throw new StatisticsClassException(String.format(STATS_UNSUPPORTED_MSG, 
TIME, UPDATE_STATS));
   }
 
   @Override
   public void updateStats(long minValue, long maxValue) {
-    throw new StatisticsClassException(String.format(STATS_UNSUPPORTED_MSG, 
TIME, "update stats"));
+    throw new StatisticsClassException(String.format(STATS_UNSUPPORTED_MSG, 
TIME, UPDATE_STATS));
   }
 
   @Override

Reply via email to