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 a1adaf2  [Sonar] Fix Codesmell blocker and critical issue (#1750)
a1adaf2 is described below

commit a1adaf2f900a87b065a2b14e8acaf50e00542819
Author: Mingzhe Liu <[email protected]>
AuthorDate: Wed Oct 14 10:42:45 2020 +0800

    [Sonar] Fix Codesmell blocker and critical issue (#1750)
---
 .../iotdb/hadoop/tsfile/TSFMRReadExample.java      |   1 -
 .../iotdb/hadoop/tsfile/TSMRWriteExample.java      |   6 +-
 .../java/org/apache/iotdb/rocketmq/Constant.java   |  17 ++--
 .../main/java/org/apache/iotdb/SessionExample.java |  58 ++++++------
 .../apache/iotdb/tsfile/TsFileWriteWithTablet.java |   6 +-
 .../apache/iotdb/hadoop/fileSystem/HDFSFile.java   |  59 ++++++------
 .../org/apache/iotdb/hive/TsFileDeserializer.java  |  17 ++--
 .../org/apache/iotdb/jdbc/IoTDBConnection.java     |  18 ++--
 .../org/apache/iotdb/jdbc/IoTDBDataSource.java     |  12 +--
 .../java/org/apache/iotdb/jdbc/IoTDBStatement.java |  14 +--
 .../apache/iotdb/jdbc/IoTDBJDBCResultSetTest.java  |  28 +++---
 .../apache/iotdb/jdbc/IoTDBResultMetadataTest.java |   4 +-
 .../iotdb/db/auth/user/BasicUserManager.java       |   4 +-
 .../iotdb/db/cost/statistic/Measurement.java       |  29 +++---
 .../db/engine/fileSystem/SystemFileFactory.java    |  10 +--
 .../engine/storagegroup/StorageGroupProcessor.java |   7 +-
 .../level/LevelTsFileManagement.java               |   2 -
 .../org/apache/iotdb/db/metadata/MLogWriter.java   |  13 ++-
 .../org/apache/iotdb/db/metadata/MManager.java     |  46 +++++-----
 .../java/org/apache/iotdb/db/metadata/MTree.java   |  13 ++-
 .../apache/iotdb/db/metrics/source/JvmSource.java  |  12 +--
 .../iotdb/db/metrics/source/MetricsSource.java     |  24 ++---
 .../iotdb/db/qp/strategy/LogicalGenerator.java     |  13 +--
 .../iotdb/db/query/control/TracingManager.java     |  32 +++----
 .../org/apache/iotdb/db/service/TSServiceImpl.java |  31 ++++---
 .../apache/iotdb/db/integration/IoTDBLastIT.java   |  10 +--
 .../iotdb/db/integration/IoTDBTracingTest.java     |   6 +-
 .../iotdb/db/qp/plan/LogicalPlanSmallTest.java     |   2 +-
 .../apache/iotdb/db/qp/plan/PhysicalPlanTest.java  |   4 +-
 .../iotdb/db/writelog/recover/LogReplayerTest.java |   2 +-
 .../org/apache/iotdb/session/SessionDataSet.java   |   6 +-
 .../scala/org/apache/iotdb/spark/db/IoTDBRDD.scala |   4 +-
 .../iotdb/tsfile/compress/IUnCompressor.java       |   9 +-
 .../iotdb/tsfile/encoding/decoder/Decoder.java     |  13 +--
 .../file/metadata/statistics/BinaryStatistics.java |  22 ++---
 .../apache/iotdb/tsfile/read/common/BatchData.java |  14 +--
 .../iotdb/tsfile/utils/ReadWriteIOUtils.java       |  14 +--
 .../apache/iotdb/tsfile/write/record/Tablet.java   |   7 +-
 .../apache/iotdb/tsfile/utils/RecordUtilsTest.java | 100 ++++++++++-----------
 39 files changed, 355 insertions(+), 334 deletions(-)

diff --git 
a/example/hadoop/src/main/java/org/apache/iotdb/hadoop/tsfile/TSFMRReadExample.java
 
b/example/hadoop/src/main/java/org/apache/iotdb/hadoop/tsfile/TSFMRReadExample.java
index 82ef438..6e3874e 100644
--- 
a/example/hadoop/src/main/java/org/apache/iotdb/hadoop/tsfile/TSFMRReadExample.java
+++ 
b/example/hadoop/src/main/java/org/apache/iotdb/hadoop/tsfile/TSFMRReadExample.java
@@ -43,7 +43,6 @@ public class TSFMRReadExample {
       System.out.println("Please give hdfs url, input path, output path");
       return;
     }
-    String HDFSURL = args[0];
     Path inputPath = new Path(args[1]);
     Path outputPath = new Path(args[2]);
 
diff --git 
a/example/hadoop/src/main/java/org/apache/iotdb/hadoop/tsfile/TSMRWriteExample.java
 
b/example/hadoop/src/main/java/org/apache/iotdb/hadoop/tsfile/TSMRWriteExample.java
index b2d8f17..bd74bcf 100644
--- 
a/example/hadoop/src/main/java/org/apache/iotdb/hadoop/tsfile/TSMRWriteExample.java
+++ 
b/example/hadoop/src/main/java/org/apache/iotdb/hadoop/tsfile/TSMRWriteExample.java
@@ -39,8 +39,7 @@ import 
org.apache.iotdb.tsfile.write.record.datapoint.DoubleDataPoint;
 import org.apache.iotdb.tsfile.write.record.datapoint.LongDataPoint;
 import org.apache.iotdb.tsfile.write.schema.MeasurementSchema;
 import org.apache.iotdb.tsfile.write.schema.Schema;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+
 
 /**
  * One example for writing TsFile with MapReduce.
@@ -77,7 +76,6 @@ public class TSMRWriteExample {
     }
     TSFOutputFormat.setSchema(schema);
 
-    String HDFSURL = args[0];
     Path inputPath = new Path(args[1]);
     Path outputPath = new Path(args[2]);
 
@@ -139,8 +137,6 @@ public class TSMRWriteExample {
 
   public static class TSMapper extends Mapper<NullWritable, MapWritable, Text, 
MapWritable> {
 
-    private static final Logger logger = 
LoggerFactory.getLogger(TSMapper.class);
-
     @Override
     protected void map(NullWritable key, MapWritable value,
         Mapper<NullWritable, MapWritable, Text, MapWritable>.Context context)
diff --git 
a/example/rocketmq/src/main/java/org/apache/iotdb/rocketmq/Constant.java 
b/example/rocketmq/src/main/java/org/apache/iotdb/rocketmq/Constant.java
index 5c465e9..4358831 100644
--- a/example/rocketmq/src/main/java/org/apache/iotdb/rocketmq/Constant.java
+++ b/example/rocketmq/src/main/java/org/apache/iotdb/rocketmq/Constant.java
@@ -31,14 +31,17 @@ public class Constant {
   public static final String IOTDB_CONNECTION_PASSWORD = "root";
   public static final String[] STORAGE_GROUP = {"root.vehicle", "root.test"};
   public static final String ADDITIONAL_STORAGE_GROUP = "root.addition";
+  public static final String INT32 = "INT32";
+  public static final String PLAIN = "PLAIN";
+  public static final String SNAPPY = "SNAPPY";
   public static final String[][] CREATE_TIMESERIES = {
-      {"root.vehicle.d0.s0", "INT32", "PLAIN", "SNAPPY"},
-      {"root.vehicle.d0.s1", "TEXT", "PLAIN", "SNAPPY"},
-      {"root.vehicle.d1.s2", "FLOAT", "PLAIN", "SNAPPY"},
-      {"root.vehicle.d1.s3", "BOOLEAN", "PLAIN", "SNAPPY"},
-      {"root.test.d0.s0", "INT32", "PLAIN", "SNAPPY"},
-      {"root.test.d0.s1", "TEXT", "PLAIN", "SNAPPY"},
-      {"root.test.d1.s0", "INT32", "PLAIN", "SNAPPY"},
+      {"root.vehicle.d0.s0", INT32, PLAIN, SNAPPY},
+      {"root.vehicle.d0.s1", "TEXT", PLAIN, SNAPPY},
+      {"root.vehicle.d1.s2", "FLOAT", PLAIN, SNAPPY},
+      {"root.vehicle.d1.s3", "BOOLEAN", PLAIN, SNAPPY},
+      {"root.test.d0.s0", INT32, PLAIN, SNAPPY},
+      {"root.test.d0.s1", "TEXT", PLAIN, SNAPPY},
+      {"root.test.d1.s0", INT32, PLAIN, SNAPPY},
   };
   public static final String[] ALL_DATA = {
       "root.vehicle.d0,10,s0,INT32,100",
diff --git a/example/session/src/main/java/org/apache/iotdb/SessionExample.java 
b/example/session/src/main/java/org/apache/iotdb/SessionExample.java
index 0534683..dc68fe2 100644
--- a/example/session/src/main/java/org/apache/iotdb/SessionExample.java
+++ b/example/session/src/main/java/org/apache/iotdb/SessionExample.java
@@ -39,6 +39,12 @@ import 
org.apache.iotdb.tsfile.write.schema.MeasurementSchema;
 public class SessionExample {
 
   private static Session session;
+  private static final String ROOT_SG1_D1_S1 = "root.sg1.d1.s1";
+  private static final String ROOT_SG1_D1_S2 = "root.sg1.d1.s2";
+  private static final String ROOT_SG1_D1_S3 = "root.sg1.d1.s3";
+  private static final String ROOT_SG1_D1_S4 = "root.sg1.d1.s4";
+  private static final String ROOT_SG1_D1 = "root.sg1.d1";
+
 
   public static void main(String[] args)
       throws IoTDBConnectionException, StatementExecutionException {
@@ -70,26 +76,26 @@ public class SessionExample {
   private static void createTimeseries()
       throws IoTDBConnectionException, StatementExecutionException {
 
-    if (!session.checkTimeseriesExists("root.sg1.d1.s1")) {
-      session.createTimeseries("root.sg1.d1.s1", TSDataType.INT64, 
TSEncoding.RLE,
+    if (!session.checkTimeseriesExists(ROOT_SG1_D1_S1)) {
+      session.createTimeseries(ROOT_SG1_D1_S1, TSDataType.INT64, 
TSEncoding.RLE,
           CompressionType.SNAPPY);
     }
-    if (!session.checkTimeseriesExists("root.sg1.d1.s2")) {
-      session.createTimeseries("root.sg1.d1.s2", TSDataType.INT64, 
TSEncoding.RLE,
+    if (!session.checkTimeseriesExists(ROOT_SG1_D1_S2)) {
+      session.createTimeseries(ROOT_SG1_D1_S2, TSDataType.INT64, 
TSEncoding.RLE,
           CompressionType.SNAPPY);
     }
-    if (!session.checkTimeseriesExists("root.sg1.d1.s3")) {
-      session.createTimeseries("root.sg1.d1.s3", TSDataType.INT64, 
TSEncoding.RLE,
+    if (!session.checkTimeseriesExists(ROOT_SG1_D1_S3)) {
+      session.createTimeseries(ROOT_SG1_D1_S3, TSDataType.INT64, 
TSEncoding.RLE,
           CompressionType.SNAPPY);
     }
 
     // create timeseries with tags and attributes
-    if (!session.checkTimeseriesExists("root.sg1.d1.s4")) {
+    if (!session.checkTimeseriesExists(ROOT_SG1_D1_S4)) {
       Map<String, String> tags = new HashMap<>();
       tags.put("tag1", "v1");
       Map<String, String> attributes = new HashMap<>();
       tags.put("description", "v1");
-      session.createTimeseries("root.sg1.d1.s4", TSDataType.INT64, 
TSEncoding.RLE,
+      session.createTimeseries(ROOT_SG1_D1_S4, TSDataType.INT64, 
TSEncoding.RLE,
           CompressionType.SNAPPY, null, tags, attributes, "temperature");
     }
   }
@@ -136,7 +142,7 @@ public class SessionExample {
   }
 
   private static void insertRecord() throws IoTDBConnectionException, 
StatementExecutionException {
-    String deviceId = "root.sg1.d1";
+    String deviceId = ROOT_SG1_D1;
     List<String> measurements = new ArrayList<>();
     List<TSDataType> types = new ArrayList<>();
     measurements.add("s1");
@@ -156,7 +162,7 @@ public class SessionExample {
   }
 
   private static void insertStrRecord() throws IoTDBConnectionException, 
StatementExecutionException {
-    String deviceId = "root.sg1.d1";
+    String deviceId = ROOT_SG1_D1;
     List<String> measurements = new ArrayList<>();
     measurements.add("s1");
     measurements.add("s2");
@@ -173,7 +179,7 @@ public class SessionExample {
 
   private static void insertRecordInObject()
       throws IoTDBConnectionException, StatementExecutionException {
-    String deviceId = "root.sg1.d1";
+    String deviceId = ROOT_SG1_D1;
     List<String> measurements = new ArrayList<>();
     List<TSDataType> types = new ArrayList<>();
     measurements.add("s1");
@@ -189,7 +195,7 @@ public class SessionExample {
   }
 
   private static void insertRecords() throws IoTDBConnectionException, 
StatementExecutionException {
-    String deviceId = "root.sg1.d1";
+    String deviceId = ROOT_SG1_D1;
     List<String> measurements = new ArrayList<>();
     measurements.add("s1");
     measurements.add("s2");
@@ -247,7 +253,7 @@ public class SessionExample {
     schemaList.add(new MeasurementSchema("s2", TSDataType.INT64));
     schemaList.add(new MeasurementSchema("s3", TSDataType.INT64));
 
-    Tablet tablet = new Tablet("root.sg1.d1", schemaList, 100);
+    Tablet tablet = new Tablet(ROOT_SG1_D1, schemaList, 100);
 
     //Method 1 to add tablet data
     long timestamp = System.currentTimeMillis();
@@ -302,12 +308,12 @@ public class SessionExample {
     schemaList.add(new MeasurementSchema("s2", TSDataType.INT64));
     schemaList.add(new MeasurementSchema("s3", TSDataType.INT64));
 
-    Tablet tablet1 = new Tablet("root.sg1.d1", schemaList, 100);
+    Tablet tablet1 = new Tablet(ROOT_SG1_D1, schemaList, 100);
     Tablet tablet2 = new Tablet("root.sg1.d2", schemaList, 100);
     Tablet tablet3 = new Tablet("root.sg1.d3", schemaList, 100);
 
     Map<String, Tablet> tabletMap = new HashMap<>();
-    tabletMap.put("root.sg1.d1", tablet1);
+    tabletMap.put(ROOT_SG1_D1, tablet1);
     tabletMap.put("root.sg1.d2", tablet2);
     tabletMap.put("root.sg1.d3", tablet3);
 
@@ -383,7 +389,7 @@ public class SessionExample {
   }
 
   private static void deleteData() throws IoTDBConnectionException, 
StatementExecutionException {
-    String path = "root.sg1.d1.s1";
+    String path = ROOT_SG1_D1_S1;
     long deleteTime = 99;
     session.deleteData(path, deleteTime);
   }
@@ -391,9 +397,9 @@ public class SessionExample {
   private static void deleteTimeseries()
       throws IoTDBConnectionException, StatementExecutionException {
     List<String> paths = new ArrayList<>();
-    paths.add("root.sg1.d1.s1");
-    paths.add("root.sg1.d1.s2");
-    paths.add("root.sg1.d1.s3");
+    paths.add(ROOT_SG1_D1_S1);
+    paths.add(ROOT_SG1_D1_S2);
+    paths.add(ROOT_SG1_D1_S3);
     session.deleteTimeseries(paths);
   }
 
@@ -411,9 +417,9 @@ public class SessionExample {
 
   private static void rawDataQuery() throws IoTDBConnectionException, 
StatementExecutionException {
     List<String> paths = new ArrayList<>();
-    paths.add("root.sg1.d1.s1");
-    paths.add("root.sg1.d1.s2");
-    paths.add("root.sg1.d1.s3");
+    paths.add(ROOT_SG1_D1_S1);
+    paths.add(ROOT_SG1_D1_S2);
+    paths.add(ROOT_SG1_D1_S3);
     long startTime = 10L;
     long endTime = 200L;
 
@@ -446,8 +452,8 @@ public class SessionExample {
       }
 
       // get third column
-      if (!iterator.isNull("root.sg1.d1.s2")) {
-        builder.append(iterator.getLong("root.sg1.d1.s2")).append(",");
+      if (!iterator.isNull(ROOT_SG1_D1_S2)) {
+        builder.append(iterator.getLong(ROOT_SG1_D1_S2)).append(",");
       } else {
         builder.append("null").append(",");
       }
@@ -460,8 +466,8 @@ public class SessionExample {
       }
 
       // get fifth column
-      if (!iterator.isNull("root.sg1.d1.s4")) {
-        builder.append(iterator.getObject("root.sg1.d1.s4"));
+      if (!iterator.isNull(ROOT_SG1_D1_S4)) {
+        builder.append(iterator.getObject(ROOT_SG1_D1_S4));
       } else {
         builder.append("null");
       }
diff --git 
a/example/tsfile/src/main/java/org/apache/iotdb/tsfile/TsFileWriteWithTablet.java
 
b/example/tsfile/src/main/java/org/apache/iotdb/tsfile/TsFileWriteWithTablet.java
index a013acc..9c0bc31 100644
--- 
a/example/tsfile/src/main/java/org/apache/iotdb/tsfile/TsFileWriteWithTablet.java
+++ 
b/example/tsfile/src/main/java/org/apache/iotdb/tsfile/TsFileWriteWithTablet.java
@@ -46,10 +46,8 @@ public class TsFileWriteWithTablet {
     try {
       String path = "test.tsfile";
       File f = FSFactoryProducer.getFSFactory().getFile(path);
-      if (f.exists()) {
-        if (!f.delete()) {
-          throw new RuntimeException("can not delete " + f.getAbsolutePath());
-        }
+      if (f.exists() && !f.delete()) {
+        throw new RuntimeException("can not delete " + f.getAbsolutePath());
       }
 
       Schema schema = new Schema();
diff --git 
a/hadoop/src/main/java/org/apache/iotdb/hadoop/fileSystem/HDFSFile.java 
b/hadoop/src/main/java/org/apache/iotdb/hadoop/fileSystem/HDFSFile.java
index 68a0d50..c6f8d7b 100644
--- a/hadoop/src/main/java/org/apache/iotdb/hadoop/fileSystem/HDFSFile.java
+++ b/hadoop/src/main/java/org/apache/iotdb/hadoop/fileSystem/HDFSFile.java
@@ -48,6 +48,7 @@ public class HDFSFile extends File {
   private Path hdfsPath;
   private FileSystem fs;
   private static final Logger logger = LoggerFactory.getLogger(HDFSFile.class);
+  private static final String UNSUPPORT_OPERATION = "Unsupported operation.";
 
 
   public HDFSFile(String pathname) {
@@ -290,146 +291,146 @@ public class HDFSFile extends File {
 
   @Override
   public String getParent() {
-    throw new UnsupportedOperationException("Unsupported operation.");
+    throw new UnsupportedOperationException(UNSUPPORT_OPERATION);
   }
 
   @Override
   public boolean isAbsolute() {
-    throw new UnsupportedOperationException("Unsupported operation.");
+    throw new UnsupportedOperationException(UNSUPPORT_OPERATION);
   }
 
   @Override
   public File[] listFiles(FileFilter filter) {
-    throw new UnsupportedOperationException("Unsupported operation.");
+    throw new UnsupportedOperationException(UNSUPPORT_OPERATION);
   }
 
   @Override
   public String getCanonicalPath() throws IOException {
-    throw new UnsupportedOperationException("Unsupported operation.");
+    throw new UnsupportedOperationException(UNSUPPORT_OPERATION);
   }
 
   @Override
   public File getCanonicalFile() throws IOException {
-    throw new UnsupportedOperationException("Unsupported operation.");
+    throw new UnsupportedOperationException(UNSUPPORT_OPERATION);
   }
 
   @Override
   public URL toURL() throws MalformedURLException {
-    throw new UnsupportedOperationException("Unsupported operation.");
+    throw new UnsupportedOperationException(UNSUPPORT_OPERATION);
   }
 
   @Override
   public URI toURI() {
-    throw new UnsupportedOperationException("Unsupported operation.");
+    throw new UnsupportedOperationException(UNSUPPORT_OPERATION);
   }
 
   @Override
   public boolean canRead() {
-    throw new UnsupportedOperationException("Unsupported operation.");
+    throw new UnsupportedOperationException(UNSUPPORT_OPERATION);
   }
 
   @Override
   public boolean canWrite() {
-    throw new UnsupportedOperationException("Unsupported operation.");
+    throw new UnsupportedOperationException(UNSUPPORT_OPERATION);
   }
 
   @Override
   public boolean isFile() {
-    throw new UnsupportedOperationException("Unsupported operation.");
+    throw new UnsupportedOperationException(UNSUPPORT_OPERATION);
   }
 
   @Override
   public boolean isHidden() {
-    throw new UnsupportedOperationException("Unsupported operation.");
+    throw new UnsupportedOperationException(UNSUPPORT_OPERATION);
   }
 
   @Override
   public long lastModified() {
-    throw new UnsupportedOperationException("Unsupported operation.");
+    throw new UnsupportedOperationException(UNSUPPORT_OPERATION);
   }
 
   @Override
   public void deleteOnExit() {
-    throw new UnsupportedOperationException("Unsupported operation.");
+    throw new UnsupportedOperationException(UNSUPPORT_OPERATION);
   }
 
   @Override
   public String[] list() {
-    throw new UnsupportedOperationException("Unsupported operation.");
+    throw new UnsupportedOperationException(UNSUPPORT_OPERATION);
   }
 
   @Override
   public String[] list(FilenameFilter filter) {
-    throw new UnsupportedOperationException("Unsupported operation.");
+    throw new UnsupportedOperationException(UNSUPPORT_OPERATION);
   }
 
   @Override
   public File[] listFiles(FilenameFilter filter) {
-    throw new UnsupportedOperationException("Unsupported operation.");
+    throw new UnsupportedOperationException(UNSUPPORT_OPERATION);
   }
 
   @Override
   public boolean mkdir() {
-    throw new UnsupportedOperationException("Unsupported operation.");
+    throw new UnsupportedOperationException(UNSUPPORT_OPERATION);
   }
 
   @Override
   public boolean setLastModified(long time) {
-    throw new UnsupportedOperationException("Unsupported operation.");
+    throw new UnsupportedOperationException(UNSUPPORT_OPERATION);
   }
 
   @Override
   public boolean setReadOnly() {
-    throw new UnsupportedOperationException("Unsupported operation.");
+    throw new UnsupportedOperationException(UNSUPPORT_OPERATION);
   }
 
   @Override
   public boolean setWritable(boolean writable, boolean ownerOnly) {
-    throw new UnsupportedOperationException("Unsupported operation.");
+    throw new UnsupportedOperationException(UNSUPPORT_OPERATION);
   }
 
   @Override
   public boolean setWritable(boolean writable) {
-    throw new UnsupportedOperationException("Unsupported operation.");
+    throw new UnsupportedOperationException(UNSUPPORT_OPERATION);
   }
 
   @Override
   public boolean setReadable(boolean readable, boolean ownerOnly) {
-    throw new UnsupportedOperationException("Unsupported operation.");
+    throw new UnsupportedOperationException(UNSUPPORT_OPERATION);
   }
 
   @Override
   public boolean setReadable(boolean readable) {
-    throw new UnsupportedOperationException("Unsupported operation.");
+    throw new UnsupportedOperationException(UNSUPPORT_OPERATION);
   }
 
   @Override
   public boolean setExecutable(boolean executable, boolean ownerOnly) {
-    throw new UnsupportedOperationException("Unsupported operation.");
+    throw new UnsupportedOperationException(UNSUPPORT_OPERATION);
   }
 
   @Override
   public boolean setExecutable(boolean executable) {
-    throw new UnsupportedOperationException("Unsupported operation.");
+    throw new UnsupportedOperationException(UNSUPPORT_OPERATION);
   }
 
   @Override
   public boolean canExecute() {
-    throw new UnsupportedOperationException("Unsupported operation.");
+    throw new UnsupportedOperationException(UNSUPPORT_OPERATION);
   }
 
   @Override
   public long getTotalSpace() {
-    throw new UnsupportedOperationException("Unsupported operation.");
+    throw new UnsupportedOperationException(UNSUPPORT_OPERATION);
   }
 
   @Override
   public long getUsableSpace() {
-    throw new UnsupportedOperationException("Unsupported operation.");
+    throw new UnsupportedOperationException(UNSUPPORT_OPERATION);
   }
 
   @Override
   public java.nio.file.Path toPath() {
-    throw new UnsupportedOperationException("Unsupported operation.");
+    throw new UnsupportedOperationException(UNSUPPORT_OPERATION);
   }
 }
diff --git 
a/hive-connector/src/main/java/org/apache/iotdb/hive/TsFileDeserializer.java 
b/hive-connector/src/main/java/org/apache/iotdb/hive/TsFileDeserializer.java
index 50ceb51..5625ac6 100644
--- a/hive-connector/src/main/java/org/apache/iotdb/hive/TsFileDeserializer.java
+++ b/hive-connector/src/main/java/org/apache/iotdb/hive/TsFileDeserializer.java
@@ -34,7 +34,7 @@ import java.util.Objects;
 
 public class TsFileDeserializer {
   private static final Logger LOG = 
LoggerFactory.getLogger(TsFileDeserializer.class);
-
+  private static final String ERROR_MSG = "Unexpected data type: %s for Date 
TypeInfo: %s";
   private List<Object> row;
 
   /**
@@ -90,15 +90,16 @@ public class TsFileDeserializer {
             row.add(((BooleanWritable)data).get());
           }
           else {
-            throw new TsFileSerDeException("Unexpected data type: " + 
data.getClass().getName() + " for Date TypeInfo: " + type);
+            throw new TsFileSerDeException(String.format(ERROR_MSG, 
data.getClass().getName(), type));
           }
+          
           break;
         case INT:
           if (data instanceof IntWritable) {
             row.add(((IntWritable)data).get());
           }
           else {
-            throw new TsFileSerDeException("Unexpected data type: " + 
data.getClass().getName() + " for Date TypeInfo: " + type);
+            throw new TsFileSerDeException(String.format(ERROR_MSG, 
data.getClass().getName(), type));
           }
           break;
         case LONG:
@@ -106,7 +107,7 @@ public class TsFileDeserializer {
             row.add(((LongWritable)data).get());
           }
           else {
-            throw new TsFileSerDeException("Unexpected data type: " + 
data.getClass().getName() + " for Date TypeInfo: " + type);
+            throw new TsFileSerDeException(String.format(ERROR_MSG, 
data.getClass().getName(), type));
           }
           break;
         case FLOAT:
@@ -114,7 +115,7 @@ public class TsFileDeserializer {
             row.add(((FloatWritable)data).get());
           }
           else {
-            throw new TsFileSerDeException("Unexpected data type: " + 
data.getClass().getName() + " for Date TypeInfo: " + type);
+            throw new TsFileSerDeException(String.format(ERROR_MSG, 
data.getClass().getName(), type));
           }
           break;
         case DOUBLE:
@@ -122,7 +123,7 @@ public class TsFileDeserializer {
             row.add(((DoubleWritable)data).get());
           }
           else {
-            throw new TsFileSerDeException("Unexpected data type: " + 
data.getClass().getName() + " for Date TypeInfo: " + type);
+            throw new TsFileSerDeException(String.format(ERROR_MSG, 
data.getClass().getName(), type));
           }
           break;
         case STRING:
@@ -130,7 +131,7 @@ public class TsFileDeserializer {
             row.add(data.toString());
           }
           else {
-            throw new TsFileSerDeException("Unexpected data type: " + 
data.getClass().getName() + " for Date TypeInfo: " + type);
+            throw new TsFileSerDeException(String.format(ERROR_MSG, 
data.getClass().getName(), type));
           }
           break;
         case TIMESTAMP:
@@ -138,7 +139,7 @@ public class TsFileDeserializer {
             row.add(new Timestamp(((LongWritable)data).get()));
           }
           else {
-            throw new TsFileSerDeException("Unexpected data type: " + 
data.getClass().getName() + " for Date TypeInfo: " + type);
+            throw new TsFileSerDeException(String.format(ERROR_MSG, 
data.getClass().getName(), type));
           }
           break;
         default:
diff --git a/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBConnection.java 
b/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBConnection.java
index b053512..e36fd80 100644
--- a/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBConnection.java
+++ b/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBConnection.java
@@ -56,6 +56,8 @@ public class IoTDBConnection implements Connection {
 
   private static final Logger logger = 
LoggerFactory.getLogger(IoTDBConnection.class);
   private static final TSProtocolVersion protocolVersion = 
TSProtocolVersion.IOTDB_SERVICE_PROTOCOL_V3;
+  private static final String NOT_SUPPORT_PREPARE_CALL = "Not support 
prepareCall";
+  private static final String NOT_SUPPORT_PREPARE_STATEMENT = "Not support 
prepareStatement";
   private TSIService.Iface client = null;
   private long sessionId = -1;
   private IoTDBConnectionParams params;
@@ -311,18 +313,18 @@ public class IoTDBConnection implements Connection {
 
   @Override
   public CallableStatement prepareCall(String arg0) throws SQLException {
-    throw new SQLException("Not support prepareCall");
+    throw new SQLException(NOT_SUPPORT_PREPARE_CALL);
   }
 
   @Override
   public CallableStatement prepareCall(String arg0, int arg1, int arg2) throws 
SQLException {
-    throw new SQLException("Not support prepareCall");
+    throw new SQLException(NOT_SUPPORT_PREPARE_CALL);
   }
 
   @Override
   public CallableStatement prepareCall(String arg0, int arg1, int arg2, int 
arg3)
       throws SQLException {
-    throw new SQLException("Not support prepareCall");
+    throw new SQLException(NOT_SUPPORT_PREPARE_CALL);
   }
 
   @Override
@@ -332,29 +334,29 @@ public class IoTDBConnection implements Connection {
 
   @Override
   public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) 
throws SQLException {
-    throw new SQLException("Not support prepareStatement");
+    throw new SQLException(NOT_SUPPORT_PREPARE_STATEMENT);
   }
 
   @Override
   public PreparedStatement prepareStatement(String sql, int[] columnIndexes) 
throws SQLException {
-    throw new SQLException("Not support prepareStatement");
+    throw new SQLException(NOT_SUPPORT_PREPARE_STATEMENT);
   }
 
   @Override
   public PreparedStatement prepareStatement(String sql, String[] columnNames) 
throws SQLException {
-    throw new SQLException("Not support prepareStatement");
+    throw new SQLException(NOT_SUPPORT_PREPARE_STATEMENT);
   }
 
   @Override
   public PreparedStatement prepareStatement(String sql, int resultSetType, int 
resultSetConcurrency)
       throws SQLException {
-    throw new SQLException("Not support prepareStatement");
+    throw new SQLException(NOT_SUPPORT_PREPARE_STATEMENT);
   }
 
   @Override
   public PreparedStatement prepareStatement(String sql, int resultSetType, int 
resultSetConcurrency,
       int resultSetHoldability) throws SQLException {
-    throw new SQLException("Not support prepareStatement");
+    throw new SQLException(NOT_SUPPORT_PREPARE_STATEMENT);
   }
 
   @Override
diff --git a/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBDataSource.java 
b/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBDataSource.java
index 9630ae2..9378e05 100644
--- a/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBDataSource.java
+++ b/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBDataSource.java
@@ -23,16 +23,16 @@ import java.sql.SQLException;
 import java.sql.SQLFeatureNotSupportedException;
 import java.util.Properties;
 import org.apache.thrift.transport.TTransportException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
+
+  
 public class IoTDBDataSource implements DataSource {
 
-  private final Logger logger = LoggerFactory.getLogger(IoTDBDataSource.class);
 
   private String url;
   private String user;
   private String password;
+  private static final String PWD_STR = "password";
   private Properties properties;
   private Integer port = 6667;
 
@@ -44,7 +44,7 @@ public class IoTDBDataSource implements DataSource {
     this.url = url;
     this.properties = new Properties();
     properties.setProperty("user", user);
-    properties.setProperty("password", password);
+    properties.setProperty(PWD_STR, password);
     if (port != 0) {
       this.port = port;
     }
@@ -65,7 +65,7 @@ public class IoTDBDataSource implements DataSource {
 
   public void setPassword(String password) {
     this.password = password;
-    properties.setProperty("password", password);
+    properties.setProperty(PWD_STR, password);
   }
 
   public Integer getPort() {
@@ -99,7 +99,7 @@ public class IoTDBDataSource implements DataSource {
     try {
       Properties newProp = new Properties();
       newProp.setProperty("user", username);
-      newProp.setProperty("password", password);
+      newProp.setProperty(PWD_STR, password);
       return new IoTDBConnection(url, newProp);
     } catch (Exception e) {
       e.printStackTrace();
diff --git a/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBStatement.java 
b/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBStatement.java
index 1b21c5c..60f9021 100644
--- a/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBStatement.java
+++ b/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBStatement.java
@@ -44,6 +44,8 @@ public class IoTDBStatement implements Statement {
   private int queryTimeout = 10;
   protected TSIService.Iface client;
   private List<String> batchSQLList;
+  private static final String NOT_SUPPORT_EXECUTE = "Not support execute";
+  private static final String NOT_SUPPORT_EXECUTE_UPDATE = "Not support 
executeUpdate";
   /**
    * Keep state so we can fail certain calls made after close().
    */
@@ -191,17 +193,17 @@ public class IoTDBStatement implements Statement {
 
   @Override
   public boolean execute(String arg0, int arg1) throws SQLException {
-    throw new SQLException("Not support execute");
+    throw new SQLException(NOT_SUPPORT_EXECUTE);
   }
 
   @Override
   public boolean execute(String arg0, int[] arg1) throws SQLException {
-    throw new SQLException("Not support execute");
+    throw new SQLException(NOT_SUPPORT_EXECUTE);
   }
 
   @Override
   public boolean execute(String arg0, String[] arg1) throws SQLException {
-    throw new SQLException("Not support execute");
+    throw new SQLException(NOT_SUPPORT_EXECUTE);
   }
 
   /**
@@ -355,17 +357,17 @@ public class IoTDBStatement implements Statement {
 
   @Override
   public int executeUpdate(String arg0, int arg1) throws SQLException {
-    throw new SQLException("Not support executeUpdate");
+    throw new SQLException(NOT_SUPPORT_EXECUTE_UPDATE);
   }
 
   @Override
   public int executeUpdate(String arg0, int[] arg1) throws SQLException {
-    throw new SQLException("Not support executeUpdate");
+    throw new SQLException(NOT_SUPPORT_EXECUTE_UPDATE);
   }
 
   @Override
   public int executeUpdate(String arg0, String[] arg1) throws SQLException {
-    throw new SQLException("Not support executeUpdate");
+    throw new SQLException(NOT_SUPPORT_EXECUTE_UPDATE);
   }
 
   private int executeUpdateSQL(String sql) throws TException, 
IoTDBSQLException {
diff --git 
a/jdbc/src/test/java/org/apache/iotdb/jdbc/IoTDBJDBCResultSetTest.java 
b/jdbc/src/test/java/org/apache/iotdb/jdbc/IoTDBJDBCResultSetTest.java
index 8b59f5a..1555678 100644
--- a/jdbc/src/test/java/org/apache/iotdb/jdbc/IoTDBJDBCResultSetTest.java
+++ b/jdbc/src/test/java/org/apache/iotdb/jdbc/IoTDBJDBCResultSetTest.java
@@ -189,24 +189,24 @@ public class IoTDBJDBCResultSetTest {
 
     try (ResultSet resultSet = statement.getResultSet()) {
       // check columnInfoMap
-      Assert.assertEquals(resultSet.findColumn("Time"), 1);
-      Assert.assertEquals(resultSet.findColumn("root.vehicle.d0.s2"), 2);
-      Assert.assertEquals(resultSet.findColumn("root.vehicle.d0.s1"), 3);
-      Assert.assertEquals(resultSet.findColumn("root.vehicle.d0.s0"), 4);
+      Assert.assertEquals(1, resultSet.findColumn("Time"));
+      Assert.assertEquals(2, resultSet.findColumn("root.vehicle.d0.s2"));
+      Assert.assertEquals(3, resultSet.findColumn("root.vehicle.d0.s1"));
+      Assert.assertEquals(4, resultSet.findColumn("root.vehicle.d0.s0"));
 
       ResultSetMetaData resultSetMetaData = resultSet.getMetaData();
       // check columnInfoList
-      Assert.assertEquals(resultSetMetaData.getColumnName(1), "Time");
-      Assert.assertEquals(resultSetMetaData.getColumnName(2), 
"root.vehicle.d0.s2");
-      Assert.assertEquals(resultSetMetaData.getColumnName(3), 
"root.vehicle.d0.s1");
-      Assert.assertEquals(resultSetMetaData.getColumnName(4), 
"root.vehicle.d0.s0");
-      Assert.assertEquals(resultSetMetaData.getColumnName(5), 
"root.vehicle.d0.s2");
+      Assert.assertEquals("Time", resultSetMetaData.getColumnName(1));
+      Assert.assertEquals("root.vehicle.d0.s2", 
resultSetMetaData.getColumnName(2));
+      Assert.assertEquals("root.vehicle.d0.s1", 
resultSetMetaData.getColumnName(3));
+      Assert.assertEquals("root.vehicle.d0.s0", 
resultSetMetaData.getColumnName(4));
+      Assert.assertEquals("root.vehicle.d0.s2", 
resultSetMetaData.getColumnName(5));
       // check columnTypeList
-      Assert.assertEquals(resultSetMetaData.getColumnType(1), Types.TIMESTAMP);
-      Assert.assertEquals(resultSetMetaData.getColumnType(2), Types.FLOAT);
-      Assert.assertEquals(resultSetMetaData.getColumnType(3), Types.BIGINT);
-      Assert.assertEquals(resultSetMetaData.getColumnType(4), Types.INTEGER);
-      Assert.assertEquals(resultSetMetaData.getColumnType(5), Types.FLOAT);
+      Assert.assertEquals(Types.TIMESTAMP, resultSetMetaData.getColumnType(1));
+      Assert.assertEquals(Types.FLOAT, resultSetMetaData.getColumnType(2));
+      Assert.assertEquals(Types.BIGINT, resultSetMetaData.getColumnType(3));
+      Assert.assertEquals(Types.INTEGER, resultSetMetaData.getColumnType(4));
+      Assert.assertEquals(Types.FLOAT, resultSetMetaData.getColumnType(5));
       // check fetched result
       int colCount = resultSetMetaData.getColumnCount();
       StringBuilder resultStr = new StringBuilder();
diff --git 
a/jdbc/src/test/java/org/apache/iotdb/jdbc/IoTDBResultMetadataTest.java 
b/jdbc/src/test/java/org/apache/iotdb/jdbc/IoTDBResultMetadataTest.java
index 0664f8e..b30e3e9 100644
--- a/jdbc/src/test/java/org/apache/iotdb/jdbc/IoTDBResultMetadataTest.java
+++ b/jdbc/src/test/java/org/apache/iotdb/jdbc/IoTDBResultMetadataTest.java
@@ -67,7 +67,7 @@ public class IoTDBResultMetadataTest {
     List<String> columnInfoList = new ArrayList<>();
     columnInfoList.add("root.a.b.c");
     metadata = new IoTDBResultMetadata(columnInfoList, null, false);
-    assertEquals(metadata.getColumnCount(), 1);
+    assertEquals(1, metadata.getColumnCount());
   }
 
   @Test
@@ -159,7 +159,7 @@ public class IoTDBResultMetadataTest {
     }
     assertTrue(flag);
 
-    assertEquals(metadata.getColumnType(1), Types.TIMESTAMP);
+    assertEquals(Types.TIMESTAMP, metadata.getColumnType(1));
     for (int i = 1; i <= types.length; i++) {
       assertEquals(metadata.getColumnType(i + 1), types[i - 1]);
     }
diff --git 
a/server/src/main/java/org/apache/iotdb/db/auth/user/BasicUserManager.java 
b/server/src/main/java/org/apache/iotdb/db/auth/user/BasicUserManager.java
index 299e9e4..a27c88f 100644
--- a/server/src/main/java/org/apache/iotdb/db/auth/user/BasicUserManager.java
+++ b/server/src/main/java/org/apache/iotdb/db/auth/user/BasicUserManager.java
@@ -288,7 +288,7 @@ public abstract class BasicUserManager implements 
IUserManager {
   public boolean isUserUseWaterMark(String username) throws AuthException {
     User user = getUser(username);
     if (user == null) {
-      throw new AuthException(String.format("No such user %s", username));
+      throw new AuthException(String.format(NO_SUCH_USER_ERROR, username));
     }
     return user.isUseWaterMark();
   }
@@ -297,7 +297,7 @@ public abstract class BasicUserManager implements 
IUserManager {
   public void setUserUseWaterMark(String username, boolean useWaterMark) 
throws AuthException {
     User user = getUser(username);
     if (user == null) {
-      throw new AuthException(String.format("No such user %s", username));
+      throw new AuthException(String.format(NO_SUCH_USER_ERROR, username));
     }
     boolean oldFlag = user.isUseWaterMark();
     if (oldFlag == useWaterMark) {
diff --git 
a/server/src/main/java/org/apache/iotdb/db/cost/statistic/Measurement.java 
b/server/src/main/java/org/apache/iotdb/db/cost/statistic/Measurement.java
index 716a509..a166c03 100644
--- a/server/src/main/java/org/apache/iotdb/db/cost/statistic/Measurement.java
+++ b/server/src/main/java/org/apache/iotdb/db/cost/statistic/Measurement.java
@@ -112,7 +112,6 @@ public class Measurement implements MeasurementMBean, 
IService {
   private long displayIntervalInMs;
   private Map<String, Boolean> operationSwitch;
 
-  private static final Logger LOGGER = 
LoggerFactory.getLogger(Measurement.class);
   private final String mbeanName = String
       .format("%s:%s=%s", "org.apache.iotdb.db.cost.statistic", 
IoTDBConstant.JMX_TYPE,
           getID().getJmxName());
@@ -164,7 +163,7 @@ public class Measurement implements MeasurementMBean, 
IService {
             new Measurement.DisplayRunnable(), 20, displayIntervalInMs, 
TimeUnit.MILLISECONDS);
       }
     } catch (Exception e) {
-      LOGGER.error("Find error when start performance statistic thread, 
because {}", e);
+      logger.error("Find error when start performance statistic thread, ", e);
     } finally {
       stateChangeLock.unlock();
     }
@@ -182,7 +181,7 @@ public class Measurement implements MeasurementMBean, 
IService {
             new Measurement.DisplayRunnable(), 20, displayIntervalInMs, 
TimeUnit.MILLISECONDS);
       }
     } catch (Exception e) {
-      LOGGER.error("Find error when start performance statistic thread, 
because {}", e);
+      logger.error("Find error when start performance statistic thread, ", e);
     } finally {
       stateChangeLock.unlock();
     }
@@ -200,7 +199,7 @@ public class Measurement implements MeasurementMBean, 
IService {
     try {
       displayFuture = cancelFuture(displayFuture);
     } catch (Exception e) {
-      LOGGER.error("Find error when stop display thread, because {}", e);
+      logger.error("Find error when stop display thread, ", e);
     } finally {
       stateChangeLock.unlock();
     }
@@ -214,7 +213,7 @@ public class Measurement implements MeasurementMBean, 
IService {
       displayFuture = cancelFuture(displayFuture);
       consumeFuture = cancelFuture(consumeFuture);
     } catch (Exception e) {
-      LOGGER.error("Find error when stop display and consuming threads, 
because {}", e);
+      logger.error("Find error when stop display and consuming threads, ", e);
     } finally {
       stateChangeLock.unlock();
     }
@@ -282,7 +281,7 @@ public class Measurement implements MeasurementMBean, 
IService {
       displayFuture = cancelFuture(displayFuture);
       service.awaitTermination(5, TimeUnit.SECONDS);
     } catch (InterruptedException e) {
-      LOGGER.error("Performance statistic service could not be shutdown, {}", 
e.getMessage());
+      logger.error("Performance statistic service could not be shutdown, {}", 
e.getMessage());
       // Restore interrupted state...
       Thread.currentThread().interrupt();
     }
@@ -335,12 +334,12 @@ public class Measurement implements MeasurementMBean, 
IService {
 
   private void showMeasurements() {
     Date date = new Date();
-    LOGGER.info(
+    logger.info(
         "====================================={} Measurement 
(ms)======================================",
         date);
     String head = String
         .format("%-45s%-25s%-25s%-25s", "OPERATION", "COUNT", "TOTAL_TIME", 
"AVG_TIME");
-    LOGGER.info(head);
+    logger.info(head);
     for (Operation operation : Operation.values()) {
       if (!operationSwitch.get(operation.getName())) {
         continue;
@@ -350,16 +349,16 @@ public class Measurement implements MeasurementMBean, 
IService {
       String avg = String.format("%.4f", (totalInMs / (cnt + 1e-9)));
       String item = String
           .format("%-45s%-25s%-25s%-25s", operation.name, cnt + "", totalInMs 
+ "", avg);
-      LOGGER.info(item);
+      logger.info(item);
     }
-    LOGGER.info(
+    logger.info(
         "==========================================OPERATION 
HISTOGRAM====================================================");
     StringBuilder histogramHead = new StringBuilder(String.format("%-45s", 
"OPERATION"));
     for (int i = 0; i < BUCKET_SIZE; i++) {
       histogramHead.append(String.format("%-8s", BUCKET_IN_MS[i] + "ms"));
     }
-    if (LOGGER.isInfoEnabled()) {
-      LOGGER.info(histogramHead.toString());
+    if (logger.isInfoEnabled()) {
+      logger.info(histogramHead.toString());
     }
     for (Operation operation : Operation.values()) {
       if (!operationSwitch.get(operation.getName())) {
@@ -372,12 +371,12 @@ public class Measurement implements MeasurementMBean, 
IService {
             .format("%.2f", (operationHistogram[operation.ordinal()][i] / (cnt 
+ 1e-9) * 100));
         item.append(String.format("%-8s", avg + "%"));
       }
-      if (LOGGER.isInfoEnabled()) {
-        LOGGER.info(item.toString());
+      if (logger.isInfoEnabled()) {
+        logger.info(item.toString());
       }
     }
 
-    LOGGER.info(
+    logger.info(
         
"=================================================================================================================");
   }
 
diff --git 
a/server/src/main/java/org/apache/iotdb/db/engine/fileSystem/SystemFileFactory.java
 
b/server/src/main/java/org/apache/iotdb/db/engine/fileSystem/SystemFileFactory.java
index 030f811..800a471 100644
--- 
a/server/src/main/java/org/apache/iotdb/db/engine/fileSystem/SystemFileFactory.java
+++ 
b/server/src/main/java/org/apache/iotdb/db/engine/fileSystem/SystemFileFactory.java
@@ -30,10 +30,10 @@ public enum SystemFileFactory {
   INSTANCE;
 
   private static FSType fsType = 
IoTDBDescriptor.getInstance().getConfig().getSystemFileStorageFs();
-
+  private static final String UNSUPPORT_FILE_SYSTEM = "Unsupported file 
system: ";
   public File getFile(String pathname) {
     if (fsType.equals(FSType.HDFS)) {
-      throw new UnsupportedOperationException("Unsupported file system: " + 
fsType.name());
+      throw new UnsupportedOperationException(UNSUPPORT_FILE_SYSTEM + 
fsType.name());
       // return new HDFSFile(pathname);
     } else {
       return new File(pathname);
@@ -42,7 +42,7 @@ public enum SystemFileFactory {
 
   public File getFile(String parent, String child) {
     if (fsType.equals(FSType.HDFS)) {
-      throw new UnsupportedOperationException("Unsupported file system: " + 
fsType.name());
+      throw new UnsupportedOperationException(UNSUPPORT_FILE_SYSTEM + 
fsType.name());
       // return new HDFSFile(parent, child);
     } else {
       return new File(parent, child);
@@ -51,7 +51,7 @@ public enum SystemFileFactory {
 
   public File getFile(File parent, String child) {
     if (fsType.equals(FSType.HDFS)) {
-      throw new UnsupportedOperationException("Unsupported file system: " + 
fsType.name());
+      throw new UnsupportedOperationException(UNSUPPORT_FILE_SYSTEM + 
fsType.name());
       // return new HDFSFile(parent, child);
     } else {
       return new File(parent, child);
@@ -60,7 +60,7 @@ public enum SystemFileFactory {
 
   public File getFile(URI uri) {
     if (fsType.equals(FSType.HDFS)) {
-      throw new UnsupportedOperationException("Unsupported file system: " + 
fsType.name());
+      throw new UnsupportedOperationException(UNSUPPORT_FILE_SYSTEM + 
fsType.name());
       // return new HDFSFile(uri);
     } else {
       return new File(uri);
diff --git 
a/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/StorageGroupProcessor.java
 
b/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/StorageGroupProcessor.java
index a11080d..28783ac 100755
--- 
a/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/StorageGroupProcessor.java
+++ 
b/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/StorageGroupProcessor.java
@@ -125,6 +125,7 @@ import org.slf4j.LoggerFactory;
 public class StorageGroupProcessor {
 
   private static final String MERGING_MODIFICATION_FILE_NAME = "merge.mods";
+  private static final String FAIL_TO_UPGRADE_FOLDER = "Failed to move {} to 
upgrade folder";
 
   /**
    * All newly generated chunks after merge have version number 0, so we set 
merged Modification
@@ -476,19 +477,19 @@ public class StorageGroupProcessor {
         // move .tsfile to upgrade folder
         for (File file : oldTsfileArray) {
           if (!file.renameTo(fsFactory.getFile(upgradeFolder, 
file.getName()))) {
-            logger.error("Failed to move {} to upgrade folder", file);
+            logger.error(FAIL_TO_UPGRADE_FOLDER, file);
           }
         }
         // move .resource to upgrade folder
         for (File file : oldResourceFileArray) {
           if (!file.renameTo(fsFactory.getFile(upgradeFolder, 
file.getName()))) {
-            logger.error("Failed to move {} to upgrade folder", file);
+            logger.error(FAIL_TO_UPGRADE_FOLDER, file);
           }
         }
         // move .mods to upgrade folder
         for (File file : oldModificationFileArray) {
           if (!file.renameTo(fsFactory.getFile(upgradeFolder, 
file.getName()))) {
-            logger.error("Failed to move {} to upgrade folder", file);
+            logger.error(FAIL_TO_UPGRADE_FOLDER, file);
           }
         }
 
diff --git 
a/server/src/main/java/org/apache/iotdb/db/engine/tsfilemanagement/level/LevelTsFileManagement.java
 
b/server/src/main/java/org/apache/iotdb/db/engine/tsfilemanagement/level/LevelTsFileManagement.java
index 5e66250..0c74be3 100644
--- 
a/server/src/main/java/org/apache/iotdb/db/engine/tsfilemanagement/level/LevelTsFileManagement.java
+++ 
b/server/src/main/java/org/apache/iotdb/db/engine/tsfilemanagement/level/LevelTsFileManagement.java
@@ -65,8 +65,6 @@ public class LevelTsFileManagement extends TsFileManagement {
 
   private static final Logger logger = 
LoggerFactory.getLogger(LevelTsFileManagement.class);
   private final int maxLevelNum = 
IoTDBDescriptor.getInstance().getConfig().getMaxLevelNum();
-  private final int maxFileNumInEachLevel = 
IoTDBDescriptor.getInstance().getConfig()
-      .getMaxFileNumInEachLevel();
   private final int maxChunkPointNum = 
IoTDBDescriptor.getInstance().getConfig()
       .getMergeChunkPointNumberThreshold();
   // First map is partition list; Second list is level list; Third list is 
file list in level;
diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/MLogWriter.java 
b/server/src/main/java/org/apache/iotdb/db/metadata/MLogWriter.java
index c00206e..d42d4fd 100644
--- a/server/src/main/java/org/apache/iotdb/db/metadata/MLogWriter.java
+++ b/server/src/main/java/org/apache/iotdb/db/metadata/MLogWriter.java
@@ -35,6 +35,7 @@ import org.slf4j.LoggerFactory;
 public class MLogWriter {
 
   private static final Logger logger = 
LoggerFactory.getLogger(MLogWriter.class);
+  private static final String STRING_TYPE = "%s,%s,%s"; 
   private File logFile;
   private BufferedWriter writer;
   private int lineNumber;
@@ -104,17 +105,17 @@ public class MLogWriter {
   }
 
   public void setTTL(String storageGroup, long ttl) throws IOException {
-    writer.write(String.format("%s,%s,%s", MetadataOperationType.SET_TTL, 
storageGroup, ttl));
+    writer.write(String.format(STRING_TYPE, MetadataOperationType.SET_TTL, 
storageGroup, ttl));
     newLine();
   }
 
   public void changeOffset(String path, long offset) throws IOException {
-    writer.write(String.format("%s,%s,%s", 
MetadataOperationType.CHANGE_OFFSET, path, offset));
+    writer.write(String.format(STRING_TYPE, 
MetadataOperationType.CHANGE_OFFSET, path, offset));
     newLine();
   }
 
   public void changeAlias(String path, String alias) throws IOException {
-    writer.write(String.format("%s,%s,%s", MetadataOperationType.CHANGE_ALIAS, 
path, alias));
+    writer.write(String.format(STRING_TYPE, 
MetadataOperationType.CHANGE_ALIAS, path, alias));
     newLine();
   }
 
@@ -132,10 +133,8 @@ public class MLogWriter {
     }
 
     // if both old mlog and mlog.tmp exist, delete mlog tmp, then do upgrading
-    if (tmpLogFile.exists()) {
-      if (!tmpLogFile.delete()) {
-        throw new IOException("Deleting " + tmpLogFile + "failed.");
-      }
+    if (tmpLogFile.exists() && !tmpLogFile.delete()) {
+      throw new IOException("Deleting " + tmpLogFile + "failed.");
     }
     // upgrading
     try (BufferedReader reader = new BufferedReader(new FileReader(logFile));
diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/MManager.java 
b/server/src/main/java/org/apache/iotdb/db/metadata/MManager.java
index 3efbf76..73ce5db 100644
--- a/server/src/main/java/org/apache/iotdb/db/metadata/MManager.java
+++ b/server/src/main/java/org/apache/iotdb/db/metadata/MManager.java
@@ -93,7 +93,13 @@ import org.slf4j.LoggerFactory;
 public class MManager {
 
   public static final String TIME_SERIES_TREE_HEADER = "===  Timeseries Tree  
===\n\n";
+  private static final String TAG_FORMAT = "tag key is %s, tag value is %s, 
tlog offset is %d";
+  private static final String DEBUG_MSG = "%s : TimeSeries %s is removed from 
tag inverted index, ";  
+  private static final String DEBUG_MSG_1 = "%s: TimeSeries %s's tag info has 
been removed from tag inverted index ";
+  private static final String PREVIOUS_CONDITION = "before deleting it, tag 
key is %s, tag value is %s, tlog offset is %d, contains key %b";
+  
   private static final Logger logger = LoggerFactory.getLogger(MManager.class);
+ 
   /**
    * A thread will check whether the MTree is modified lately each such 
interval. Unit: second
    */
@@ -488,8 +494,8 @@ public class MManager {
             .containsKey(entry.getValue())) {
           if (logger.isDebugEnabled()) {
             logger.debug(String.format(
-                "Delete: TimeSeries %s is removed from tag inverted index, "
-                    + "tag key is %s, tag value is %s, tlog offset is %d",
+                DEBUG_MSG, "Delete"
+                    + TAG_FORMAT,
                 node.getFullPath(), entry.getKey(), entry.getValue(), 
node.getOffset()));
           }
           tagIndex.get(entry.getKey()).get(entry.getValue()).remove(node);
@@ -502,8 +508,8 @@ public class MManager {
         } else {
           if (logger.isDebugEnabled()) {
             logger.debug(String.format(
-                "Delete: TimeSeries %s's tag info has been removed from tag 
inverted index before "
-                    + "deleting it, tag key is %s, tag value is %s, tlog 
offset is %d, contains key %b",
+                DEBUG_MSG_1, "Delete"
+                    + PREVIOUS_CONDITION,
                 node.getFullPath(), entry.getKey(), entry.getValue(), 
node.getOffset(),
                 tagIndex.containsKey(entry.getKey())));
           }
@@ -1165,8 +1171,8 @@ public class MManager {
           if (tagIndex.containsKey(key) && 
tagIndex.get(key).containsKey(beforeValue)) {
             if (logger.isDebugEnabled()) {
               logger.debug(String.format(
-                  "Upsert: TimeSeries %s is removed from tag inverted index, "
-                      + "tag key is %s, tag value is %s, tlog offset is %d",
+                  DEBUG_MSG, "Upsert"
+                      + TAG_FORMAT,
                   leafMNode.getFullPath(), key, beforeValue, 
leafMNode.getOffset()));
             }
 
@@ -1177,8 +1183,8 @@ public class MManager {
           } else {
             if (logger.isDebugEnabled()) {
               logger.debug(String.format(
-                  "Upsert: TimeSeries %s's tag info has been removed from tag 
inverted index "
-                      + "before deleting it, tag key is %s, tag value is %s, 
tlog offset is %d, contains key %b",
+                  DEBUG_MSG_1, "Upsert"
+                      + PREVIOUS_CONDITION,
                   leafMNode.getFullPath(), key, beforeValue, 
leafMNode.getOffset(),
                   tagIndex.containsKey(key)));
             }
@@ -1327,8 +1333,8 @@ public class MManager {
       if (tagIndex.containsKey(key) && tagIndex.get(key).containsKey(value)) {
         if (logger.isDebugEnabled()) {
           logger.debug(String.format(
-              "Drop: TimeSeries %s is removed from tag inverted index, "
-                  + "tag key is %s, tag value is %s, tlog offset is %d",
+              DEBUG_MSG, "Drop"
+                  + TAG_FORMAT,
               leafMNode.getFullPath(), entry.getKey(), entry.getValue(), 
leafMNode.getOffset()));
         }
 
@@ -1342,8 +1348,8 @@ public class MManager {
       } else {
         if (logger.isDebugEnabled()) {
           logger.debug(String.format(
-              "Drop: TimeSeries %s's tag info has been removed from tag 
inverted index "
-                  + "before deleting it, tag key is %s, tag value is %s, tlog 
offset is %d, contains key %b",
+              DEBUG_MSG_1, "Drop"
+                  + PREVIOUS_CONDITION,
               leafMNode.getFullPath(), key, value, leafMNode.getOffset(),
               tagIndex.containsKey(key)));
         }
@@ -1406,8 +1412,8 @@ public class MManager {
 
         if (logger.isDebugEnabled()) {
           logger.debug(String.format(
-              "Set: TimeSeries %s is removed from tag inverted index, "
-                  + "tag key is %s, tag value is %s, tlog offset is %d",
+              DEBUG_MSG, "Set"
+                  + TAG_FORMAT,
               leafMNode.getFullPath(), entry.getKey(), beforeValue, 
leafMNode.getOffset()));
         }
 
@@ -1415,8 +1421,8 @@ public class MManager {
       } else {
         if (logger.isDebugEnabled()) {
           logger.debug(String.format(
-              "Set: TimeSeries %s's tag info has been removed from tag 
inverted index "
-                  + "before deleting it, tag key is %s, tag value is %s, tlog 
offset is %d, contains key %b",
+              DEBUG_MSG_1, "Set"
+                  + PREVIOUS_CONDITION,
               leafMNode.getFullPath(), key, beforeValue, leafMNode.getOffset(),
               tagIndex.containsKey(key)));
         }
@@ -1467,8 +1473,8 @@ public class MManager {
 
         if (logger.isDebugEnabled()) {
           logger.debug(String.format(
-              "Rename: TimeSeries %s is removed from tag inverted index, "
-                  + "tag key is %s, tag value is %s, tlog offset is %d",
+              DEBUG_MSG, "Rename"
+                  + TAG_FORMAT,
               leafMNode.getFullPath(), oldKey, value, leafMNode.getOffset()));
         }
 
@@ -1477,8 +1483,8 @@ public class MManager {
       } else {
         if (logger.isDebugEnabled()) {
           logger.debug(String.format(
-              "Rename: TimeSeries %s's tag info has been removed from tag 
inverted index "
-                  + "before deleting it, tag key is %s, tag value is %s, tlog 
offset is %d, contains key %b",
+              DEBUG_MSG_1, "Rename"
+                  + PREVIOUS_CONDITION,
               leafMNode.getFullPath(), oldKey, value, leafMNode.getOffset(),
               tagIndex.containsKey(oldKey)));
         }
diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/MTree.java 
b/server/src/main/java/org/apache/iotdb/db/metadata/MTree.java
index 582a30d..0fe0a5e 100644
--- a/server/src/main/java/org/apache/iotdb/db/metadata/MTree.java
+++ b/server/src/main/java/org/apache/iotdb/db/metadata/MTree.java
@@ -86,6 +86,7 @@ public class MTree implements Serializable {
   public static final Gson GSON = new 
GsonBuilder().setPrettyPrinting().create();
   private static final long serialVersionUID = -4200394435237291964L;
   private static final Logger logger = LoggerFactory.getLogger(MTree.class);
+  private static final String NO_CHILDNODE_MSG = " does not have the child 
node ";
   private static transient ThreadLocal<Integer> limit = new ThreadLocal<>();
   private static transient ThreadLocal<Integer> offset = new ThreadLocal<>();
   private static transient ThreadLocal<Integer> count = new ThreadLocal<>();
@@ -815,7 +816,7 @@ public class MTree implements Serializable {
       if (node.getChild(nodes[i]) != null) {
         node = node.getChild(nodes[i]);
       } else {
-        throw new MetadataException(nodes[i - 1] + " does not have the child 
node " + nodes[i]);
+        throw new MetadataException(nodes[i - 1] + NO_CHILDNODE_MSG + 
nodes[i]);
       }
     }
     return getCountInGivenLevel(node, level - (nodes.length - 1));
@@ -835,7 +836,7 @@ public class MTree implements Serializable {
           return getCount(next, nodes, idx + 1);
         }
       } else {
-        throw new MetadataException(node.getName() + " does not have the child 
node " + nodeReg);
+        throw new MetadataException(node.getName() + NO_CHILDNODE_MSG + 
nodeReg);
       }
     } else {
       int cnt = 0;
@@ -1028,10 +1029,8 @@ public class MTree implements Serializable {
           continue;
         }
         findPath(child, nodes, idx + 1, timeseriesSchemaList, hasLimit, 
needLast, queryContext);
-        if (hasLimit) {
-          if (count.get().intValue() == limit.get().intValue()) {
-            return;
-          }
+        if (hasLimit && count.get().intValue() == limit.get().intValue()) {
+          return;
         }
       }
     }
@@ -1169,7 +1168,7 @@ public class MTree implements Serializable {
           return res;
         }
       } else {
-        throw new MetadataException(nodes[i - 1] + " does not have the child 
node " + nodes[i]);
+        throw new MetadataException(nodes[i - 1] + NO_CHILDNODE_MSG + 
nodes[i]);
       }
     }
     findNodes(node, path, res, nodeLevel - (nodes.length - 1), filter);
diff --git 
a/server/src/main/java/org/apache/iotdb/db/metrics/source/JvmSource.java 
b/server/src/main/java/org/apache/iotdb/db/metrics/source/JvmSource.java
index 55c9971..13cee76 100644
--- a/server/src/main/java/org/apache/iotdb/db/metrics/source/JvmSource.java
+++ b/server/src/main/java/org/apache/iotdb/db/metrics/source/JvmSource.java
@@ -26,7 +26,7 @@ import com.codahale.metrics.jvm.MemoryUsageGaugeSet;
 
 public class JvmSource implements Source {
 
-  public String sourceName = "jvm";
+  public static final String SOURCE_NAME = "jvm";
   public MetricRegistry metricRegistry;
 
   public JvmSource(MetricRegistry metricRegistry) {
@@ -34,15 +34,17 @@ public class JvmSource implements Source {
   }
 
   public void registerInfo() {
-    metricRegistry.register(MetricRegistry.name(sourceName, "gc"), new 
GarbageCollectorMetricSet());
-    metricRegistry.register(MetricRegistry.name(sourceName, "memory"), new 
MemoryUsageGaugeSet());
-    metricRegistry.register(MetricRegistry.name(sourceName, "buffer-pool"),
+    metricRegistry.register(MetricRegistry.name(SOURCE_NAME, "gc"), new 
GarbageCollectorMetricSet());
+    metricRegistry.register(MetricRegistry.name(SOURCE_NAME, "memory"), new 
MemoryUsageGaugeSet());
+    metricRegistry.register(MetricRegistry.name(SOURCE_NAME, "buffer-pool"),
         new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer()));
   }
 
   @Override
   public String sourceName() {
-    return this.sourceName;
+    return JvmSource.SOURCE_NAME;
   }
 
+
+
 }
diff --git 
a/server/src/main/java/org/apache/iotdb/db/metrics/source/MetricsSource.java 
b/server/src/main/java/org/apache/iotdb/db/metrics/source/MetricsSource.java
index 42698c9..d61d5a4 100644
--- a/server/src/main/java/org/apache/iotdb/db/metrics/source/MetricsSource.java
+++ b/server/src/main/java/org/apache/iotdb/db/metrics/source/MetricsSource.java
@@ -24,7 +24,7 @@ import com.codahale.metrics.MetricRegistry;
 
 public class MetricsSource implements Source {
 
-  public String sourceName = "iot-metrics";
+  private static final String SOURCE_NAME = "iot-metrics";
   public MetricRegistry metricRegistry;
   public ServerArgument serverArgument;
 
@@ -35,61 +35,61 @@ public class MetricsSource implements Source {
 
   public void registerInfo() {
 
-    metricRegistry.register(MetricRegistry.name(sourceName, "host"), new 
Gauge<String>() {
+    metricRegistry.register(MetricRegistry.name(SOURCE_NAME, "host"), new 
Gauge<String>() {
       public String getValue() {
         return serverArgument.getHost();
       }
     });
 
-    metricRegistry.register(MetricRegistry.name(sourceName, "port"), new 
Gauge<Integer>() {
+    metricRegistry.register(MetricRegistry.name(SOURCE_NAME, "port"), new 
Gauge<Integer>() {
       public Integer getValue() {
         return (int) serverArgument.getPort();
       }
     });
 
-    metricRegistry.register(MetricRegistry.name(sourceName, "cores"), new 
Gauge<Integer>() {
+    metricRegistry.register(MetricRegistry.name(SOURCE_NAME, "cores"), new 
Gauge<Integer>() {
       public Integer getValue() {
         return (int) serverArgument.getCores();
       }
     });
 
-    metricRegistry.register(MetricRegistry.name(sourceName, "cpu_ratio"), new 
Gauge<Integer>() {
+    metricRegistry.register(MetricRegistry.name(SOURCE_NAME, "cpu_ratio"), new 
Gauge<Integer>() {
       public Integer getValue() {
         return (int) serverArgument.getCpuRatio();
       }
     });
 
-    metricRegistry.register(MetricRegistry.name(sourceName, "total_memory"), 
new Gauge<Integer>() {
+    metricRegistry.register(MetricRegistry.name(SOURCE_NAME, "total_memory"), 
new Gauge<Integer>() {
       public Integer getValue() {
         return (int) serverArgument.getTotalMemory();
       }
     });
 
-    metricRegistry.register(MetricRegistry.name(sourceName, "max_memory"), new 
Gauge<Integer>() {
+    metricRegistry.register(MetricRegistry.name(SOURCE_NAME, "max_memory"), 
new Gauge<Integer>() {
       public Integer getValue() {
         return (int) serverArgument.getMaxMemory();
       }
     });
 
-    metricRegistry.register(MetricRegistry.name(sourceName, "free_memory"), 
new Gauge<Integer>() {
+    metricRegistry.register(MetricRegistry.name(SOURCE_NAME, "free_memory"), 
new Gauge<Integer>() {
       public Integer getValue() {
         return (int) serverArgument.getFreeMemory();
       }
     });
 
-    metricRegistry.register(MetricRegistry.name(sourceName, 
"totalPhysical_memory"), new Gauge<Integer>() {
+    metricRegistry.register(MetricRegistry.name(SOURCE_NAME, 
"totalPhysical_memory"), new Gauge<Integer>() {
           public Integer getValue() {
             return (int) serverArgument.getTotalPhysicalMemory();
           }
         });
 
-    metricRegistry.register(MetricRegistry.name(sourceName, 
"freePhysical_memory"), new Gauge<Integer>() {
+    metricRegistry.register(MetricRegistry.name(SOURCE_NAME, 
"freePhysical_memory"), new Gauge<Integer>() {
           public Integer getValue() {
             return (int) serverArgument.getFreePhysicalMemory();
           }
         });
 
-    metricRegistry.register(MetricRegistry.name(sourceName, 
"usedPhysical_memory"), new Gauge<Integer>() {
+    metricRegistry.register(MetricRegistry.name(SOURCE_NAME, 
"usedPhysical_memory"), new Gauge<Integer>() {
           public Integer getValue() {
             return (int) serverArgument.getUsedPhysicalMemory();
           }
@@ -98,7 +98,7 @@ public class MetricsSource implements Source {
 
   @Override
   public String sourceName() {
-    return this.sourceName;
+    return MetricsSource.SOURCE_NAME;
   }
 
 }
diff --git 
a/server/src/main/java/org/apache/iotdb/db/qp/strategy/LogicalGenerator.java 
b/server/src/main/java/org/apache/iotdb/db/qp/strategy/LogicalGenerator.java
index 758129d..5225e73 100644
--- a/server/src/main/java/org/apache/iotdb/db/qp/strategy/LogicalGenerator.java
+++ b/server/src/main/java/org/apache/iotdb/db/qp/strategy/LogicalGenerator.java
@@ -200,6 +200,10 @@ public class LogicalGenerator extends SqlBaseBaseListener {
   private UpdateOperator updateOp;
   private QueryOperator queryOp;
   private DeleteDataOperator deleteDataOp;
+  private static final String DELETE_RANGE_ERROR_MSG = 
+    "For delete statement, where clause can only contain atomic expressions 
like : " +
+      "time > XXX, time <= XXX, or two atomic expressions connected by 'AND'";
+
 
   LogicalGenerator(ZoneId zoneId) {
     this.zoneId = zoneId;
@@ -1634,8 +1638,7 @@ public class LogicalGenerator extends SqlBaseBaseListener 
{
     FilterOperator filterOperator = operator.getFilterOperator();
     if (!filterOperator.isLeaf() && filterOperator.getTokenIntType() != 
SQLConstant.KW_AND) {
       throw new SQLParserException(
-          "For delete statement, where clause can only contain atomic 
expressions like : "
-              + "time > XXX, time <= XXX, or two atomic expressions connected 
by 'AND'");
+          DELETE_RANGE_ERROR_MSG);
     }
 
     if (filterOperator.isLeaf()) {
@@ -1647,8 +1650,7 @@ public class LogicalGenerator extends SqlBaseBaseListener 
{
     FilterOperator rOperator = children.get(1);
     if (!lOperator.isLeaf() || !rOperator.isLeaf()) {
       throw new SQLParserException(
-          "For delete statement, where clause can only contain atomic 
expressions like : "
-              + "time > XXX, time <= XXX, or two atomic expressions connected 
by 'AND'");
+          DELETE_RANGE_ERROR_MSG);
     }
 
     Pair<Long, Long> leftOpInterval = calcOperatorInterval(lOperator);
@@ -1678,8 +1680,7 @@ public class LogicalGenerator extends SqlBaseBaseListener 
{
         return new Pair<>(time, time);
       default:
         throw new SQLParserException(
-            "For delete statement, where clause can only contain atomic 
expressions like : "
-                + "time > XXX, time <= XXX, or two atomic expressions 
connected by 'AND'");
+            DELETE_RANGE_ERROR_MSG);
     }
   }
 
diff --git 
a/server/src/main/java/org/apache/iotdb/db/query/control/TracingManager.java 
b/server/src/main/java/org/apache/iotdb/db/query/control/TracingManager.java
index 68aa034..cd23d0b 100644
--- a/server/src/main/java/org/apache/iotdb/db/query/control/TracingManager.java
+++ b/server/src/main/java/org/apache/iotdb/db/query/control/TracingManager.java
@@ -32,6 +32,8 @@ import org.slf4j.LoggerFactory;
 public class TracingManager {
 
   private static final Logger logger = 
LoggerFactory.getLogger(TracingManager.class);
+  private static final String QUERY_ID = "Query Id: ";
+  private static final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss.SSS";
   private BufferedWriter writer;
 
   public TracingManager(String dirName, String logFileName) {
@@ -60,12 +62,12 @@ public class TracingManager {
 
   public void writeQueryInfo(long queryId, String statement, int pathsNum) 
throws IOException {
     StringBuilder builder = new StringBuilder();
-    builder.append("Query Id: ").append(queryId)
+    builder.append(QUERY_ID).append(queryId)
         .append(" - Query Statement: ").append(statement)
-        .append("\nQuery Id: ").append(queryId)
+        .append("\n" + QUERY_ID).append(queryId)
         .append(" - Start time: ")
-        .append(new SimpleDateFormat("yyyy-MM-dd 
HH:mm:ss.SSS").format(System.currentTimeMillis()))
-        .append("\nQuery Id: ").append(queryId)
+        .append(new 
SimpleDateFormat(DATE_FORMAT).format(System.currentTimeMillis()))
+        .append("\n" + QUERY_ID).append(queryId)
         .append(" - Number of series paths: ").append(pathsNum)
         .append("\n");
     writer.write(builder.toString());
@@ -74,17 +76,17 @@ public class TracingManager {
   // for align by device query
   public void writeQueryInfo(long queryId, String statement) throws 
IOException {
     StringBuilder builder = new StringBuilder();
-    builder.append("Query Id: ").append(queryId)
+    builder.append(QUERY_ID).append(queryId)
         .append(" - Query Statement: ").append(statement)
-        .append("\nQuery Id: ").append(queryId)
+        .append("\n" + QUERY_ID).append(queryId)
         .append(" - Start time: ")
-        .append(new SimpleDateFormat("yyyy-MM-dd 
HH:mm:ss.SSS").format(System.currentTimeMillis()))
+        .append(new 
SimpleDateFormat(DATE_FORMAT).format(System.currentTimeMillis()))
         .append("\n");
     writer.write(builder.toString());
   }
 
   public void writePathsNum(long queryId, int pathsNum) throws IOException {
-    StringBuilder builder = new StringBuilder("Query Id: ").append(queryId)
+    StringBuilder builder = new StringBuilder(QUERY_ID).append(queryId)
         .append(" - Number of series paths: ").append(pathsNum)
         .append("\n");
     writer.write(builder.toString());
@@ -93,11 +95,11 @@ public class TracingManager {
   public void writeTsFileInfo(long queryId, int seqFileNum, int unseqFileNum) 
throws IOException {
     // to avoid the disorder info of multi query
     // add query id as prefix of each info
-    StringBuilder builder = new StringBuilder("Query Id: ").append(queryId)
+    StringBuilder builder = new StringBuilder(QUERY_ID).append(queryId)
         .append(" - Number of tsfiles: ").append(seqFileNum + unseqFileNum)
-        .append("\nQuery Id: ").append(queryId)
+        .append("\n" + QUERY_ID).append(queryId)
         .append(" - Number of sequence files: ").append(seqFileNum)
-        .append("\nQuery Id: ").append(queryId)
+        .append("\n" + QUERY_ID).append(queryId)
         .append(" - Number of unsequence files: ").append(unseqFileNum)
         .append("\n");
     writer.write(builder.toString());
@@ -105,18 +107,18 @@ public class TracingManager {
 
   public void writeChunksInfo(long queryId, long totalChunkNum, long 
totalChunkSize)
       throws IOException {
-    StringBuilder builder = new StringBuilder("Query Id: ").append(queryId)
+    StringBuilder builder = new StringBuilder(QUERY_ID).append(queryId)
         .append(" - Number of chunks: ").append(totalChunkNum)
-        .append("\nQuery Id: ").append(queryId)
+        .append("\n" + QUERY_ID).append(queryId)
         .append(" - Average size of chunks: ").append(totalChunkSize / 
totalChunkNum)
         .append("\n");
     writer.write(builder.toString());
   }
 
   public void writeEndTime(long queryId) throws IOException {
-    StringBuilder builder = new StringBuilder("Query Id: ").append(queryId)
+    StringBuilder builder = new StringBuilder(QUERY_ID).append(queryId)
         .append(" - End time: ")
-        .append(new SimpleDateFormat("yyyy-MM-dd 
HH:mm:ss.SSS").format(System.currentTimeMillis()))
+        .append(new 
SimpleDateFormat(DATE_FORMAT).format(System.currentTimeMillis()))
         .append("\n");
     writer.write(builder.toString());
     writer.flush();
diff --git 
a/server/src/main/java/org/apache/iotdb/db/service/TSServiceImpl.java 
b/server/src/main/java/org/apache/iotdb/db/service/TSServiceImpl.java
index e5ea7fd..2d9f676 100644
--- a/server/src/main/java/org/apache/iotdb/db/service/TSServiceImpl.java
+++ b/server/src/main/java/org/apache/iotdb/db/service/TSServiceImpl.java
@@ -141,6 +141,9 @@ public class TSServiceImpl implements TSIService.Iface, 
ServerContext {
   private static final int FETCH_SIZE = 10000;
   private static final String ERROR_PARSING_SQL =
       "meet error while parsing SQL to physical plan: {}";
+  private static final String SERVER_INTERNAL_ERROR = "{}: server Internal 
Error: ";
+  private static final String CHECK_METADATA_ERROR = "check metadata error: ";
+
   private static final List<SqlArgument> sqlArgumentList = new 
ArrayList<>(MAX_SIZE);
   protected Planner processor;
   protected IPlanExecutor executor;
@@ -404,7 +407,7 @@ public class TSServiceImpl implements TSIService.Iface, 
ServerContext {
         return RpcUtils.getStatus(result);
       }
     } catch (Exception e) {
-      logger.error("{}: server Internal Error: ", 
IoTDBConstant.GLOBAL_DB_NAME, e);
+      logger.error(SERVER_INTERNAL_ERROR, IoTDBConstant.GLOBAL_DB_NAME, e);
       return RpcUtils
           .getStatus(TSStatusCode.INTERNAL_SERVER_ERROR, e.getMessage());
     } finally {
@@ -453,7 +456,7 @@ public class TSServiceImpl implements TSIService.Iface, 
ServerContext {
               "query statement not allowed: " + statement));
       return false;
     } catch (Exception e) {
-      logger.error("{}: server Internal Error: ", 
IoTDBConstant.GLOBAL_DB_NAME, e);
+      logger.error(SERVER_INTERNAL_ERROR, IoTDBConstant.GLOBAL_DB_NAME, e);
       result.add(RpcUtils.getStatus(
           TSStatusCode.INTERNAL_SERVER_ERROR, "server Internal Error: " + 
e.getMessage()));
     }
@@ -482,16 +485,16 @@ public class TSServiceImpl implements TSIService.Iface, 
ServerContext {
       logger.warn(ERROR_PARSING_SQL, req.getStatement() + " " + 
e.getMessage());
       return RpcUtils.getTSExecuteStatementResp(TSStatusCode.SQL_PARSE_ERROR, 
e.getMessage());
     } catch (SQLParserException e) {
-      logger.error("check metadata error: ", e);
+      logger.error(CHECK_METADATA_ERROR, e);
       return RpcUtils.getTSExecuteStatementResp(
-          TSStatusCode.METADATA_ERROR, "Check metadata error: " + 
e.getMessage());
+          TSStatusCode.METADATA_ERROR, CHECK_METADATA_ERROR + e.getMessage());
     } catch (QueryProcessException e) {
       logger.info(ERROR_PARSING_SQL, e.getMessage());
       return RpcUtils.getTSExecuteStatementResp(
           RpcUtils.getStatus(TSStatusCode.QUERY_PROCESS_ERROR,
               "Meet error in query process: " + e.getMessage()));
     } catch (Exception e) {
-      logger.error("{}: server Internal Error: ", 
IoTDBConstant.GLOBAL_DB_NAME, e);
+      logger.error(SERVER_INTERNAL_ERROR, IoTDBConstant.GLOBAL_DB_NAME, e);
       return 
RpcUtils.getTSExecuteStatementResp(TSStatusCode.INTERNAL_SERVER_ERROR, 
e.getMessage());
     }
   }
@@ -527,11 +530,11 @@ public class TSServiceImpl implements TSIService.Iface, 
ServerContext {
       return RpcUtils.getTSExecuteStatementResp(TSStatusCode.SQL_PARSE_ERROR,
           ERROR_PARSING_SQL + e.getMessage());
     } catch (SQLParserException e) {
-      logger.error("check metadata error: ", e);
+      logger.error(CHECK_METADATA_ERROR, e);
       return RpcUtils.getTSExecuteStatementResp(
-          TSStatusCode.METADATA_ERROR, "Check metadata error: " + 
e.getMessage());
+          TSStatusCode.METADATA_ERROR, CHECK_METADATA_ERROR + e.getMessage());
     } catch (Exception e) {
-      logger.error("{}: server Internal Error: ", 
IoTDBConstant.GLOBAL_DB_NAME, e);
+      logger.error(SERVER_INTERNAL_ERROR, IoTDBConstant.GLOBAL_DB_NAME, e);
       return RpcUtils.getTSExecuteStatementResp(
           RpcUtils.getStatus(TSStatusCode.INTERNAL_SERVER_ERROR, 
e.getMessage()));
     }
@@ -567,11 +570,11 @@ public class TSServiceImpl implements TSIService.Iface, 
ServerContext {
       return RpcUtils.getTSExecuteStatementResp(TSStatusCode.SQL_PARSE_ERROR,
           ERROR_PARSING_SQL + e.getMessage());
     } catch (SQLParserException e) {
-      logger.error("check metadata error: ", e);
+      logger.error(CHECK_METADATA_ERROR, e);
       return RpcUtils.getTSExecuteStatementResp(
-          TSStatusCode.METADATA_ERROR, "Check metadata error: " + 
e.getMessage());
+          TSStatusCode.METADATA_ERROR, CHECK_METADATA_ERROR + e.getMessage());
     } catch (Exception e) {
-      logger.error("{}: server Internal Error: ", 
IoTDBConstant.GLOBAL_DB_NAME, e);
+      logger.error(SERVER_INTERNAL_ERROR, IoTDBConstant.GLOBAL_DB_NAME, e);
       return RpcUtils.getTSExecuteStatementResp(
           RpcUtils.getStatus(TSStatusCode.INTERNAL_SERVER_ERROR, 
e.getMessage()));
     }
@@ -1045,7 +1048,7 @@ public class TSServiceImpl implements TSIService.Iface, 
ServerContext {
       String statement = req.getStatement();
       return executeUpdateStatement(statement, req.getSessionId());
     } catch (Exception e) {
-      logger.error("{}: server Internal Error: ", 
IoTDBConstant.GLOBAL_DB_NAME, e);
+      logger.error(SERVER_INTERNAL_ERROR, IoTDBConstant.GLOBAL_DB_NAME, e);
       return RpcUtils.getTSExecuteStatementResp(
           RpcUtils.getStatus(TSStatusCode.INTERNAL_SERVER_ERROR, 
e.getMessage()));
     }
@@ -1671,7 +1674,7 @@ public class TSServiceImpl implements TSIService.Iface, 
ServerContext {
       logger.error("meet error while checking authorization.", e);
       return RpcUtils.getStatus(TSStatusCode.UNINITIALIZED_AUTH_ERROR, 
e.getMessage());
     } catch (Exception e) {
-      logger.error("{}: server Internal Error: ", 
IoTDBConstant.GLOBAL_DB_NAME, e);
+      logger.error(SERVER_INTERNAL_ERROR, IoTDBConstant.GLOBAL_DB_NAME, e);
       return RpcUtils.getStatus(TSStatusCode.INTERNAL_SERVER_ERROR, 
e.getMessage());
     }
     return null;
@@ -1687,7 +1690,7 @@ public class TSServiceImpl implements TSIService.Iface, 
ServerContext {
       logger.error("meet error while processing non-query. ", e);
       return RpcUtils.getStatus(e.getErrorCode(), e.getMessage());
     } catch (Exception e) {
-      logger.error("{}: server Internal Error: ", 
IoTDBConstant.GLOBAL_DB_NAME, e);
+      logger.error(SERVER_INTERNAL_ERROR, IoTDBConstant.GLOBAL_DB_NAME, e);
       return RpcUtils.getStatus(TSStatusCode.INTERNAL_SERVER_ERROR, 
e.getMessage());
     }
 
diff --git 
a/server/src/test/java/org/apache/iotdb/db/integration/IoTDBLastIT.java 
b/server/src/test/java/org/apache/iotdb/db/integration/IoTDBLastIT.java
index f9d3e9f..c771bbb 100644
--- a/server/src/test/java/org/apache/iotdb/db/integration/IoTDBLastIT.java
+++ b/server/src/test/java/org/apache/iotdb/db/integration/IoTDBLastIT.java
@@ -179,7 +179,7 @@ public class IoTDBLastIT {
 
       // Last cache is updated with above insert sql
       long time = node.getCachedLast().getTimestamp();
-      Assert.assertEquals(time, 700);
+      Assert.assertEquals(700, time);
 
       hasResultSet = statement.execute("select last temperature,status,id from 
root.ln.wf01.wt01");
       Assert.assertTrue(hasResultSet);
@@ -198,7 +198,7 @@ public class IoTDBLastIT {
 
       // Last cache is not updated with above insert sql
       time = node.getCachedLast().getTimestamp();
-      Assert.assertEquals(time, 700);
+      Assert.assertEquals(700, time);
 
       hasResultSet = statement.execute("select last temperature,status,id from 
root.ln.wf01.wt01");
       Assert.assertTrue(hasResultSet);
@@ -306,7 +306,7 @@ public class IoTDBLastIT {
           Assert.assertEquals(retArray[cnt], ans);
           cnt++;
         }
-        Assert.assertEquals(cnt, 1);
+        Assert.assertEquals(1, cnt);
       }
     }
   }
@@ -352,7 +352,7 @@ public class IoTDBLastIT {
           Assert.assertEquals(retArray[cnt], ans);
           cnt++;
         }
-        Assert.assertEquals(cnt, 1);
+        Assert.assertEquals(1, cnt);
       }
     }
   }
@@ -394,7 +394,7 @@ public class IoTDBLastIT {
           Assert.assertEquals(retArray[cnt], ans);
           cnt++;
         }
-        Assert.assertEquals(cnt, 1);
+        Assert.assertEquals(1, cnt);
       }
 
       statement
diff --git 
a/server/src/test/java/org/apache/iotdb/db/integration/IoTDBTracingTest.java 
b/server/src/test/java/org/apache/iotdb/db/integration/IoTDBTracingTest.java
index 4d9ecf3..67e1c95 100644
--- a/server/src/test/java/org/apache/iotdb/db/integration/IoTDBTracingTest.java
+++ b/server/src/test/java/org/apache/iotdb/db/integration/IoTDBTracingTest.java
@@ -52,13 +52,13 @@ public class IoTDBTracingTest {
         .getConnection(Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", 
"root");
         Statement statement = connection.createStatement()) {
       IoTDBConfig config = IoTDBDescriptor.getInstance().getConfig();
-      Assert.assertEquals(config.isEnablePerformanceTracing(), false);
+      Assert.assertEquals(false, config.isEnablePerformanceTracing());
 
       statement.execute("tracing on");
-      Assert.assertEquals(config.isEnablePerformanceTracing(), true);
+      Assert.assertEquals(true, config.isEnablePerformanceTracing());
 
       statement.execute("tracing off");
-      Assert.assertEquals(config.isEnablePerformanceTracing(), false);
+      Assert.assertEquals(false, config.isEnablePerformanceTracing());
     } catch (Exception e) {
       e.printStackTrace();
       fail(e.getMessage());
diff --git 
a/server/src/test/java/org/apache/iotdb/db/qp/plan/LogicalPlanSmallTest.java 
b/server/src/test/java/org/apache/iotdb/db/qp/plan/LogicalPlanSmallTest.java
index b897c07..f44567e 100644
--- a/server/src/test/java/org/apache/iotdb/db/qp/plan/LogicalPlanSmallTest.java
+++ b/server/src/test/java/org/apache/iotdb/db/qp/plan/LogicalPlanSmallTest.java
@@ -340,7 +340,7 @@ public class LogicalPlanSmallTest {
     } catch (RuntimeException e) {
       errorMsg = e.getMessage();
     }
-    Assert.assertEquals(errorMsg, "Invalid delete range: [1, -2]");
+    Assert.assertEquals("Invalid delete range: [1, -2]", errorMsg);
 
     sql = "delete from root.d1.s1 where time > 5 and time <= 0";
     errorMsg = null;
diff --git 
a/server/src/test/java/org/apache/iotdb/db/qp/plan/PhysicalPlanTest.java 
b/server/src/test/java/org/apache/iotdb/db/qp/plan/PhysicalPlanTest.java
index b20f4bf..abfac3b 100644
--- a/server/src/test/java/org/apache/iotdb/db/qp/plan/PhysicalPlanTest.java
+++ b/server/src/test/java/org/apache/iotdb/db/qp/plan/PhysicalPlanTest.java
@@ -874,7 +874,7 @@ public class PhysicalPlanTest {
     PhysicalPlan plan = processor.parseSQLToPhysicalPlan(sqlStr1);
     Assert.assertFalse(plan.isQuery());
     Assert.assertEquals(plan.getPaths(), Collections.singletonList(new 
PartialPath("root.vehicle.d1")));
-    Assert.assertEquals(((DeletePlan) plan).getDeleteStartTime(), 1);
-    Assert.assertEquals(((DeletePlan) plan).getDeleteEndTime(), 2);
+    Assert.assertEquals(1, ((DeletePlan) plan).getDeleteStartTime());
+    Assert.assertEquals(2, ((DeletePlan) plan).getDeleteEndTime());
   }
 }
diff --git 
a/server/src/test/java/org/apache/iotdb/db/writelog/recover/LogReplayerTest.java
 
b/server/src/test/java/org/apache/iotdb/db/writelog/recover/LogReplayerTest.java
index 8564b93..f7a5c63 100644
--- 
a/server/src/test/java/org/apache/iotdb/db/writelog/recover/LogReplayerTest.java
+++ 
b/server/src/test/java/org/apache/iotdb/db/writelog/recover/LogReplayerTest.java
@@ -146,7 +146,7 @@ public class LogReplayerTest {
       assertEquals(1, mods.length);
       assertEquals("root.sg.device0.sensor0", mods[0].getPathString());
       assertEquals(5, mods[0].getVersionNum());
-      assertEquals(((Deletion) mods[0]).getEndTime(), 200);
+      assertEquals(200, ((Deletion) mods[0]).getEndTime());
 
       assertEquals(2, tsFileResource.getStartTime("root.sg.device0"));
       assertEquals(100, tsFileResource.getEndTime("root.sg.device0"));
diff --git a/session/src/main/java/org/apache/iotdb/session/SessionDataSet.java 
b/session/src/main/java/org/apache/iotdb/session/SessionDataSet.java
index f264ece..dbe078d 100644
--- a/session/src/main/java/org/apache/iotdb/session/SessionDataSet.java
+++ b/session/src/main/java/org/apache/iotdb/session/SessionDataSet.java
@@ -129,10 +129,8 @@ public class SessionDataSet {
 
 
   public RowRecord next() throws StatementExecutionException, 
IoTDBConnectionException {
-    if (!ioTDBRpcDataSet.hasCachedRecord) {
-      if (!hasNext()) {
-        return null;
-      }
+    if (!ioTDBRpcDataSet.hasCachedRecord && !hasNext()) {
+      return null;
     }
     ioTDBRpcDataSet.hasCachedRecord = false;
 
diff --git 
a/spark-iotdb-connector/src/main/scala/org/apache/iotdb/spark/db/IoTDBRDD.scala 
b/spark-iotdb-connector/src/main/scala/org/apache/iotdb/spark/db/IoTDBRDD.scala
index ac02191..c5d2cb3 100644
--- 
a/spark-iotdb-connector/src/main/scala/org/apache/iotdb/spark/db/IoTDBRDD.scala
+++ 
b/spark-iotdb-connector/src/main/scala/org/apache/iotdb/spark/db/IoTDBRDD.scala
@@ -111,11 +111,9 @@ class IoTDBRDD private[iotdb](
 
 
     override def hasNext: Boolean = {
-      if (!finished) {
-        if (!gotNext) {
+      if (!finished && !gotNext) {
           nextValue = getNext
           gotNext = true
-        }
       }
       !finished
     }
diff --git 
a/tsfile/src/main/java/org/apache/iotdb/tsfile/compress/IUnCompressor.java 
b/tsfile/src/main/java/org/apache/iotdb/tsfile/compress/IUnCompressor.java
index 82ccc3e..77c7439 100644
--- a/tsfile/src/main/java/org/apache/iotdb/tsfile/compress/IUnCompressor.java
+++ b/tsfile/src/main/java/org/apache/iotdb/tsfile/compress/IUnCompressor.java
@@ -30,6 +30,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.xerial.snappy.Snappy;
 
+
 /**
  * uncompress data according to type in metadata.
  */
@@ -191,6 +192,8 @@ public interface IUnCompressor {
   class LZ4UnCompressor implements IUnCompressor {
 
     private static final Logger logger = 
LoggerFactory.getLogger(LZ4Compressor.class);
+    private static final String UNCOMPRESS_INPUT_ERROR = "tsfile-compression 
LZ4UnCompressor: errors occurs when uncompress input byte";
+
     private static final int MAX_COMPRESS_RATIO = 255;
     private LZ4SafeDecompressor decompressor;
 
@@ -225,7 +228,7 @@ public interface IUnCompressor {
         return decompressor.decompress(bytes, MAX_COMPRESS_RATIO * 
bytes.length);
       } catch (RuntimeException e) {
         logger.error(
-            "tsfile-compression LZ4UnCompressor: errors occurs when uncompress 
input byte", e);
+            UNCOMPRESS_INPUT_ERROR, e);
         throw new IOException(e);
       }
     }
@@ -238,7 +241,7 @@ public interface IUnCompressor {
       }
       catch (RuntimeException e){
         logger.error(
-            "tsfile-compression LZ4UnCompressor: errors occurs when uncompress 
input byte", e);
+            UNCOMPRESS_INPUT_ERROR, e);
         throw new IOException(e);
       }
     }
@@ -254,7 +257,7 @@ public interface IUnCompressor {
         return compressed.limit();
       } catch (RuntimeException e) {
         logger.error(
-            "tsfile-compression LZ4UnCompressor: errors occurs when uncompress 
input byte", e);
+            UNCOMPRESS_INPUT_ERROR, e);
         throw new IOException(e);
       }
     }
diff --git 
a/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/decoder/Decoder.java 
b/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/decoder/Decoder.java
index a24052c..76892a4 100644
--- a/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/decoder/Decoder.java
+++ b/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/decoder/Decoder.java
@@ -31,6 +31,8 @@ import org.apache.iotdb.tsfile.utils.Binary;
 
 public abstract class Decoder {
 
+  private static final String ERROR_MSG = "Decoder not found: %s , DataType is 
: %s";
+
   private TSEncoding type;
 
   public Decoder(TSEncoding type) {
@@ -67,8 +69,7 @@ public abstract class Decoder {
         case DOUBLE:
           return new FloatDecoder(TSEncoding.valueOf(type.toString()), 
dataType);
         default:
-          throw new TsFileDecodingException(
-              "Decoder not found:" + type + " , DataType is :" + dataType);
+          throw new TsFileDecodingException(String.format(ERROR_MSG, type, 
dataType));
       }
     } else if (type == TSEncoding.TS_2DIFF) {
       switch (dataType) {
@@ -81,7 +82,7 @@ public abstract class Decoder {
           return new FloatDecoder(TSEncoding.valueOf(type.toString()), 
dataType);
         default:
           throw new TsFileDecodingException(
-              "Decoder not found:" + type + " , DataType is :" + dataType);
+              String.format(ERROR_MSG, type, dataType));
       }
     } else if (type == TSEncoding.GORILLA) {
       switch (dataType) {
@@ -91,7 +92,7 @@ public abstract class Decoder {
           return new DoublePrecisionDecoder();
         default:
           throw new TsFileDecodingException(
-              "Decoder not found:" + type + " , DataType is :" + dataType);
+              String.format(ERROR_MSG, type, dataType));
       }
     } else if (type == TSEncoding.REGULAR) {
       switch (dataType) {
@@ -101,11 +102,11 @@ public abstract class Decoder {
           return new RegularDataDecoder.LongRegularDecoder();
         default:
           throw new TsFileDecodingException(
-              "Decoder not found:" + type + " , DataType is :" + dataType);
+              String.format(ERROR_MSG, type, dataType));
       }
     } else {
       throw new TsFileDecodingException(
-          "Decoder not found:" + type + " , DataType is :" + dataType);
+          String.format(ERROR_MSG, type, dataType));
     }
   }
 
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 c1cb381..ab6fc6f 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
@@ -36,7 +36,7 @@ public class BinaryStatistics extends Statistics<Binary> {
 
   private Binary firstValue = new Binary("");
   private Binary lastValue = new Binary("");
-
+  private static final String BINARY_STATS_UNSUPPORTED_MSG = "Binary 
statistics does not support: %s"; 
   @Override
   public TSDataType getType() {
     return TSDataType.TEXT;
@@ -80,12 +80,12 @@ public class BinaryStatistics extends Statistics<Binary> {
 
   @Override
   public Binary getMinValue() {
-    throw new StatisticsClassException("Binary statistics does not support: 
min");
+    throw new 
StatisticsClassException(String.format(BINARY_STATS_UNSUPPORTED_MSG, "min"));
   }
-
+ 
   @Override
   public Binary getMaxValue() {
-    throw new StatisticsClassException("Binary statistics does not support: 
max");
+    throw new 
StatisticsClassException(String.format(BINARY_STATS_UNSUPPORTED_MSG, "max"));
   }
 
   @Override
@@ -100,7 +100,7 @@ public class BinaryStatistics extends Statistics<Binary> {
 
   @Override
   public double getSumValue() {
-    throw new StatisticsClassException("Binary statistics does not support: 
sum");
+    throw new 
StatisticsClassException(String.format(BINARY_STATS_UNSUPPORTED_MSG, "sum"));
   }
 
   @Override
@@ -138,12 +138,12 @@ public class BinaryStatistics extends Statistics<Binary> {
 
   @Override
   public byte[] getMinValueBytes() {
-    throw new StatisticsClassException("Binary statistics does not support: 
min");
+    throw new 
StatisticsClassException(String.format(BINARY_STATS_UNSUPPORTED_MSG, "min"));
   }
 
   @Override
   public byte[] getMaxValueBytes() {
-    throw new StatisticsClassException("Binary statistics does not support: 
max");
+    throw new 
StatisticsClassException(String.format(BINARY_STATS_UNSUPPORTED_MSG, "max"));
   }
 
   @Override
@@ -158,17 +158,17 @@ public class BinaryStatistics extends Statistics<Binary> {
 
   @Override
   public byte[] getSumValueBytes() {
-    throw new StatisticsClassException("Binary statistics does not support: 
sum");
+    throw new 
StatisticsClassException(String.format(BINARY_STATS_UNSUPPORTED_MSG, "sum"));
   }
 
   @Override
   public ByteBuffer getMinValueBuffer() {
-    throw new StatisticsClassException("Binary statistics does not support: 
min");
+    throw new 
StatisticsClassException(String.format(BINARY_STATS_UNSUPPORTED_MSG, "min"));
   }
 
   @Override
   public ByteBuffer getMaxValueBuffer() {
-    throw new StatisticsClassException("Binary statistics does not support: 
max");
+    throw new 
StatisticsClassException(String.format(BINARY_STATS_UNSUPPORTED_MSG, "max"));
   }
 
   @Override
@@ -183,7 +183,7 @@ public class BinaryStatistics extends Statistics<Binary> {
 
   @Override
   public ByteBuffer getSumValueBuffer() {
-    throw new StatisticsClassException("Binary statistics does not support: 
sum");
+    throw new 
StatisticsClassException(String.format(BINARY_STATS_UNSUPPORTED_MSG, "sum"));
   }
 
   @Override
diff --git 
a/tsfile/src/main/java/org/apache/iotdb/tsfile/read/common/BatchData.java 
b/tsfile/src/main/java/org/apache/iotdb/tsfile/read/common/BatchData.java
index 0f0d81f..f0732c0 100644
--- a/tsfile/src/main/java/org/apache/iotdb/tsfile/read/common/BatchData.java
+++ b/tsfile/src/main/java/org/apache/iotdb/tsfile/read/common/BatchData.java
@@ -424,7 +424,7 @@ public class BatchData implements Serializable {
     return this.booleanRet.get(readCurListIndex)[readCurArrayIndex];
   }
 
-  public void setBoolean(int idx, boolean v) {
+  public void setBoolean(boolean v) {
     this.booleanRet.get(readCurListIndex)[readCurArrayIndex] = v;
   }
 
@@ -432,7 +432,7 @@ public class BatchData implements Serializable {
     return this.intRet.get(readCurListIndex)[readCurArrayIndex];
   }
 
-  public void setInt(int idx, int v) {
+  public void setInt(int v) {
     this.intRet.get(readCurListIndex)[readCurArrayIndex] = v;
   }
 
@@ -440,7 +440,7 @@ public class BatchData implements Serializable {
     return this.longRet.get(readCurListIndex)[readCurArrayIndex];
   }
 
-  public void setLong(int idx, long v) {
+  public void setLong(long v) {
     this.longRet.get(readCurListIndex)[readCurArrayIndex] = v;
   }
 
@@ -448,7 +448,7 @@ public class BatchData implements Serializable {
     return this.floatRet.get(readCurListIndex)[readCurArrayIndex];
   }
 
-  public void setFloat(int idx, float v) {
+  public void setFloat(float v) {
     this.floatRet.get(readCurListIndex)[readCurArrayIndex] = v;
   }
 
@@ -456,7 +456,7 @@ public class BatchData implements Serializable {
     return this.doubleRet.get(readCurListIndex)[readCurArrayIndex];
   }
 
-  public void setDouble(int idx, double v) {
+  public void setDouble(double v) {
     this.doubleRet.get(readCurListIndex)[readCurArrayIndex] = v;
   }
 
@@ -464,11 +464,11 @@ public class BatchData implements Serializable {
     return this.binaryRet.get(readCurListIndex)[readCurArrayIndex];
   }
 
-  public void setBinary(int idx, Binary v) {
+  public void setBinary(Binary v) {
     this.binaryRet.get(readCurListIndex)[readCurArrayIndex] = v;
   }
 
-  public void setTime(int idx, long v) {
+  public void setTime(long v) {
     this.timeRet.get(readCurListIndex)[readCurArrayIndex] = v;
   }
 
diff --git 
a/tsfile/src/main/java/org/apache/iotdb/tsfile/utils/ReadWriteIOUtils.java 
b/tsfile/src/main/java/org/apache/iotdb/tsfile/utils/ReadWriteIOUtils.java
index 4caf429..2a25fef 100644
--- a/tsfile/src/main/java/org/apache/iotdb/tsfile/utils/ReadWriteIOUtils.java
+++ b/tsfile/src/main/java/org/apache/iotdb/tsfile/utils/ReadWriteIOUtils.java
@@ -59,6 +59,8 @@ public class ReadWriteIOUtils {
 
   private static final byte[] magicStringBytes;
 
+  private static final String RETURN_ERROR = "Intend to read %d bytes but %d 
are actually returned";
+
   static {
     magicStringBytes = BytesUtils.stringToBytes(TSFileConfig.MAGIC_STRING);
   }
@@ -458,7 +460,7 @@ public class ReadWriteIOUtils {
     byte[] bytes = new byte[SHORT_LEN];
     int readLen = inputStream.read(bytes);
     if (readLen != SHORT_LEN) {
-      throw new IOException(String.format("Intend to read %d bytes but %d are 
actually returned",
+      throw new IOException(String.format(RETURN_ERROR,
           SHORT_LEN, readLen));
     }
     return BytesUtils.bytesToShort(bytes);
@@ -478,7 +480,7 @@ public class ReadWriteIOUtils {
     byte[] bytes = new byte[FLOAT_LEN];
     int readLen = inputStream.read(bytes);
     if (readLen != FLOAT_LEN) {
-      throw new IOException(String.format("Intend to read %d bytes but %d are 
actually returned",
+      throw new IOException(String.format(RETURN_ERROR,
           FLOAT_LEN, readLen));
     }
     return BytesUtils.bytesToFloat(bytes);
@@ -500,7 +502,7 @@ public class ReadWriteIOUtils {
     byte[] bytes = new byte[DOUBLE_LEN];
     int readLen = inputStream.read(bytes);
     if (readLen != DOUBLE_LEN) {
-      throw new IOException(String.format("Intend to read %d bytes but %d are 
actually returned",
+      throw new IOException(String.format(RETURN_ERROR,
           DOUBLE_LEN, readLen));
     }
     return BytesUtils.bytesToDouble(bytes);
@@ -522,7 +524,7 @@ public class ReadWriteIOUtils {
     byte[] bytes = new byte[INT_LEN];
     int readLen = inputStream.read(bytes);
     if (readLen != INT_LEN) {
-      throw new IOException(String.format("Intend to read %d bytes but %d are 
actually returned",
+      throw new IOException(String.format(RETURN_ERROR,
           INT_LEN, readLen));
     }
     return BytesUtils.bytesToInt(bytes);
@@ -554,7 +556,7 @@ public class ReadWriteIOUtils {
     byte[] bytes = new byte[LONG_LEN];
     int readLen = inputStream.read(bytes);
     if (readLen != LONG_LEN) {
-      throw new IOException(String.format("Intend to read %d bytes but %d are 
actually returned",
+      throw new IOException(String.format(RETURN_ERROR,
           LONG_LEN, readLen));
     }
     return BytesUtils.bytesToLong(bytes);
@@ -575,7 +577,7 @@ public class ReadWriteIOUtils {
     byte[] bytes = new byte[strLength];
     int readLen = inputStream.read(bytes, 0, strLength);
     if (readLen != strLength) {
-      throw new IOException(String.format("Intend to read %d bytes but %d are 
actually returned",
+      throw new IOException(String.format(RETURN_ERROR,
           strLength, readLen));
     }
     return new String(bytes, 0, strLength);
diff --git 
a/tsfile/src/main/java/org/apache/iotdb/tsfile/write/record/Tablet.java 
b/tsfile/src/main/java/org/apache/iotdb/tsfile/write/record/Tablet.java
index 05f37bd..9de8b91 100644
--- a/tsfile/src/main/java/org/apache/iotdb/tsfile/write/record/Tablet.java
+++ b/tsfile/src/main/java/org/apache/iotdb/tsfile/write/record/Tablet.java
@@ -43,6 +43,7 @@ import org.apache.iotdb.tsfile.write.schema.MeasurementSchema;
 public class Tablet {
 
   private static final int DEFAULT_SIZE = 1024;
+  private static final String NOT_SUPPORT_DATATYPE= "Data type %s is not 
supported.";
 
   /**
    * deviceId of this tablet
@@ -154,7 +155,7 @@ public class Tablet {
       }
       default:
         throw new UnSupportedDataTypeException(
-            String.format("Data type %s is not supported.", 
measurementSchema.getType()));
+            String.format(NOT_SUPPORT_DATATYPE, measurementSchema.getType()));
     }
   }
 
@@ -203,7 +204,7 @@ public class Tablet {
         values[i] = new Binary[maxRowNumber];
         break;
       default:
-        throw new UnSupportedDataTypeException(String.format("Data type %s is 
not supported.", dataType));
+        throw new 
UnSupportedDataTypeException(String.format(NOT_SUPPORT_DATATYPE, dataType));
       }
     }
   }
@@ -245,7 +246,7 @@ public class Tablet {
         break;
       default:
         throw new UnSupportedDataTypeException(
-            String.format("Data type %s is not supported.", 
schemas.get(i).getType()));
+            String.format(NOT_SUPPORT_DATATYPE, schemas.get(i).getType()));
       }
     }
     return valueOccupation;
diff --git 
a/tsfile/src/test/java/org/apache/iotdb/tsfile/utils/RecordUtilsTest.java 
b/tsfile/src/test/java/org/apache/iotdb/tsfile/utils/RecordUtilsTest.java
index 1293c68..cfe17d5 100755
--- a/tsfile/src/test/java/org/apache/iotdb/tsfile/utils/RecordUtilsTest.java
+++ b/tsfile/src/test/java/org/apache/iotdb/tsfile/utils/RecordUtilsTest.java
@@ -66,36 +66,36 @@ public class RecordUtilsTest {
   public void testParseSimpleTupleRecordInt() {
     String testString = "d1,1471522347000,s1,1";
     TSRecord record = RecordUtils.parseSimpleTupleRecord(testString, schema);
-    assertEquals(record.time, 1471522347000l);
-    assertEquals(record.deviceId, "d1");
+    assertEquals(1471522347000l, record.time);
+    assertEquals("d1", record.deviceId);
     List<DataPoint> tuples = record.dataPointList;
     assertEquals(1, tuples.size());
     DataPoint tuple = tuples.get(0);
-    assertEquals(tuple.getMeasurementId(), "s1");
-    assertEquals(tuple.getType(), TSDataType.INT32);
-    assertEquals(tuple.getValue(), 1);
+    assertEquals("s1", tuple.getMeasurementId());
+    assertEquals(TSDataType.INT32, tuple.getType());
+    assertEquals(1, tuple.getValue());
 
     testString = "d1,1471522347000,s1,1,";
     record = RecordUtils.parseSimpleTupleRecord(testString, schema);
-    assertEquals(record.time, 1471522347000l);
-    assertEquals(record.deviceId, "d1");
+    assertEquals(1471522347000l, record.time);
+    assertEquals("d1", record.deviceId);
     tuples = record.dataPointList;
     assertEquals(1, tuples.size());
     tuple = tuples.get(0);
-    assertEquals(tuple.getMeasurementId(), "s1");
-    assertEquals(tuple.getType(), TSDataType.INT32);
-    assertEquals(tuple.getValue(), 1);
+    assertEquals("s1", tuple.getMeasurementId());
+    assertEquals(TSDataType.INT32, tuple.getType());
+    assertEquals(1, tuple.getValue());
 
     testString = "d1,1471522347000,s1,1,s2";
     record = RecordUtils.parseSimpleTupleRecord(testString, schema);
-    assertEquals(record.time, 1471522347000l);
-    assertEquals(record.deviceId, "d1");
+    assertEquals(1471522347000l, record.time);
+    assertEquals("d1", record.deviceId);
     tuples = record.dataPointList;
     assertEquals(1, tuples.size());
     tuple = tuples.get(0);
-    assertEquals(tuple.getMeasurementId(), "s1");
-    assertEquals(tuple.getType(), TSDataType.INT32);
-    assertEquals(tuple.getValue(), 1);
+    assertEquals("s1", tuple.getMeasurementId());
+    assertEquals(TSDataType.INT32, tuple.getType());
+    assertEquals(1, tuple.getValue());
 
   }
 
@@ -103,81 +103,81 @@ public class RecordUtilsTest {
   public void testParseSimpleTupleRecordNull() {
     String testString = "d1,1471522347000,s1,1,s2,,s3,";
     TSRecord record = RecordUtils.parseSimpleTupleRecord(testString, schema);
-    assertEquals(record.time, 1471522347000l);
+    assertEquals(1471522347000l, record.time);
     List<DataPoint> tuples = record.dataPointList;
-    assertEquals(tuples.size(), 1);
+    assertEquals(1, tuples.size());
     DataPoint tuple = tuples.get(0);
-    assertEquals(tuple.getMeasurementId(), "s1");
-    assertEquals(tuple.getType(), TSDataType.INT32);
-    assertEquals(tuple.getValue(), 1);
+    assertEquals("s1", tuple.getMeasurementId());
+    assertEquals(TSDataType.INT32, tuple.getType());
+    assertEquals(1, tuple.getValue());
   }
 
   @Test
   public void testParseSimpleTupleRecordAll() {
     String testString = 
"d1,1471522347000,s1,1,s2,134134287192587,s3,1.4,s4,1.128794817,s5,true";
     TSRecord record = RecordUtils.parseSimpleTupleRecord(testString, schema);
-    assertEquals(record.time, 1471522347000l);
-    assertEquals(record.deviceId, "d1");
+    assertEquals(1471522347000l, record.time);
+    assertEquals("d1", record.deviceId);
     List<DataPoint> tuples = record.dataPointList;
     assertEquals(5, tuples.size());// enum type is omitted.
     DataPoint tuple = tuples.get(0);
-    assertEquals(tuple.getMeasurementId(), "s1");
-    assertEquals(tuple.getType(), TSDataType.INT32);
-    assertEquals(tuple.getValue(), 1);
+    assertEquals("s1", tuple.getMeasurementId());
+    assertEquals(TSDataType.INT32, tuple.getType());
+    assertEquals(1, tuple.getValue());
     tuple = tuples.get(1);
-    assertEquals(tuple.getMeasurementId(), "s2");
-    assertEquals(tuple.getType(), TSDataType.INT64);
-    assertEquals(tuple.getValue(), 134134287192587l);
+    assertEquals("s2", tuple.getMeasurementId());
+    assertEquals(TSDataType.INT64, tuple.getType());
+    assertEquals(134134287192587l, tuple.getValue());
     tuple = tuples.get(2);
-    assertEquals(tuple.getMeasurementId(), "s3");
-    assertEquals(tuple.getType(), TSDataType.FLOAT);
-    assertEquals(tuple.getValue(), 1.4f);
+    assertEquals("s3", tuple.getMeasurementId());
+    assertEquals(TSDataType.FLOAT, tuple.getType());
+    assertEquals(1.4f, tuple.getValue());
     tuple = tuples.get(3);
-    assertEquals(tuple.getMeasurementId(), "s4");
-    assertEquals(tuple.getType(), TSDataType.DOUBLE);
-    assertEquals(tuple.getValue(), 1.128794817d);
+    assertEquals("s4", tuple.getMeasurementId());
+    assertEquals(TSDataType.DOUBLE, tuple.getType());
+    assertEquals(1.128794817d, tuple.getValue());
     tuple = tuples.get(4);
-    assertEquals(tuple.getMeasurementId(), "s5");
-    assertEquals(tuple.getType(), TSDataType.BOOLEAN);
-    assertEquals(tuple.getValue(), true);
+    assertEquals("s5", tuple.getMeasurementId());
+    assertEquals(TSDataType.BOOLEAN, tuple.getType());
+    assertEquals(true, tuple.getValue());
   }
 
   @Test
   public void testError() {
     String testString = "d1,1471522347000,s1,1,s2,s123";
     TSRecord record = RecordUtils.parseSimpleTupleRecord(testString, schema);
-    assertEquals(record.time, 1471522347000l);
+    assertEquals(1471522347000l, record.time);
     List<DataPoint> tuples = record.dataPointList;
-    assertEquals(tuples.size(), 1);
+    assertEquals(1, tuples.size());
     DataPoint tuple = tuples.get(0);
-    assertEquals(tuple.getMeasurementId(), "s1");
-    assertEquals(tuple.getType(), TSDataType.INT32);
-    assertEquals(tuple.getValue(), 1);
+    assertEquals("s1", tuple.getMeasurementId());
+    assertEquals(TSDataType.INT32, tuple.getType());
+    assertEquals(1, tuple.getValue());
   }
 
   @Test
   public void testErrorMeasurementAndTimeStamp() {
     String testString = "d1,1471522347000,s1,1,s123,1";
     TSRecord record = RecordUtils.parseSimpleTupleRecord(testString, schema);
-    assertEquals(record.time, 1471522347000l);
+    assertEquals(1471522347000l, record.time);
     List<DataPoint> tuples = record.dataPointList;
-    assertEquals(tuples.size(), 1);
+    assertEquals(1, tuples.size());
     DataPoint tuple = tuples.get(0);
-    assertEquals(tuple.getMeasurementId(), "s1");
-    assertEquals(tuple.getType(), TSDataType.INT32);
-    assertEquals(tuple.getValue(), 1);
+    assertEquals("s1", tuple.getMeasurementId());
+    assertEquals(TSDataType.INT32, tuple.getType());
+    assertEquals(1, tuple.getValue());
 
     testString = "d1,1dsjhk,s1,1,s123,1";
     record = RecordUtils.parseSimpleTupleRecord(testString, schema);
     assertEquals(record.time, -1);
     tuples = record.dataPointList;
-    assertEquals(tuples.size(), 0);
+    assertEquals(0, tuples.size());
 
     testString = "d1,1471522347000,s8,1";
     record = RecordUtils.parseSimpleTupleRecord(testString, schema);
-    assertEquals(record.time, 1471522347000l);
+    assertEquals(1471522347000l, record.time);
     tuples = record.dataPointList;
-    assertEquals(tuples.size(), 0);
+    assertEquals(0, tuples.size());
 
   }
 

Reply via email to