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 2023/06/29 02:21:30 UTC

[iotdb] branch master updated: Fix bugs and code smells detected by SonarLint in TsFile encoder (#10324)

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 19fe00b176e Fix bugs and code smells detected by SonarLint in TsFile encoder (#10324)
19fe00b176e is described below

commit 19fe00b176e6be6d5e17364bf43f3229c91a94e4
Author: Zhang.Jinrui <xi...@gmail.com>
AuthorDate: Thu Jun 29 10:21:23 2023 +0800

    Fix bugs and code smells detected by SonarLint in TsFile encoder (#10324)
---
 .../tsfile/encoding/encoder/BitmapEncoder.java     |   2 -
 .../encoding/encoder/DeltaBinaryEncoder.java       |   4 +-
 .../tsfile/encoding/encoder/DictionaryEncoder.java |   2 +-
 .../iotdb/tsfile/encoding/encoder/DoubleRLBE.java  | 135 ++++++++++++---------
 .../encoding/encoder/DoubleSprintzEncoder.java     |  27 +++--
 .../encoding/encoder/FloatSprintzEncoder.java      |   4 +-
 .../tsfile/encoding/encoder/GorillaEncoderV1.java  |   1 +
 .../tsfile/encoding/encoder/GorillaEncoderV2.java  |   4 +-
 .../tsfile/encoding/encoder/IntChimpEncoder.java   |  18 +--
 .../tsfile/encoding/encoder/IntGorillaEncoder.java |   4 +-
 .../iotdb/tsfile/encoding/encoder/IntRLBE.java     | 129 +++++++++++---------
 .../tsfile/encoding/encoder/IntRleEncoder.java     |   2 +-
 .../tsfile/encoding/encoder/IntSprintzEncoder.java |  23 ++--
 .../tsfile/encoding/encoder/IntZigzagEncoder.java  |   6 +-
 .../tsfile/encoding/encoder/LongChimpEncoder.java  |  22 ++--
 .../encoding/encoder/LongGorillaEncoder.java       |   4 +-
 .../iotdb/tsfile/encoding/encoder/LongRLBE.java    | 129 +++++++++++---------
 .../tsfile/encoding/encoder/LongRleEncoder.java    |   2 +-
 .../encoding/encoder/LongSprintzEncoder.java       |  25 ++--
 .../tsfile/encoding/encoder/LongZigzagEncoder.java |   7 +-
 .../tsfile/encoding/encoder/PlainEncoder.java      |  12 +-
 .../apache/iotdb/tsfile/encoding/encoder/RLBE.java |  16 +--
 .../encoding/encoder/RegularDataEncoder.java       |   4 +-
 .../iotdb/tsfile/encoding/encoder/RleEncoder.java  |   2 -
 .../iotdb/tsfile/encoding/encoder/SDTEncoder.java  |  56 ++++-----
 .../tsfile/encoding/encoder/SprintzEncoder.java    |  16 +--
 .../tsfile/encoding/encoder/TSEncodingBuilder.java |   5 +-
 27 files changed, 359 insertions(+), 302 deletions(-)

diff --git a/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/BitmapEncoder.java b/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/BitmapEncoder.java
index ec0cbae9349..a25839731d5 100644
--- a/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/BitmapEncoder.java
+++ b/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/BitmapEncoder.java
@@ -45,8 +45,6 @@ import java.util.Set;
  * bit-index := a list of 01 sequence to record the position of the value above
  * }</pre>
  *
- * .
- *
  * <p>Decode switch or enum values using bitmap, bitmap-encode.{@code <length> <num> <encoded data>
  * }
  */
diff --git a/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/DeltaBinaryEncoder.java b/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/DeltaBinaryEncoder.java
index b95846085e3..adac76fb807 100644
--- a/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/DeltaBinaryEncoder.java
+++ b/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/DeltaBinaryEncoder.java
@@ -60,7 +60,7 @@ public abstract class DeltaBinaryEncoder extends Encoder {
    *
    * @param size - the number how many numbers to be packed into a block.
    */
-  public DeltaBinaryEncoder(int size) {
+  protected DeltaBinaryEncoder(int size) {
     super(TSEncoding.TS_2DIFF);
     blockSize = size;
   }
@@ -80,7 +80,7 @@ public abstract class DeltaBinaryEncoder extends Encoder {
     for (int i = 0; i < writeIndex; i++) {
       writeValueToBytes(i);
     }
-    int encodingLength = (int) Math.ceil((double) (writeIndex * writeWidth) / 8.0);
+    int encodingLength = (int) Math.ceil((writeIndex * writeWidth) / 8.0);
     out.write(encodingBlockBuffer, 0, encodingLength);
   }
 
diff --git a/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/DictionaryEncoder.java b/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/DictionaryEncoder.java
index b339c71a035..4a55e143fc2 100644
--- a/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/DictionaryEncoder.java
+++ b/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/DictionaryEncoder.java
@@ -63,7 +63,7 @@ public class DictionaryEncoder extends Encoder {
   public void encode(Binary value, ByteArrayOutputStream out) {
     entryIndex.computeIfAbsent(
         value,
-        (v) -> {
+        v -> {
           indexEntry.add(v);
           mapSize += v.getLength();
           return entryIndex.size();
diff --git a/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/DoubleRLBE.java b/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/DoubleRLBE.java
index 429ef3524c0..a9becdc66de 100644
--- a/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/DoubleRLBE.java
+++ b/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/DoubleRLBE.java
@@ -20,19 +20,18 @@
 package org.apache.iotdb.tsfile.encoding.encoder;
 
 import java.io.ByteArrayOutputStream;
-import java.io.IOException;
 
 public class DoubleRLBE extends RLBE {
-  /** delta values */
-  private double[] DiffValue = new double[blockSize + 1];
+  // delta values
+  private final double[] diffValue = new double[blockSize + 1];
 
-  /** repeat times on length code */
-  private long[] Lengrle = new long[blockSize + 1];
+  // repeat times on length code
+  private final long[] lengRLE = new long[blockSize + 1];
 
-  /** previous value of original value */
-  private double previousvalue;
+  // previous value of original value
+  private double previousValue;
 
-  /** constructor of DoubleRLBE */
+  // constructor of DoubleRLBE
   public DoubleRLBE() {
     super();
     reset();
@@ -42,43 +41,51 @@ public class DoubleRLBE extends RLBE {
     writeIndex = -1;
     LengthCode = new int[blockSize + 1];
     for (int i = 0; i < blockSize; i++) {
-      DiffValue[i] = 0;
+      diffValue[i] = 0;
       LengthCode[i] = 0;
       byteBuffer = 0;
       numberLeftInBuffer = 0;
-      Lengrle[i] = 0;
+      lengRLE[i] = 0;
     }
   }
 
   /**
-   * calculate the binary code length of given long integer
+   * calculate the binary code length of given long integer.
    *
    * @param val the long integer to calculate length
    * @return the length of val's binary code
    */
   private int calBinarylength(long val) {
-    if (val == 0) return 1;
+    if (val == 0) {
+      return 1;
+    }
     int i = 64;
-    while ((((long) 1 << (i - 1)) & val) == 0 && i > 0) i--;
+    while ((((long) 1 << (i - 1)) & val) == 0 && i > 0) {
+      i--;
+    }
     return i;
   }
 
   /**
-   * calculate the binary code length of given double note: double is transfered into long first
+   * calculate the binary code length of given double note: double is transfered into long first.
    *
    * @param v the double to calculate length
    * @return the length of val's binary code
    */
   private int calBinarylength(double v) {
     long val = Double.doubleToRawLongBits(v);
-    if (val == 0) return 1;
+    if (val == 0) {
+      return 1;
+    }
     int i = 64;
-    while ((((long) 1 << (i - 1)) & val) == 0 && i > 0) i--;
+    while ((((long) 1 << (i - 1)) & val) == 0 && i > 0) {
+      i--;
+    }
     return i;
   }
 
   /**
-   * encode one input integer value
+   * encode one input integer value.
    *
    * @param value the integer to be encoded
    * @param out the output stream to flush in when buffer is full
@@ -86,16 +93,16 @@ public class DoubleRLBE extends RLBE {
   public void encodeValue(double value, ByteArrayOutputStream out) {
     if (writeIndex == -1) {
       // when the first value hasn't encoded yet
-      DiffValue[++writeIndex] = value;
+      diffValue[++writeIndex] = value;
       LengthCode[writeIndex] = calBinarylength(value);
-      previousvalue = value;
+      previousValue = value;
       return;
     }
     // calculate delta value
-    DiffValue[++writeIndex] = value - previousvalue;
+    diffValue[++writeIndex] = value - previousValue;
     // caldulate the length of delta value
-    LengthCode[writeIndex] = calBinarylength(DiffValue[writeIndex]);
-    previousvalue = value;
+    LengthCode[writeIndex] = calBinarylength(diffValue[writeIndex]);
+    previousValue = value;
     if (writeIndex == blockSize - 1) {
       // when encoded number reach to blocksize
       flush(out);
@@ -113,29 +120,31 @@ public class DoubleRLBE extends RLBE {
   }
 
   /**
-   * calculate fibonacci code of input long integer
+   * calculate fibonacci code of input long integer.
    *
    * @param val the long integer to be fibonacci-encoded
    * @return the reverse fibonacci code of val in binary code
    */
   protected long calcFibonacci(long val) {
     // fibonacci values are stored in Fib
-    long[] Fib = new long[blockSize * 2 + 1];
-    Fib[0] = 1;
-    Fib[1] = 1;
+    long[] fib = new long[blockSize * 2 + 1];
+    fib[0] = 1;
+    fib[1] = 1;
     int i;
     // generate fibonacci values from 1 to the first one larger than val
-    for (i = 2; Fib[i - 1] <= val; i++) {
-      Fib[i] = Fib[i - 1] + Fib[i - 2];
+    for (i = 2; fib[i - 1] <= val; i++) {
+      fib[i] = fib[i - 1] + fib[i - 2];
     }
 
     i--;
     long valfib = 0;
     // calculate fibonacci code
     while (val > 0) {
-      while (Fib[i] > val && i >= 1) i--;
+      while (fib[i] > val && i >= 1) {
+        i--;
+      }
       valfib |= (1 << (i - 1));
-      val -= Fib[i];
+      val -= fib[i];
     }
     return valfib;
   }
@@ -151,13 +160,13 @@ public class DoubleRLBE extends RLBE {
         temprlecal++;
       }
       // store repeat time at the first repeating value's position
-      Lengrle[i] = temprlecal;
+      lengRLE[i] = temprlecal;
       i = j;
     }
   }
 
   /**
-   * flush all encoded values in a block to output stream
+   * flush all encoded values in a block to output stream.
    *
    * @param out the output stream to be flushed to
    */
@@ -170,36 +179,38 @@ public class DoubleRLBE extends RLBE {
     // calculate length code of delta binary length
     rleonlengthcode();
     for (int i = 0; i <= writeIndex; i++) {
-      if (Lengrle[i] > 0) // flush the adjacent same length delta values
-      try {
-          flushsegment(i, out);
-        } catch (IOException e) {
-          logger.error("flush data to stream failed!", e);
-        }
+      if (lengRLE[i] > 0) { // flush the adjacent same length delta values
+        flushSegment(i, out);
+      }
     }
     clearBuffer(out);
     reset();
   }
 
   /**
-   * flush the adjacent same-length delta values
+   * flush the adjacent same-length delta values.
    *
    * @param i the position of the first delta value
    * @param out output stream
-   * @throws IOException
    */
-  private void flushsegment(int i, ByteArrayOutputStream out) throws IOException {
+  private void flushSegment(int i, ByteArrayOutputStream out) {
     // write the first 6 bits: length code in binary words.
     for (int j = 6; j >= 0; j--) {
-      if ((LengthCode[i] & (1 << j)) > 0) writeBit(true, out);
-      else writeBit(false, out);
+      if ((LengthCode[i] & (1 << j)) > 0) {
+        writeBit(true, out);
+      } else {
+        writeBit(false, out);
+      }
     }
     // write the fibonacci code in normal direction
-    long fib = calcFibonacci(Lengrle[i]);
+    long fib = calcFibonacci(lengRLE[i]);
     int fiblen = calBinarylength(fib);
     for (int j = 0; j < fiblen; j++) {
-      if ((fib & (1 << j)) > 0) writeBit(true, out);
-      else writeBit(false, out);
+      if ((fib & (1 << j)) > 0) {
+        writeBit(true, out);
+      } else {
+        writeBit(false, out);
+      }
     }
     // write '1' to note the end of fibonacci code
     writeBit(true, out);
@@ -207,14 +218,17 @@ public class DoubleRLBE extends RLBE {
     // write Binary code words
     int j = i;
     do {
-      int tempDifflen = calBinarylength(DiffValue[j]);
-      long tempDiff = Double.doubleToRawLongBits(DiffValue[j]);
+      int tempDifflen = calBinarylength(diffValue[j]);
+      long tempDiff = Double.doubleToRawLongBits(diffValue[j]);
       for (int k = tempDifflen - 1; k >= 0; k--) {
-        if ((tempDiff & ((long) 1 << k)) > 0) writeBit(true, out);
-        else writeBit(false, out);
+        if ((tempDiff & ((long) 1 << k)) > 0) {
+          writeBit(true, out);
+        } else {
+          writeBit(false, out);
+        }
       }
       j++;
-    } while (Lengrle[j] == 0 && j <= writeIndex);
+    } while (lengRLE[j] == 0 && j <= writeIndex);
   }
 
   @Override
@@ -224,7 +238,7 @@ public class DoubleRLBE extends RLBE {
 
   @Override
   public long getMaxByteSize() {
-    return 5 * 4 * blockSize * 2;
+    return 5L * 4 * blockSize * 2;
   }
 
   /**
@@ -246,13 +260,17 @@ public class DoubleRLBE extends RLBE {
   }
 
   /**
-   * flush bits left in byteBuffer to output stream
+   * flush bits left in byteBuffer to output stream.
    *
    * @param out output stream
    */
   protected void clearBuffer(ByteArrayOutputStream out) {
-    if (numberLeftInBuffer == 0) return;
-    if (numberLeftInBuffer > 0) byteBuffer <<= (8 - numberLeftInBuffer);
+    if (numberLeftInBuffer == 0) {
+      return;
+    }
+    if (numberLeftInBuffer > 0) {
+      byteBuffer <<= (8 - numberLeftInBuffer);
+    }
     out.write(byteBuffer);
     numberLeftInBuffer = 0;
     byteBuffer = 0;
@@ -265,8 +283,11 @@ public class DoubleRLBE extends RLBE {
    */
   private void writewriteIndex(ByteArrayOutputStream out) {
     for (int i = 31; i >= 0; i--) {
-      if ((writeIndex + 1 & (1 << i)) > 0) writeBit(true, out);
-      else writeBit(false, out);
+      if ((writeIndex + 1 & (1 << i)) > 0) {
+        writeBit(true, out);
+      } else {
+        writeBit(false, out);
+      }
     }
   }
 }
diff --git a/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/DoubleSprintzEncoder.java b/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/DoubleSprintzEncoder.java
index 62f34c6cfab..9a9ba4cac0c 100644
--- a/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/DoubleSprintzEncoder.java
+++ b/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/DoubleSprintzEncoder.java
@@ -31,21 +31,21 @@ import java.util.Vector;
 
 public class DoubleSprintzEncoder extends SprintzEncoder {
 
-  /** bit packer */
+  // bit packer
   LongPacker packer;
 
-  /** Long Fire Predictor * */
+  // Long Fire Predictor
   LongFire firePred;
 
-  /** we save all value in a list and calculate its bitwidth. */
+  // we save all value in a list and calculate its bitWidth
   protected Vector<Double> values;
 
-  /** convert to Long Buffer * */
+  // convert to Long Buffer
   long[] convertBuffer;
 
   public DoubleSprintzEncoder() {
     super();
-    values = new Vector<Double>();
+    values = new Vector<>();
     firePred = new LongFire(3);
     convertBuffer = new long[Block_size];
   }
@@ -68,25 +68,30 @@ public class DoubleSprintzEncoder extends SprintzEncoder {
 
   protected long predict(Double value, Double preVlaue) throws TsFileEncodingException {
     long pred;
-    if (PredictMethod.equals("delta")) {
+    if (predictMethod.equals("delta")) {
       pred = delta(value, preVlaue);
-    } else if (PredictMethod.equals("fire")) {
+    } else if (predictMethod.equals("fire")) {
       pred = fire(value, preVlaue);
     } else {
       throw new TsFileEncodingException(
           "Config: Predict Method {} of SprintzEncoder is not supported.");
     }
-    if (pred <= 0) pred = -2 * pred;
-    else pred = 2 * pred - 1; // TODO:overflow
+    if (pred <= 0) {
+      pred = -2 * pred;
+    } else {
+      pred = 2 * pred - 1; // TODO:overflow
+    }
     return pred;
   }
 
   @Override
   protected void bitPack() throws IOException {
-    double preValue = values.get(0);
+    final double preValue = values.get(0);
     values.remove(0);
     Vector<Long> convertBufferList = new Vector<>();
-    for (long itemBuffer : convertBuffer) convertBufferList.add(itemBuffer);
+    for (long itemBuffer : convertBuffer) {
+      convertBufferList.add(itemBuffer);
+    }
     this.bitWidth = ReadWriteForEncodingUtils.getLongMaxBitWidth(convertBufferList);
     packer = new LongPacker(this.bitWidth);
     byte[] bytes = new byte[bitWidth];
diff --git a/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/FloatSprintzEncoder.java b/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/FloatSprintzEncoder.java
index 08559ef17ed..3100514e116 100644
--- a/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/FloatSprintzEncoder.java
+++ b/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/FloatSprintzEncoder.java
@@ -67,9 +67,9 @@ public class FloatSprintzEncoder extends SprintzEncoder {
 
   protected int predict(Float value, Float preVlaue) throws TsFileEncodingException {
     int pred;
-    if (PredictMethod.equals("delta")) {
+    if (predictMethod.equals("delta")) {
       pred = delta(value, preVlaue);
-    } else if (PredictMethod.equals("fire")) {
+    } else if (predictMethod.equals("fire")) {
       pred = fire(value, preVlaue);
     } else {
       throw new TsFileEncodingException(
diff --git a/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/GorillaEncoderV1.java b/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/GorillaEncoderV1.java
index 2815d470e30..71213904301 100644
--- a/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/GorillaEncoderV1.java
+++ b/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/GorillaEncoderV1.java
@@ -16,6 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+
 package org.apache.iotdb.tsfile.encoding.encoder;
 
 import org.apache.iotdb.tsfile.file.metadata.enums.TSEncoding;
diff --git a/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/GorillaEncoderV2.java b/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/GorillaEncoderV2.java
index 00422e7e780..9af575bbcfd 100644
--- a/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/GorillaEncoderV2.java
+++ b/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/GorillaEncoderV2.java
@@ -59,13 +59,13 @@ public abstract class GorillaEncoderV2 extends Encoder {
     bitsLeft = Byte.SIZE;
   }
 
-  /** Stores a 0 and increases the count of bits by 1 */
+  /** Stores a 0 and increases the count of bits by 1. */
   protected void skipBit(ByteArrayOutputStream out) {
     bitsLeft--;
     flipByte(out);
   }
 
-  /** Stores a 1 and increases the count of bits by 1 */
+  /** Stores a 1 and increases the count of bits by 1. */
   protected void writeBit(ByteArrayOutputStream out) {
     buffer |= (1 << (bitsLeft - 1));
     bitsLeft--;
diff --git a/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/IntChimpEncoder.java b/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/IntChimpEncoder.java
index 1f792491b61..03c01415b65 100644
--- a/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/IntChimpEncoder.java
+++ b/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/IntChimpEncoder.java
@@ -41,28 +41,28 @@ public class IntChimpEncoder extends GorillaEncoderV2 {
   private static final int PREVIOUS_VALUES = 64;
   private static final int PREVIOUS_VALUES_LOG2 = (int) (Math.log(PREVIOUS_VALUES) / Math.log(2));
   private static final int THRESHOLD = 5 + PREVIOUS_VALUES_LOG2;
-  private static final int SET_LSB = (int) Math.pow(2, THRESHOLD + 1) - 1;
+  private static final int SET_LSB = (int) Math.pow(2, THRESHOLD + 1d) - 1;
   private static final int CASE_ZERO_METADATA_LENGTH = PREVIOUS_VALUES_LOG2 + 2;
   private static final int CASE_ONE_METADATA_LENGTH = PREVIOUS_VALUES_LOG2 + 10;
-  public static final short[] LEADING_REPRESENTATION = {
+  protected static final short[] LEADING_REPRESENTATION = {
     0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7,
     7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7
   };
 
-  public static final short[] LEADING_ROUND = {
+  protected static final short[] LEADING_ROUND = {
     0, 0, 0, 0, 0, 0, 0, 0, 8, 8, 8, 8, 12, 12, 12, 12, 16, 16, 18, 18, 20, 20, 22, 22, 24, 24, 24,
     24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
     24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24
   };
 
-  private int storedValues[];
+  private int[] storedValues;
   private int[] indices;
   private int index = 0;
   private int current = 0;
 
   public IntChimpEncoder() {
     this.setType(TSEncoding.CHIMP);
-    this.indices = new int[(int) Math.pow(2, THRESHOLD + 1)];
+    this.indices = new int[(int) Math.pow(2, THRESHOLD + 1d)];
     this.storedValues = new int[PREVIOUS_VALUES];
   }
 
@@ -84,7 +84,7 @@ public class IntChimpEncoder extends GorillaEncoderV2 {
     super.reset();
     this.current = 0;
     this.index = 0;
-    this.indices = new int[(int) Math.pow(2, THRESHOLD + 1)];
+    this.indices = new int[(int) Math.pow(2, THRESHOLD + 1d)];
     this.storedValues = new int[PREVIOUS_VALUES];
   }
 
@@ -155,8 +155,8 @@ public class IntChimpEncoder extends GorillaEncoderV2 {
       if (trailingZeros > THRESHOLD) {
         int significantBits = VALUE_BITS_LENGTH_32BIT - leadingZeros - trailingZeros;
         writeBits(
-            256 * (PREVIOUS_VALUES + previousIndex)
-                + 32 * LEADING_REPRESENTATION[leadingZeros]
+            256L * (PREVIOUS_VALUES + previousIndex)
+                + 32L * LEADING_REPRESENTATION[leadingZeros]
                 + significantBits,
             CASE_ONE_METADATA_LENGTH,
             out);
@@ -176,7 +176,7 @@ public class IntChimpEncoder extends GorillaEncoderV2 {
       } else {
         storedLeadingZeros = leadingZeros;
         int significantBits = VALUE_BITS_LENGTH_32BIT - leadingZeros;
-        writeBits(24 + LEADING_REPRESENTATION[leadingZeros], 5, out);
+        writeBits(24L + LEADING_REPRESENTATION[leadingZeros], 5, out);
         writeBits(xor, significantBits, out);
       }
     }
diff --git a/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/IntGorillaEncoder.java b/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/IntGorillaEncoder.java
index 2562d8e34b3..fdb4f790a58 100644
--- a/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/IntGorillaEncoder.java
+++ b/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/IntGorillaEncoder.java
@@ -108,7 +108,7 @@ public class IntGorillaEncoder extends GorillaEncoderV2 {
 
   /**
    * If there at least as many leading zeros and as many trailing zeros as previous value, control
-   * bit = 0 (type a)
+   * bit = 0 (type a).
    *
    * <p>store the meaningful XORed value
    *
@@ -122,7 +122,7 @@ public class IntGorillaEncoder extends GorillaEncoderV2 {
   }
 
   /**
-   * Stores the length of the number of leading zeros in the next 5 bits
+   * Stores the length of the number of leading zeros in the next 5 bits.
    *
    * <p>Stores the length of the meaningful XORed value in the next 5 bits
    *
diff --git a/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/IntRLBE.java b/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/IntRLBE.java
index 5bec5b4df82..43401f2bf88 100644
--- a/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/IntRLBE.java
+++ b/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/IntRLBE.java
@@ -23,22 +23,21 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.io.ByteArrayOutputStream;
-import java.io.IOException;
 
 public class IntRLBE extends RLBE {
-  /** delta values */
-  private int[] DiffValue = new int[blockSize + 1];
+  // delta values
+  private final int[] diffValue = new int[blockSize + 1];
 
-  /** repeat times on length code */
-  private int[] Lengrle = new int[blockSize + 1];
+  // repeat times on length code
+  private final int[] lengRLE = new int[blockSize + 1];
 
-  /** previous value of original value */
-  private int previousvalue;
+  // previous value of original value
+  private int previousValue;
 
-  /** logger */
+  // logger
   private static final Logger logger = LoggerFactory.getLogger(IntRLBE.class);
 
-  /** constructor of IntRLBE */
+  // constructor of IntRLBE
   public IntRLBE() {
     super();
     reset();
@@ -48,29 +47,33 @@ public class IntRLBE extends RLBE {
     writeIndex = -1;
     LengthCode = new int[blockSize + 1];
     for (int i = 0; i < blockSize; i++) {
-      DiffValue[i] = 0;
+      diffValue[i] = 0;
       LengthCode[i] = 0;
       byteBuffer = 0;
       numberLeftInBuffer = 0;
-      Lengrle[i] = 0;
+      lengRLE[i] = 0;
     }
   }
 
   /**
-   * calculate the binary code length of given integer
+   * calculate the binary code length of given integer.
    *
    * @param val the integer to calculate length
    * @return the length of val's binary code
    */
   private int calBinarylength(int val) {
-    if (val == 0) return 1;
+    if (val == 0) {
+      return 1;
+    }
     int i = 32;
-    while (((1 << (i - 1)) & val) == 0 && i > 0) i--;
+    while (((1 << (i - 1)) & val) == 0 && i > 0) {
+      i--;
+    }
     return i;
   }
 
   /**
-   * encode one input integer value
+   * encode one input integer value.
    *
    * @param value the integer to be encoded
    * @param out the output stream to flush in when buffer is full
@@ -78,16 +81,16 @@ public class IntRLBE extends RLBE {
   public void encodeValue(int value, ByteArrayOutputStream out) {
     if (writeIndex == -1) {
       // when the first value hasn't encoded yet
-      DiffValue[++writeIndex] = value;
+      diffValue[++writeIndex] = value;
       LengthCode[writeIndex] = calBinarylength(value);
-      previousvalue = value;
+      previousValue = value;
       return;
     }
     // calculate delta value
-    DiffValue[++writeIndex] = value - previousvalue;
+    diffValue[++writeIndex] = value - previousValue;
     // caldulate the length of delta value
-    LengthCode[writeIndex] = calBinarylength(DiffValue[writeIndex]);
-    previousvalue = value;
+    LengthCode[writeIndex] = calBinarylength(diffValue[writeIndex]);
+    previousValue = value;
     if (writeIndex == blockSize - 1) {
       // when encoded number reach to blocksize
       flush(out);
@@ -105,29 +108,31 @@ public class IntRLBE extends RLBE {
   }
 
   /**
-   * calculate fibonacci code of input integer
+   * calculate fibonacci code of input integer.
    *
    * @param val the integer to be fibonacci-encoded
    * @return the reverse fibonacci code of val in binary code
    */
   protected int calcFibonacci(int val) {
     // fibonacci values are stored in Fib
-    int[] Fib = new int[blockSize * 2 + 1];
-    Fib[0] = 1;
-    Fib[1] = 1;
+    int[] fib = new int[blockSize * 2 + 1];
+    fib[0] = 1;
+    fib[1] = 1;
     int i;
     // generate fibonacci values from 1 to the first one larger than val
-    for (i = 2; Fib[i - 1] <= val; i++) {
-      Fib[i] = Fib[i - 1] + Fib[i - 2];
+    for (i = 2; fib[i - 1] <= val; i++) {
+      fib[i] = fib[i - 1] + fib[i - 2];
     }
 
     i--;
     int valfib = 0;
     // calculate fibonacci code
     while (val > 0) {
-      while (Fib[i] > val && i >= 1) i--;
+      while (fib[i] > val && i >= 1) {
+        i--;
+      }
       valfib |= (1 << (i - 1));
-      val -= Fib[i];
+      val -= fib[i];
     }
     return valfib;
   }
@@ -143,13 +148,13 @@ public class IntRLBE extends RLBE {
         temprlecal++;
       }
       // store repeat time at the first repeating value's position
-      Lengrle[i] = temprlecal;
+      lengRLE[i] = temprlecal;
       i = j;
     }
   }
 
   /**
-   * flush all encoded values in a block to output stream
+   * flush all encoded values in a block to output stream.
    *
    * @param out the output stream to be flushed to
    */
@@ -162,36 +167,38 @@ public class IntRLBE extends RLBE {
     // calculate length code of delta binary length
     rleonlengthcode();
     for (int i = 0; i <= writeIndex; i++) {
-      if (Lengrle[i] > 0) // flush the adjacent same length delta values
-      try {
-          flushsegment(i, out);
-        } catch (IOException e) {
-          logger.error("flush data to stream failed!", e);
-        }
+      if (lengRLE[i] > 0) { // flush the adjacent same length delta values
+        flushSegment(i, out);
+      }
     }
     clearBuffer(out);
     reset();
   }
 
   /**
-   * flush the adjacent same-length delta values
+   * flush the adjacent same-length delta values.
    *
    * @param i the position of the first delta value
    * @param out output stream
-   * @throws IOException
    */
-  private void flushsegment(int i, ByteArrayOutputStream out) throws IOException {
+  private void flushSegment(int i, ByteArrayOutputStream out) {
     // write the first 6 bits: length code in binary words.
     for (int j = 5; j >= 0; j--) {
-      if ((LengthCode[i] & (1 << j)) > 0) writeBit(true, out);
-      else writeBit(false, out);
+      if ((LengthCode[i] & (1 << j)) > 0) {
+        writeBit(true, out);
+      } else {
+        writeBit(false, out);
+      }
     }
     // write the fibonacci code in normal direction
-    int fib = calcFibonacci(Lengrle[i]);
+    int fib = calcFibonacci(lengRLE[i]);
     int fiblen = calBinarylength(fib);
     for (int j = 0; j < fiblen; j++) {
-      if ((fib & (1 << j)) > 0) writeBit(true, out);
-      else writeBit(false, out);
+      if ((fib & (1 << j)) > 0) {
+        writeBit(true, out);
+      } else {
+        writeBit(false, out);
+      }
     }
     // write '1' to note the end of fibonacci code
     writeBit(true, out);
@@ -199,13 +206,16 @@ public class IntRLBE extends RLBE {
     // write Binary code words
     int j = i;
     do {
-      int tempDifflen = calBinarylength(DiffValue[j]);
+      int tempDifflen = calBinarylength(diffValue[j]);
       for (int k = tempDifflen - 1; k >= 0; k--) {
-        if ((DiffValue[j] & (1 << k)) > 0) writeBit(true, out);
-        else writeBit(false, out);
+        if ((diffValue[j] & (1 << k)) > 0) {
+          writeBit(true, out);
+        } else {
+          writeBit(false, out);
+        }
       }
       j++;
-    } while (Lengrle[j] == 0 && j <= writeIndex);
+    } while (lengRLE[j] == 0 && j <= writeIndex);
   }
 
   @Override
@@ -215,11 +225,11 @@ public class IntRLBE extends RLBE {
 
   @Override
   public long getMaxByteSize() {
-    return 5 * 4 * blockSize;
+    return 5L * 4 * blockSize;
   }
 
   /**
-   * write one bit to byteBuffer, when byteBuffer is full, flush byteBuffer to output stream
+   * write one bit to byteBuffer, when byteBuffer is full, flush byteBuffer to output stream.
    *
    * @param b the bit to be written
    * @param out output stream
@@ -237,27 +247,34 @@ public class IntRLBE extends RLBE {
   }
 
   /**
-   * flush bits left in byteBuffer to output stream
+   * flush bits left in byteBuffer to output stream.
    *
    * @param out output stream
    */
   protected void clearBuffer(ByteArrayOutputStream out) {
-    if (numberLeftInBuffer == 0) return;
-    if (numberLeftInBuffer > 0) byteBuffer <<= (8 - numberLeftInBuffer);
+    if (numberLeftInBuffer == 0) {
+      return;
+    }
+    if (numberLeftInBuffer > 0) {
+      byteBuffer <<= (8 - numberLeftInBuffer);
+    }
     out.write(byteBuffer);
     numberLeftInBuffer = 0;
     byteBuffer = 0;
   }
 
   /**
-   * write the number of encoded values to output stream
+   * write the number of encoded values to output stream.
    *
    * @param out output stream
    */
   private void writewriteIndex(ByteArrayOutputStream out) {
     for (int i = 31; i >= 0; i--) {
-      if ((writeIndex + 1 & (1 << i)) > 0) writeBit(true, out);
-      else writeBit(false, out);
+      if ((writeIndex + 1 & (1 << i)) > 0) {
+        writeBit(true, out);
+      } else {
+        writeBit(false, out);
+      }
     }
   }
 }
diff --git a/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/IntRleEncoder.java b/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/IntRleEncoder.java
index 44190dae337..c6873ccf91a 100644
--- a/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/IntRleEncoder.java
+++ b/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/IntRleEncoder.java
@@ -101,7 +101,7 @@ public class IntRleEncoder extends RleEncoder<Integer> {
 
     int[] tmpBuffer = new int[TSFileConfig.RLE_MIN_REPEATED_NUM];
     for (int i = 0; i < TSFileConfig.RLE_MIN_REPEATED_NUM; i++) {
-      tmpBuffer[i] = (int) bufferedValues[i];
+      tmpBuffer[i] = bufferedValues[i];
     }
     packer.pack8Values(tmpBuffer, 0, bytes);
     // we'll not write bit-packing group to OutputStream immediately
diff --git a/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/IntSprintzEncoder.java b/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/IntSprintzEncoder.java
index 82c665451b4..ad7797004b9 100644
--- a/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/IntSprintzEncoder.java
+++ b/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/IntSprintzEncoder.java
@@ -30,13 +30,13 @@ import java.util.Vector;
 
 public class IntSprintzEncoder extends SprintzEncoder {
 
-  /** bit packer */
+  // bit packer
   IntPacker packer;
 
-  /** Fire predictor * */
+  // Fire predictor
   IntFire firePred;
 
-  /** we save all value in a list and calculate its bitwidth. */
+  // we save all value in a list and calculate its bitwidth.
   protected Vector<Integer> values;
 
   public IntSprintzEncoder() {
@@ -63,28 +63,33 @@ public class IntSprintzEncoder extends SprintzEncoder {
 
   protected Integer predict(Integer value, Integer preVlaue) throws TsFileEncodingException {
     Integer pred;
-    if (PredictMethod.equals("delta")) {
+    if (predictMethod.equals("delta")) {
       pred = delta(value, preVlaue);
-    } else if (PredictMethod.equals("fire")) {
+    } else if (predictMethod.equals("fire")) {
       pred = fire(value, preVlaue);
     } else {
       throw new TsFileEncodingException(
           "Config: Predict Method {} of SprintzEncoder is not supported.");
     }
-    if (pred <= 0) pred = -2 * pred;
-    else pred = 2 * pred - 1; // TODO:overflow
+    if (pred <= 0) {
+      pred = -2 * pred;
+    } else {
+      pred = 2 * pred - 1; // TODO:overflow
+    }
     return pred;
   }
 
   @Override
   protected void bitPack() throws IOException {
-    int preValue = values.get(0);
+    final int preValue = values.get(0);
     values.remove(0);
     this.bitWidth = ReadWriteForEncodingUtils.getIntMaxBitWidth(values);
     packer = new IntPacker(this.bitWidth);
     byte[] bytes = new byte[bitWidth];
     int[] tmpBuffer = new int[Block_size];
-    for (int i = 0; i < Block_size; i++) tmpBuffer[i] = values.get(i);
+    for (int i = 0; i < Block_size; i++) {
+      tmpBuffer[i] = values.get(i);
+    }
     packer.pack8Values(tmpBuffer, 0, bytes);
     ReadWriteForEncodingUtils.writeIntLittleEndianPaddedOnBitWidth(bitWidth, byteCache, 1);
     ReadWriteForEncodingUtils.writeUnsignedVarInt(preValue, byteCache);
diff --git a/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/IntZigzagEncoder.java b/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/IntZigzagEncoder.java
index 27600cb3b8e..6e145dca144 100644
--- a/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/IntZigzagEncoder.java
+++ b/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/IntZigzagEncoder.java
@@ -36,7 +36,7 @@ import java.util.List;
  * https://gist.github.com/mfuerstenau/ba870a29e16536fdbaba
  */
 public class IntZigzagEncoder extends Encoder {
-  private static final Logger logger = LoggerFactory.getLogger(DictionaryEncoder.class);
+  private static final Logger logger = LoggerFactory.getLogger(IntZigzagEncoder.class);
   private List<Integer> values;
   byte[] buf = new byte[5];
 
@@ -46,7 +46,7 @@ public class IntZigzagEncoder extends Encoder {
     logger.debug("tsfile-encoding IntZigzagEncoder: int zigzag encoder");
   }
 
-  /** encoding and bit packing */
+  /** encoding and bit packing. */
   private byte[] encodeInt(int n) {
     n = (n << 1) ^ (n >> 31);
     int idx = 0;
@@ -70,7 +70,7 @@ public class IntZigzagEncoder extends Encoder {
   public void flush(ByteArrayOutputStream out) throws IOException {
     // byteCache stores all <encoded-data> and we know its size
     ByteArrayOutputStream byteCache = new ByteArrayOutputStream();
-    int len = values.size();
+    final int len = values.size();
     if (values.size() == 0) {
       return;
     }
diff --git a/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/LongChimpEncoder.java b/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/LongChimpEncoder.java
index 170d34d8b2d..f8bb1083b9f 100644
--- a/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/LongChimpEncoder.java
+++ b/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/LongChimpEncoder.java
@@ -41,28 +41,28 @@ public class LongChimpEncoder extends GorillaEncoderV2 {
   private static final int PREVIOUS_VALUES = 128;
   private static final int PREVIOUS_VALUES_LOG2 = (int) (Math.log(PREVIOUS_VALUES) / Math.log(2));
   private static final int THRESHOLD = 6 + PREVIOUS_VALUES_LOG2;
-  private static final int SET_LSB = (int) Math.pow(2, THRESHOLD + 1) - 1;
+  private static final int SET_LSB = (int) Math.pow(2, THRESHOLD + 1d) - 1;
   private static final int CASE_ZERO_METADATA_LENGTH = PREVIOUS_VALUES_LOG2 + 2;
   private static final int CASE_ONE_METADATA_LENGTH = PREVIOUS_VALUES_LOG2 + 11;
-  public static final short[] LEADING_REPRESENTATION = {
+  protected static final short[] LEADING_REPRESENTATION = {
     0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7,
     7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7
   };
 
-  public static final short[] LEADING_ROUND = {
+  protected static final short[] LEADING_ROUND = {
     0, 0, 0, 0, 0, 0, 0, 0, 8, 8, 8, 8, 12, 12, 12, 12, 16, 16, 18, 18, 20, 20, 22, 22, 24, 24, 24,
     24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
     24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24
   };
 
-  private long storedValues[];
+  private long[] storedValues;
   private int[] indices;
   private int index = 0;
   private int current = 0;
 
   public LongChimpEncoder() {
     this.setType(TSEncoding.CHIMP);
-    this.indices = new int[(int) Math.pow(2, THRESHOLD + 1)];
+    this.indices = new int[(int) Math.pow(2, THRESHOLD + 1d)];
     this.storedValues = new long[PREVIOUS_VALUES];
   }
 
@@ -74,12 +74,12 @@ public class LongChimpEncoder extends GorillaEncoderV2 {
               / Byte.SIZE
           + 1;
 
-  public static final short[] leadingRepresentation = {
+  protected static final short[] leadingRepresentation = {
     0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7,
     7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7
   };
 
-  public static final short[] leadingRound = {
+  protected static final short[] leadingRound = {
     0, 0, 0, 0, 0, 0, 0, 0, 8, 8, 8, 8, 12, 12, 12, 12, 16, 16, 18, 18, 20, 20, 22, 22, 24, 24, 24,
     24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
     24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24
@@ -95,7 +95,7 @@ public class LongChimpEncoder extends GorillaEncoderV2 {
     super.reset();
     this.current = 0;
     this.index = 0;
-    this.indices = new int[(int) Math.pow(2, THRESHOLD + 1)];
+    this.indices = new int[(int) Math.pow(2, THRESHOLD + 1d)];
     this.storedValues = new long[PREVIOUS_VALUES];
   }
 
@@ -166,8 +166,8 @@ public class LongChimpEncoder extends GorillaEncoderV2 {
       if (trailingZeros > THRESHOLD) {
         int significantBits = VALUE_BITS_LENGTH_64BIT - leadingZeros - trailingZeros;
         writeBits(
-            512 * (PREVIOUS_VALUES + previousIndex)
-                + 64 * leadingRepresentation[leadingZeros]
+            512L * (PREVIOUS_VALUES + previousIndex)
+                + 64L * leadingRepresentation[leadingZeros]
                 + significantBits,
             CASE_ONE_METADATA_LENGTH,
             out);
@@ -187,7 +187,7 @@ public class LongChimpEncoder extends GorillaEncoderV2 {
       } else {
         storedLeadingZeros = leadingZeros;
         int significantBits = VALUE_BITS_LENGTH_64BIT - leadingZeros;
-        writeBits(24 + leadingRepresentation[leadingZeros], 5, out);
+        writeBits(24L + leadingRepresentation[leadingZeros], 5, out);
         writeBits(xor, significantBits, out);
       }
     }
diff --git a/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/LongGorillaEncoder.java b/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/LongGorillaEncoder.java
index 5202e693b4f..0b39592e4b4 100644
--- a/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/LongGorillaEncoder.java
+++ b/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/LongGorillaEncoder.java
@@ -108,7 +108,7 @@ public class LongGorillaEncoder extends GorillaEncoderV2 {
 
   /**
    * If there at least as many leading zeros and as many trailing zeros as previous value, control
-   * bit = 0 (type a)
+   * bit = 0 (type a).
    *
    * <p>store the meaningful XORed value
    *
@@ -122,7 +122,7 @@ public class LongGorillaEncoder extends GorillaEncoderV2 {
   }
 
   /**
-   * Stores the length of the number of leading zeros in the next 6 bits
+   * Stores the length of the number of leading zeros in the next 6 bits.
    *
    * <p>Stores the length of the meaningful XORed value in the next 6 bits
    *
diff --git a/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/LongRLBE.java b/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/LongRLBE.java
index 5ec12b9a634..7e489e3cfd5 100644
--- a/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/LongRLBE.java
+++ b/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/LongRLBE.java
@@ -23,16 +23,16 @@ import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 
 public class LongRLBE extends RLBE {
-  /** delta values */
-  private long[] DiffValue = new long[blockSize + 1];
+  // delta values
+  private long[] diffValue = new long[blockSize + 1];
 
-  /** repeat times on length code */
-  private long[] Lengrle = new long[blockSize + 1];
+  // repeat times on length code
+  private long[] lengRLE = new long[blockSize + 1];
 
-  /** previous value of original value */
-  private long previousvalue;
+  // previous value of original value
+  private long previousValue;
 
-  /** constructor of LongRLBE */
+  // constructor of LongRLBE
   public LongRLBE() {
     super();
     reset();
@@ -42,29 +42,33 @@ public class LongRLBE extends RLBE {
     writeIndex = -1;
     LengthCode = new int[blockSize + 1];
     for (int i = 0; i < blockSize; i++) {
-      DiffValue[i] = 0;
+      diffValue[i] = 0;
       LengthCode[i] = 0;
       byteBuffer = 0;
       numberLeftInBuffer = 0;
-      Lengrle[i] = 0;
+      lengRLE[i] = 0;
     }
   }
 
   /**
-   * calculate the binary code length of given long integer
+   * calculate the binary code length of given long integer.
    *
    * @param val the long integer to calculate length
    * @return the length of val's binary code
    */
   private int calBinarylength(long val) {
-    if (val == 0) return 1;
+    if (val == 0) {
+      return 1;
+    }
     int i = 64;
-    while ((((long) 1 << (i - 1)) & val) == 0 && i > 0) i--;
+    while ((((long) 1 << (i - 1)) & val) == 0 && i > 0) {
+      i--;
+    }
     return i;
   }
 
   /**
-   * encode one input long integer value
+   * encode one input long integer value.
    *
    * @param value the long integer to be encoded
    * @param out the output stream to flush in when buffer is full
@@ -72,16 +76,16 @@ public class LongRLBE extends RLBE {
   public void encodeValue(long value, ByteArrayOutputStream out) {
     if (writeIndex == -1) {
       // when the first value hasn't encoded yet
-      DiffValue[++writeIndex] = value;
+      diffValue[++writeIndex] = value;
       LengthCode[writeIndex] = calBinarylength(value);
-      previousvalue = value;
+      previousValue = value;
       return;
     }
     // calculate delta value
-    DiffValue[++writeIndex] = value - previousvalue;
+    diffValue[++writeIndex] = value - previousValue;
     // caldulate the length of delta value
-    LengthCode[writeIndex] = calBinarylength(DiffValue[writeIndex]);
-    previousvalue = value;
+    LengthCode[writeIndex] = calBinarylength(diffValue[writeIndex]);
+    previousValue = value;
     if (writeIndex == blockSize - 1) {
       // when encoded number reach to blocksize
       flush(out);
@@ -99,35 +103,37 @@ public class LongRLBE extends RLBE {
   }
 
   /**
-   * calculate fibonacci code of input long integer
+   * calculate fibonacci code of input long integer.
    *
    * @param val the long integer to be fibonacci-encoded
    * @return the reverse fibonacci code of val in binary code
    */
   protected long calcFibonacci(long val) {
     // fibonacci values are stored in Fib
-    long[] Fib = new long[blockSize * 2 + 1];
-    Fib[0] = 1;
-    Fib[1] = 1;
+    long[] fib = new long[blockSize * 2 + 1];
+    fib[0] = 1;
+    fib[1] = 1;
     int i;
     // generate fibonacci values from 1 to the first one larger than val
-    for (i = 2; Fib[i - 1] <= val; i++) {
-      Fib[i] = Fib[i - 1] + Fib[i - 2];
+    for (i = 2; fib[i - 1] <= val; i++) {
+      fib[i] = fib[i - 1] + fib[i - 2];
     }
 
     i--;
     long valfib = 0;
     // calculate fibonacci code
     while (val > 0) {
-      while (Fib[i] > val && i >= 1) i--;
+      while (fib[i] > val && i >= 1) {
+        i--;
+      }
       valfib |= (1 << (i - 1));
-      val -= Fib[i];
+      val -= fib[i];
     }
     return valfib;
   }
 
   /** run length on DiffValue then store length at the first index in Lengrle. */
-  private void rleonlengthcode() {
+  private void rleOnLengthCode() {
     int i = 0;
     while (i <= writeIndex) {
       int j = i;
@@ -137,13 +143,13 @@ public class LongRLBE extends RLBE {
         temprlecal++;
       }
       // store repeat time at the first repeating value's position
-      Lengrle[i] = temprlecal;
+      lengRLE[i] = temprlecal;
       i = j;
     }
   }
 
   /**
-   * flush all encoded values in a block to output stream
+   * flush all encoded values in a block to output stream.
    *
    * @param out the output stream to be flushed to
    */
@@ -154,38 +160,41 @@ public class LongRLBE extends RLBE {
     // store the number of values
     writewriteIndex(out);
     // calculate length code of delta binary length
-    rleonlengthcode();
+    rleOnLengthCode();
     for (int i = 0; i <= writeIndex; i++) {
-      if (Lengrle[i] > 0) // flush the adjacent same length delta values
-      try {
-          flushsegment(i, out);
-        } catch (IOException e) {
-          logger.error("flush data to stream failed!", e);
-        }
+      if (lengRLE[i] > 0) {
+        flushsegment(i, out);
+      }
     }
     clearBuffer(out);
     reset();
   }
 
   /**
-   * flush the adjacent same-length delta values
+   * flush the adjacent same-length delta values.
    *
    * @param i the position of the first delta value
    * @param out output stream
    * @throws IOException
    */
-  private void flushsegment(int i, ByteArrayOutputStream out) throws IOException {
+  private void flushsegment(int i, ByteArrayOutputStream out) {
     // write the first 7 bits: length code in binary words.
     for (int j = 6; j >= 0; j--) {
-      if ((LengthCode[i] & (1 << j)) > 0) writeBit(true, out);
-      else writeBit(false, out);
+      if ((LengthCode[i] & (1 << j)) > 0) {
+        writeBit(true, out);
+      } else {
+        writeBit(false, out);
+      }
     }
     // write the fibonacci code in normal direction
-    long fib = calcFibonacci(Lengrle[i]);
+    long fib = calcFibonacci(lengRLE[i]);
     int fiblen = calBinarylength(fib);
     for (int j = 0; j < fiblen; j++) {
-      if ((fib & (1 << j)) > 0) writeBit(true, out);
-      else writeBit(false, out);
+      if ((fib & (1 << j)) > 0) {
+        writeBit(true, out);
+      } else {
+        writeBit(false, out);
+      }
     }
     // write '1' to note the end of fibonacci code
     writeBit(true, out);
@@ -193,13 +202,16 @@ public class LongRLBE extends RLBE {
     // write Binary code words
     int j = i;
     do {
-      int tempDifflen = calBinarylength(DiffValue[j]);
+      int tempDifflen = calBinarylength(diffValue[j]);
       for (int k = tempDifflen - 1; k >= 0; k--) {
-        if ((DiffValue[j] & ((long) 1 << k)) > 0) writeBit(true, out);
-        else writeBit(false, out);
+        if ((diffValue[j] & ((long) 1 << k)) > 0) {
+          writeBit(true, out);
+        } else {
+          writeBit(false, out);
+        }
       }
       j++;
-    } while (Lengrle[j] == 0 && j <= writeIndex);
+    } while (lengRLE[j] == 0 && j <= writeIndex);
   }
 
   @Override
@@ -209,11 +221,11 @@ public class LongRLBE extends RLBE {
 
   @Override
   public long getMaxByteSize() {
-    return 5 * 4 * blockSize * 2;
+    return 5L * 4 * blockSize * 2;
   }
 
   /**
-   * write one bit to byteBuffer, when byteBuffer is full, flush byteBuffer to output stream
+   * write one bit to byteBuffer, when byteBuffer is full, flush byteBuffer to output stream.
    *
    * @param b the bit to be written
    * @param out output stream
@@ -231,27 +243,34 @@ public class LongRLBE extends RLBE {
   }
 
   /**
-   * flush bits left in byteBuffer to output stream
+   * flush bits left in byteBuffer to output stream.
    *
    * @param out output stream
    */
   protected void clearBuffer(ByteArrayOutputStream out) {
-    if (numberLeftInBuffer == 0) return;
-    if (numberLeftInBuffer > 0) byteBuffer <<= (8 - numberLeftInBuffer);
+    if (numberLeftInBuffer == 0) {
+      return;
+    }
+    if (numberLeftInBuffer > 0) {
+      byteBuffer <<= (8 - numberLeftInBuffer);
+    }
     out.write(byteBuffer);
     numberLeftInBuffer = 0;
     byteBuffer = 0;
   }
 
   /**
-   * write the number of encoded values to output stream
+   * write the number of encoded values to output stream.
    *
    * @param out output stream
    */
   private void writewriteIndex(ByteArrayOutputStream out) {
     for (int i = 31; i >= 0; i--) {
-      if ((writeIndex + 1 & (1 << i)) > 0) writeBit(true, out);
-      else writeBit(false, out);
+      if ((writeIndex + 1 & (1 << i)) > 0) {
+        writeBit(true, out);
+      } else {
+        writeBit(false, out);
+      }
     }
   }
 }
diff --git a/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/LongRleEncoder.java b/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/LongRleEncoder.java
index 59473f2d54c..96365327953 100644
--- a/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/LongRleEncoder.java
+++ b/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/LongRleEncoder.java
@@ -95,7 +95,7 @@ public class LongRleEncoder extends RleEncoder<Long> {
     byte[] bytes = new byte[bitWidth];
     long[] tmpBuffer = new long[TSFileConfig.RLE_MIN_REPEATED_NUM];
     for (int i = 0; i < TSFileConfig.RLE_MIN_REPEATED_NUM; i++) {
-      tmpBuffer[i] = (long) bufferedValues[i];
+      tmpBuffer[i] = bufferedValues[i];
     }
     packer.pack8Values(tmpBuffer, 0, bytes);
     // we'll not write bit-packing group to OutputStream immediately
diff --git a/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/LongSprintzEncoder.java b/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/LongSprintzEncoder.java
index 5d565741df3..83a1218e57b 100644
--- a/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/LongSprintzEncoder.java
+++ b/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/LongSprintzEncoder.java
@@ -31,13 +31,13 @@ import java.util.Vector;
 
 public class LongSprintzEncoder extends SprintzEncoder {
 
-  /** bit packer */
+  // bit packer
   LongPacker packer;
 
-  /** Long Fire predictor * */
+  // Long Fire predictor
   LongFire firePred;
 
-  /** we save all value in a list and calculate its bitwidth. */
+  // we save all value in a list and calculate its bitwidth.
   protected Vector<Long> values;
 
   public LongSprintzEncoder() {
@@ -59,33 +59,38 @@ public class LongSprintzEncoder extends SprintzEncoder {
 
   @Override
   public long getMaxByteSize() {
-    return 1 + (1 + values.size()) * Long.BYTES;
+    return 1 + (1L + values.size()) * Long.BYTES;
   }
 
   protected Long predict(Long value, Long preVlaue) throws TsFileEncodingException {
     Long pred;
-    if (PredictMethod.equals("delta")) {
+    if (predictMethod.equals("delta")) {
       pred = delta(value, preVlaue);
-    } else if (PredictMethod.equals("fire")) {
+    } else if (predictMethod.equals("fire")) {
       pred = fire(value, preVlaue);
     } else {
       throw new TsFileEncodingException(
           "Config: Predict Method {} of SprintzEncoder is not supported.");
     }
-    if (pred <= 0) pred = -2 * pred;
-    else pred = 2 * pred - 1; // TODO:overflow
+    if (pred <= 0) {
+      pred = -2 * pred;
+    } else {
+      pred = 2 * pred - 1; // TODO:overflow
+    }
     return pred;
   }
 
   @Override
   protected void bitPack() throws IOException {
-    long preValue = values.get(0);
+    final long preValue = values.get(0);
     values.remove(0);
     this.bitWidth = ReadWriteForEncodingUtils.getLongMaxBitWidth(values);
     packer = new LongPacker(this.bitWidth);
     byte[] bytes = new byte[bitWidth];
     long[] tmpBuffer = new long[Block_size];
-    for (int i = 0; i < Block_size; i++) tmpBuffer[i] = values.get(i);
+    for (int i = 0; i < Block_size; i++) {
+      tmpBuffer[i] = values.get(i);
+    }
     packer.pack8Values(tmpBuffer, 0, bytes);
     ReadWriteForEncodingUtils.writeIntLittleEndianPaddedOnBitWidth(bitWidth, byteCache, 1);
     byteCache.write(ByteBuffer.allocate(8).putLong(preValue).array());
diff --git a/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/LongZigzagEncoder.java b/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/LongZigzagEncoder.java
index aa8e3c44f7a..f611815fa1b 100644
--- a/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/LongZigzagEncoder.java
+++ b/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/LongZigzagEncoder.java
@@ -36,7 +36,7 @@ import java.util.List;
  * https://gist.github.com/mfuerstenau/ba870a29e16536fdbaba
  */
 public class LongZigzagEncoder extends Encoder {
-  private static final Logger logger = LoggerFactory.getLogger(DictionaryEncoder.class);
+  private static final Logger logger = LoggerFactory.getLogger(LongZigzagEncoder.class);
   private List<Long> values;
   byte[] buf = new byte[10];
 
@@ -46,7 +46,7 @@ public class LongZigzagEncoder extends Encoder {
     logger.debug("tsfile-encoding LongZigzagEncoder: long zigzag encoder");
   }
 
-  /** encoding and bit packing */
+  /** encoding and bit packing. */
   private byte[] encodeLong(long n) {
     n = (n << 1) ^ (n >> 63);
     int idx = 0;
@@ -72,6 +72,7 @@ public class LongZigzagEncoder extends Encoder {
     return sb.toString();
   }
 
+  @Override
   public void encode(long value, ByteArrayOutputStream out) {
     values.add(value);
   }
@@ -80,7 +81,7 @@ public class LongZigzagEncoder extends Encoder {
   public void flush(ByteArrayOutputStream out) throws IOException {
     // byteCache stores all <encoded-data> and we know its size
     ByteArrayOutputStream byteCache = new ByteArrayOutputStream();
-    int len = values.size();
+    final int len = values.size();
     if (values.size() == 0) {
       return;
     }
diff --git a/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/PlainEncoder.java b/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/PlainEncoder.java
index 1a2271836b0..32491089bd2 100644
--- a/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/PlainEncoder.java
+++ b/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/PlainEncoder.java
@@ -99,6 +99,12 @@ public class PlainEncoder extends Encoder {
     }
   }
 
+  @Override
+  public void encode(BigDecimal value, ByteArrayOutputStream out) {
+    throw new TsFileEncodingException(
+        "tsfile-encoding PlainEncoder: current version does not support BigDecimal value encoding");
+  }
+
   @Override
   public void flush(ByteArrayOutputStream out) {
     // This is an empty function.
@@ -129,10 +135,4 @@ public class PlainEncoder extends Encoder {
   public long getMaxByteSize() {
     return 0;
   }
-
-  @Override
-  public void encode(BigDecimal value, ByteArrayOutputStream out) {
-    throw new TsFileEncodingException(
-        "tsfile-encoding PlainEncoder: current version does not support BigDecimal value encoding");
-  }
 }
diff --git a/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/RLBE.java b/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/RLBE.java
index 072c7e86d19..d428b4f4c31 100644
--- a/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/RLBE.java
+++ b/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/RLBE.java
@@ -27,30 +27,30 @@ import org.slf4j.LoggerFactory;
 import java.io.ByteArrayOutputStream;
 
 public class RLBE extends Encoder {
-  /** Every BLOCK_DEFAULT_SIZE values are followed by a header */
+  // Every BLOCK_DEFAULT_SIZE values are followed by a header
   protected static final int BLOCK_DEFAULT_SIZE = 10000;
 
   protected static final Logger logger = LoggerFactory.getLogger(RLBE.class);
 
-  /** output stream to buffer {@code <length> <fibonacci code> <delta value>} */
+  // output stream to buffer {@code <length> <fibonacci code> <delta value>}
   protected ByteArrayOutputStream out;
 
   protected int blockSize = BLOCK_DEFAULT_SIZE;
 
-  /** Storage bits into byteBuffer and flush when full */
+  // Storage bits into byteBuffer and flush when full
   protected byte byteBuffer;
-  /** Valid bits left in byteBuffer */
+  // Valid bits left in byteBuffer
   protected int numberLeftInBuffer;
 
-  /** Differential Value of InputData is stored in DiffValue */
+  // Differential Value of InputData is stored in DiffValue
 
-  /** Length of binary code of delta values are stored in LengthCode */
+  // Length of binary code of delta values are stored in LengthCode
   protected int[] LengthCode;
 
-  /** When writeIndex == -1, the first value is not stored */
+  // When writeIndex == -1, the first value is not stored
   protected int writeIndex = -1;
 
-  /** Constructor of RLBE */
+  // Constructor of RLBE
   public RLBE() {
     super(TSEncoding.RLBE);
     // blockSize = size;
diff --git a/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/RegularDataEncoder.java b/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/RegularDataEncoder.java
index 74222636e94..9a2badb6cce 100644
--- a/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/RegularDataEncoder.java
+++ b/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/RegularDataEncoder.java
@@ -58,7 +58,7 @@ public abstract class RegularDataEncoder extends Encoder {
    *
    * @param size - the number how many numbers to be packed into a block.
    */
-  public RegularDataEncoder(int size) {
+  protected RegularDataEncoder(int size) {
     super(TSEncoding.REGULAR);
     blockSize = size;
   }
@@ -226,7 +226,7 @@ public abstract class RegularDataEncoder extends Encoder {
       for (int i = 1; i < dataTotal; i++) {
         int delta = missingPointData[i] - missingPointData[i - 1];
         if (delta != minDeltaBase) {
-          int missingPointNum = (int) (delta / minDeltaBase) - 1;
+          int missingPointNum = (delta / minDeltaBase) - 1;
           for (int j = 0; j < missingPointNum; j++) {
             bitmap.set(i + (offset++), false);
           }
diff --git a/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/RleEncoder.java b/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/RleEncoder.java
index 2b40e880b46..2afb70a4e44 100644
--- a/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/RleEncoder.java
+++ b/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/RleEncoder.java
@@ -55,8 +55,6 @@ import java.util.List;
  * repeated-value := value that is repeated, using a fixed-width of round-up-to-next-byte(bit-width)
  * }</pre>
  *
- * .
- *
  * @param <T> data type T for RLE
  */
 public abstract class RleEncoder<T extends Comparable<T>> extends Encoder {
diff --git a/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/SDTEncoder.java b/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/SDTEncoder.java
index f3f4b9ff627..ff8cfb00f07 100644
--- a/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/SDTEncoder.java
+++ b/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/SDTEncoder.java
@@ -21,10 +21,8 @@ package org.apache.iotdb.tsfile.encoding.encoder;
 
 public class SDTEncoder {
 
-  /**
-   * the last read time and value if upperDoor >= lowerDoor meaning out of compDeviation range, will
-   * store lastReadPair
-   */
+  // the last read time and value if upperDoor >= lowerDoor meaning out of compDeviation range, will
+  // store lastReadPair
   private long lastReadTimestamp;
 
   private long lastReadLong;
@@ -32,7 +30,7 @@ public class SDTEncoder {
   private int lastReadInt;
   private float lastReadFloat;
 
-  /** the last stored time and vlaue we compare current point against lastStoredPair */
+  // the last stored time and vlaue we compare current point against lastStoredPair
   private long lastStoredTimestamp;
 
   private long lastStoredLong;
@@ -40,43 +38,31 @@ public class SDTEncoder {
   private int lastStoredInt;
   private float lastStoredFloat;
 
-  /**
-   * the maximum curUpperSlope between the lastStoredPoint to the current point upperDoor can only
-   * open up
-   */
+  // the maximum curUpperSlope between the lastStoredPoint to the current point upperDoor can only
+  // open up
   private double upperDoor;
 
-  /**
-   * the minimum curLowerSlope between the lastStoredPoint to the current point lowerDoor can only
-   * open downard
-   */
+  // the minimum curLowerSlope between the lastStoredPoint to the current point lowerDoor can only
+  // open downard
   private double lowerDoor;
 
-  /**
-   * the maximum absolute difference the user set if the data's value is within compDeviation, it
-   * will be compressed and discarded after compression, it will only store out of range <time,
-   * data></> to form the trend
-   */
+  // the maximum absolute difference the user set if the data's value is within compDeviation, it
+  // will be compressed and discarded after compression, it will only store out of range <time,
+  // data> to form the trend
   private double compDeviation;
 
-  /**
-   * the minimum time distance between two stored data points if current point time to the last
-   * stored point time distance <= compMinTime, current point will NOT be stored regardless of
-   * compression deviation
-   */
+  // the minimum time distance between two stored data points if current point time to the last
+  // stored point time distance <= compMinTime, current point will NOT be stored regardless of
+  // compression deviation
   private long compMinTime;
 
-  /**
-   * the maximum time distance between two stored data points if current point time to the last
-   * stored point time distance >= compMaxTime, current point will be stored regardless of
-   * compression deviation
-   */
+  // the maximum time distance between two stored data points if current point time to the last
+  // stored point time distance >= compMaxTime, current point will be stored regardless of
+  // compression deviation
   private long compMaxTime;
 
-  /**
-   * isFirstValue is true when the encoder takes the first point or reset() when cur point's
-   * distance to the last stored point's distance exceeds compMaxTime
-   */
+  // isFirstValue is true when the encoder takes the first point or reset() when cur point's
+  // distance to the last stored point's distance exceeds compMaxTime
   private boolean isFirstValue;
 
   public SDTEncoder() {
@@ -101,7 +87,7 @@ public class SDTEncoder {
     }
 
     // if current point to the last stored point's time distance is larger than compMaxTime,
-    // will reset two doors, and store current point;
+    // will reset two doors, and store current point
     if (time - lastStoredTimestamp >= compMaxTime) {
       reset(time, value);
       return true;
@@ -147,7 +133,7 @@ public class SDTEncoder {
     }
 
     // if current point to the last stored point's time distance is larger than compMaxTime,
-    // will reset two doors, and store current point;
+    // will reset two doors, and store current point
     if (time - lastStoredTimestamp >= compMaxTime) {
       reset(time, value);
       return true;
@@ -193,7 +179,7 @@ public class SDTEncoder {
     }
 
     // if current point to the last stored point's time distance is larger than compMaxTime,
-    // will reset two doors, and store current point;
+    // will reset two doors, and store current point
     if (time - lastStoredTimestamp >= compMaxTime) {
       reset(time, value);
       return true;
diff --git a/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/SprintzEncoder.java b/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/SprintzEncoder.java
index d4032c4d11d..32a7aa2caa5 100644
--- a/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/SprintzEncoder.java
+++ b/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/SprintzEncoder.java
@@ -32,30 +32,30 @@ import java.io.IOException;
 public abstract class SprintzEncoder extends Encoder {
   protected static final Logger logger = LoggerFactory.getLogger(SprintzEncoder.class);
 
-  /** Segment block size to compress:8 */
+  // Segment block size to compress:8
   protected int Block_size = 8;
 
-  /** group size maximum * */
+  // group size maximum
   protected int groupMax = 16;
 
-  /** group number * */
+  // group number
   protected int groupNum;
 
-  /** the bit width used for bit-packing and rle. */
+  // the bit width used for bit-packing and rle.
   protected int bitWidth;
 
   /** output stream to buffer {@code <bitwidth> <encoded-data>}. */
   protected ByteArrayOutputStream byteCache;
 
-  /** selecet the predict method */
-  protected String PredictMethod =
-      TSFileDescriptor.getInstance().getConfig().getSprintzPredictScheme();;
+  // selecet the predict method
+  protected String predictMethod =
+      TSFileDescriptor.getInstance().getConfig().getSprintzPredictScheme();
 
   protected boolean isFirstCached = false;
 
   protected TSFileConfig config = TSFileDescriptor.getInstance().getConfig();
 
-  public SprintzEncoder() {
+  protected SprintzEncoder() {
     super(TSEncoding.SPRINTZ);
     byteCache = new ByteArrayOutputStream();
   }
diff --git a/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/TSEncodingBuilder.java b/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/TSEncodingBuilder.java
index 91513335c6c..453aadfed2d 100644
--- a/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/TSEncodingBuilder.java
+++ b/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/TSEncodingBuilder.java
@@ -16,6 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+
 package org.apache.iotdb.tsfile.encoding.encoder;
 
 import org.apache.iotdb.tsfile.common.conf.TSFileConfig;
@@ -43,7 +44,7 @@ public abstract class TSEncodingBuilder {
   private static final Logger logger = LoggerFactory.getLogger(TSEncodingBuilder.class);
   protected final TSFileConfig conf;
 
-  public TSEncodingBuilder() {
+  protected TSEncodingBuilder() {
     this.conf = TSFileDescriptor.getInstance().getConfig();
   }
 
@@ -260,7 +261,7 @@ public abstract class TSEncodingBuilder {
     }
   }
 
-  /** for INT32, INT64 */
+  /** for INT32, INT64. */
   public static class Regular extends TSEncodingBuilder {
 
     @Override