jixuan1989 commented on a change in pull request #34: fix sonar 
URL: https://github.com/apache/incubator-iotdb/pull/34#discussion_r251862548
 
 

 ##########
 File path: 
tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/TSEncodingBuilder.java
 ##########
 @@ -105,24 +101,51 @@ public Encoder getEncoder(TSDataType type) {
     public void initFromProps(Map<String, String> props) {
       // set max error from initialized map or default value if not set
       if (props == null || !props.containsKey(Encoder.MAX_STRING_LENGTH)) {
-        maxStringLength = conf.maxStringLength;
+        maxStringLength = TSFileConfig.maxStringLength;
       } else {
         maxStringLength = 
Integer.valueOf(props.get(Encoder.MAX_STRING_LENGTH));
         if (maxStringLength < 0) {
-          maxStringLength = conf.maxStringLength;
+          maxStringLength = TSFileConfig.maxStringLength;
           LOG.warn("cannot set max string length to negative value, replaced 
with default value:{}",
               maxStringLength);
         }
       }
     }
   }
 
+  private static abstract class rleAndTs2diffCommon extends TSEncodingBuilder {
+
+    protected int maxPointNumber;
+
+    @Override
+    /**
+     * Both RLE and TS_2DIFF could specify <b>max_point_number</b> in given 
JSON Object, which means the maximum
+     * decimal digits for float or double data.
+     */
+    public void initFromProps(Map<String, String> props) {
+      // set max error from initialized map or default value if not set
+      if (props == null || !props.containsKey(Encoder.MAX_POINT_NUMBER)) {
+        maxPointNumber = TSFileConfig.floatPrecision;
+      } else {
+        maxPointNumber = Integer.valueOf(props.get(Encoder.MAX_POINT_NUMBER));
+        if (maxPointNumber < 0) {
+          maxPointNumber = TSFileConfig.floatPrecision;
+          LOG.warn("cannot set max point number to negative value, replaced 
with default value:{}",
+              maxPointNumber);
+        }
+      }
+    }
+
+  }
+
   /**
    * for ENUMS, INT32, BOOLEAN, INT64, FLOAT, DOUBLE.
    */
-  public static class RLE extends TSEncodingBuilder {
+  public static class RLE extends rleAndTs2diffCommon {
 
 Review comment:
   I know you want to eliminate the duplicate codes of `public void 
initFromProps(Map<String, String> props)`, so you add a new Class 
`rleAndTs2diffCommon` which can set the `maxPointNumber` field. 
   Actually, you can add new new function in `TSEncodingBuilder`, called 
`public int getMaxPointNumber(Map<String, String> props)`, then you will remove 
the duplicate codes in the two subclasses and do not need to add the new class.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to