You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by GitBox <gi...@apache.org> on 2021/02/18 05:41:33 UTC

[GitHub] [iotdb] liutaohua commented on a change in pull request #2684: [IOTDB-1156] Improve the quality and efficiency of code formatting

liutaohua commented on a change in pull request #2684:
URL: https://github.com/apache/iotdb/pull/2684#discussion_r578103765



##########
File path: tsfile/src/main/java/org/apache/iotdb/tsfile/write/record/datapoint/IntDataPoint.java
##########
@@ -32,12 +34,10 @@
 public class IntDataPoint extends DataPoint {
 
   private static final Logger LOG = LoggerFactory.getLogger(IntDataPoint.class);
-  /** actual value. **/
+  /** actual value. * */

Review comment:
       redundant `*`

##########
File path: tsfile/src/main/java/org/apache/iotdb/tsfile/write/record/datapoint/FloatDataPoint.java
##########
@@ -32,12 +34,10 @@
 public class FloatDataPoint extends DataPoint {
 
   private static final Logger LOG = LoggerFactory.getLogger(FloatDataPoint.class);
-  /** actual value. **/
+  /** actual value. * */

Review comment:
       redundant `*`

##########
File path: pom.xml
##########
@@ -598,6 +599,34 @@
                         </excludes>
                     </configuration>
                 </plugin>
+                <plugin>
+                    <groupId>com.diffplug.spotless</groupId>
+                    <artifactId>spotless-maven-plugin</artifactId>
+                    <version>${spotless.version}</version>
+                    <configuration>
+                        <java>
+                            <googleJavaFormat>
+                                <version>1.7</version>
+                                <style>GOOGLE</style>
+                            </googleJavaFormat>
+
+                            <importOrder>
+                                <order>org.apache.iotdb,,javax,java,\#</order>

Review comment:
       why double `,`  , typo ?

##########
File path: server/src/main/java/org/apache/iotdb/db/qp/physical/crud/AlignByDevicePlan.java
##########
@@ -18,18 +18,21 @@
  */
 package org.apache.iotdb.db.qp.physical.crud;
 
-import java.util.List;
-import java.util.Map;
 import org.apache.iotdb.db.metadata.PartialPath;
 import org.apache.iotdb.db.qp.logical.Operator;
 import org.apache.iotdb.db.qp.logical.Operator.OperatorType;
 import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
 import org.apache.iotdb.tsfile.read.expression.IExpression;
 
+import java.util.List;
+import java.util.Map;
+
 public class AlignByDevicePlan extends QueryPlan {
 
-  private List<String> measurements; // to record result measurement columns, e.g. temperature, status, speed
-  private Map<String, String> measurementAliasMap; // select s1, s2 as speed from root, then s2 -> speed
+  private List<String>
+      measurements; // to record result measurement columns, e.g. temperature, status, speed
+  private Map<String, String>

Review comment:
       Don't use end-of-line comments?

##########
File path: session/src/main/java/org/apache/iotdb/session/pool/SessionPool.java
##########
@@ -328,16 +388,12 @@ public void insertTablet(Tablet tablet)
 
   /**
    * insert the data of a device. For each timestamp, the number of measurements is the same.
-   * <p>
-   * a Tablet example:
    *
-   *      device1

Review comment:
       same

##########
File path: tsfile/src/main/java/org/apache/iotdb/tsfile/utils/Murmur128Hash.java
##########
@@ -44,25 +44,29 @@ public static int hash(String value, int seed) {
    * @return hashcode of value
    */
   public static int hash(String value1, long value2, int seed) {
-    return (int) innerHash(
-        BytesUtils.concatByteArray(value1.getBytes(), BytesUtils.longToBytes(value2)), 0,
-        value1.length() + 8, seed);
+    return (int)
+        innerHash(
+            BytesUtils.concatByteArray(value1.getBytes(), BytesUtils.longToBytes(value2)),
+            0,
+            value1.length() + 8,
+            seed);
   }
 
-  /**************************************
-   * Methods to perform murmur 128 hash.
-   **************************************/
+  /**
+   * ************************************ Methods to perform murmur 128 hash.

Review comment:
       redundant `*`

##########
File path: example/udf/src/main/java/org/apache/iotdb/udf/UDTFExample.java
##########
@@ -1,56 +1,54 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.iotdb.udf;
-
-import java.io.IOException;
-import org.apache.iotdb.db.query.udf.api.UDTF;
-import org.apache.iotdb.db.query.udf.api.access.Row;
-import org.apache.iotdb.db.query.udf.api.collector.PointCollector;
-import org.apache.iotdb.db.query.udf.api.customizer.config.UDTFConfigurations;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameters;
-import org.apache.iotdb.db.query.udf.api.customizer.strategy.RowByRowAccessStrategy;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
-
-/**
- * SET STORAGE GROUP TO root.sg1;
- * CREATE TIMESERIES root.sg1.d1.s1 WITH DATATYPE=INT32, ENCODING=PLAIN;
- * CREATE TIMESERIES root.sg1.d1.s2 WITH DATATYPE=INT32, ENCODING=PLAIN;
- * INSERT INTO root.sg1.d1(timestamp, s1, s2) VALUES (0, -1, 1);
- * INSERT INTO root.sg1.d1(timestamp, s1, s2) VALUES (1, -2, 2);
- * INSERT INTO root.sg1.d1(timestamp, s1, s2) VALUES (2, -3, 3);
- *
- * CREATE FUNCTION example AS "org.apache.iotdb.udf.UDTFExample";
- * SHOW FUNCTIONS;
- * SELECT s1, example(s1), s2, example(s2) FROM root.sg1.d1;
- */
-public class UDTFExample implements UDTF {
-
-  @Override
-  public void beforeStart(UDFParameters parameters, UDTFConfigurations configurations) {
-    configurations
-        .setAccessStrategy(new RowByRowAccessStrategy())
-        .setOutputDataType(TSDataType.INT32);
-  }
-
-  @Override
-  public void transform(Row row, PointCollector collector) throws IOException {
-    collector.putInt(row.getTime(), -row.getInt(0));
-  }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.udf;
+
+import org.apache.iotdb.db.query.udf.api.UDTF;
+import org.apache.iotdb.db.query.udf.api.access.Row;
+import org.apache.iotdb.db.query.udf.api.collector.PointCollector;
+import org.apache.iotdb.db.query.udf.api.customizer.config.UDTFConfigurations;
+import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameters;
+import org.apache.iotdb.db.query.udf.api.customizer.strategy.RowByRowAccessStrategy;
+import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+
+import java.io.IOException;
+
+/**

Review comment:
       `/*`

##########
File path: session/src/main/java/org/apache/iotdb/session/pool/SessionPool.java
##########
@@ -289,35 +351,33 @@ private void closeSession(Session session) {
       try {
         session.close();
       } catch (Exception e2) {
-        //do nothing. We just want to guarantee the session is closed.
+        // do nothing. We just want to guarantee the session is closed.
         logger.warn(CLOSE_THE_SESSION_FAILED, e2);
       }
     }
   }
 
-  private void cleanSessionAndMayThrowConnectionException(Session session, int times,
-      IoTDBConnectionException e) throws IoTDBConnectionException {
+  private void cleanSessionAndMayThrowConnectionException(
+      Session session, int times, IoTDBConnectionException e) throws IoTDBConnectionException {
     closeSession(session);
     removeSession();
     if (times == FINAL_RETRY) {
       throw new IoTDBConnectionException(
-          String.format("retry to execute statement on %s:%s failed %d times: %s", ip, port,
-              RETRY, e.getMessage()), e);
+          String.format(
+              "retry to execute statement on %s:%s failed %d times: %s",
+              ip, port, RETRY, e.getMessage()),
+          e);
     }
   }
 
   /**
    * insert the data of a device. For each timestamp, the number of measurements is the same.
    *
-   *  a Tablet example:
+   * <p>a Tablet example:
    *
-   *        device1

Review comment:
       use `/*` to show

##########
File path: example/session/src/main/java/org/apache/iotdb/SessionExample.java
##########
@@ -257,15 +270,11 @@ private static void insertRecords() throws IoTDBConnectionException, StatementEx
   /**
    * insert the data of a device. For each timestamp, the number of measurements is the same.
    *
-   * a Tablet example:
+   * <p>a Tablet example:
    *
-   *      device1

Review comment:
       use `/*` to show

##########
File path: example/udf/pom.xml
##########
@@ -60,6 +60,34 @@
                     </execution>
                 </executions>
             </plugin>
+            <plugin>
+                <groupId>com.diffplug.spotless</groupId>
+                <artifactId>spotless-maven-plugin</artifactId>
+                <version>2.4.2</version>
+                <configuration>
+                    <java>
+                        <googleJavaFormat>
+                            <version>1.7</version>
+                            <style>GOOGLE</style>
+                        </googleJavaFormat>
+
+                        <importOrder>
+                            <order>org.apache.iotdb,,javax,java,\#</order>

Review comment:
       why need two `,` here?  typo?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org