From 980abbd4f359373ce7a11a3405c99ab9a9e850ce Mon Sep 17 00:00:00 2001 From: CritasWang Date: Fri, 9 May 2025 10:25:40 +0800 Subject: [PATCH] style: change spotless like iotdb --- .../iotdb/hadoop/tsfile/TSFInputFormat.java | 6 ++ .../iotdb/hadoop/tsfile/TSFRecordReader.java | 2 + .../hadoop/tsfile/record/HDFSTSRecord.java | 2 + .../iotdb/hive/TSFHiveRecordReader.java | 2 + examples/iotdb-spring-boot-start/pom.xml | 29 +++++++++ .../IoTDBSpringBootStartApplication.java | 7 +-- .../service/IoTDBService.java | 59 +++++++++---------- .../SpringBootIoTDBApplicationTests.java | 18 +++--- .../iotdb/pulsar/PulsarConsumerThread.java | 1 + pom.xml | 31 +++------- 10 files changed, 91 insertions(+), 66 deletions(-) diff --git a/connectors/hadoop/src/main/java/org/apache/iotdb/hadoop/tsfile/TSFInputFormat.java b/connectors/hadoop/src/main/java/org/apache/iotdb/hadoop/tsfile/TSFInputFormat.java index f38cc084..a943db90 100644 --- a/connectors/hadoop/src/main/java/org/apache/iotdb/hadoop/tsfile/TSFInputFormat.java +++ b/connectors/hadoop/src/main/java/org/apache/iotdb/hadoop/tsfile/TSFInputFormat.java @@ -47,16 +47,22 @@ public class TSFInputFormat extends FileInputFormat { /** key to configure whether reading time enable */ public static final String READ_TIME_ENABLE = "tsfile.read.time.enable"; + /** key to configure whether reading deltaObjectId enable */ public static final String READ_DELTAOBJECT_ENABLE = "tsfile.read.deltaObjectId.enable"; + /** key to configure the type of filter */ @Deprecated public static final String FILTER_TYPE = "tsfile.filter.type"; + /** key to configure the filter */ @Deprecated public static final String FILTER_EXPRESSION = "tsfile.filter.expression"; + /** key to configure whether filtering is enable */ public static final String FILTER_EXIST = "tsfile.filter.exist"; + /** key to configure the reading deltaObjectIds */ public static final String READ_DELTAOBJECTS = "tsfile.read.deltaobject"; + /** key to configure the reading measurementIds */ public static final String READ_MEASUREMENTID = "tsfile.read.measurement"; diff --git a/connectors/hadoop/src/main/java/org/apache/iotdb/hadoop/tsfile/TSFRecordReader.java b/connectors/hadoop/src/main/java/org/apache/iotdb/hadoop/tsfile/TSFRecordReader.java index 49bcf864..ab21d06b 100644 --- a/connectors/hadoop/src/main/java/org/apache/iotdb/hadoop/tsfile/TSFRecordReader.java +++ b/connectors/hadoop/src/main/java/org/apache/iotdb/hadoop/tsfile/TSFRecordReader.java @@ -55,6 +55,7 @@ public class TSFRecordReader extends RecordReader imp /** all */ private List dataSetList = new ArrayList<>(); + /** * List for name of devices. The order corresponds to the order of dataSetList. Means that * deviceIdList[i] is the name of device for dataSetList[i]. @@ -62,6 +63,7 @@ public class TSFRecordReader extends RecordReader imp private List deviceIdList = new ArrayList<>(); private List fields = null; + /** The index of QueryDataSet that is currently processed */ private int currentIndex = 0; diff --git a/connectors/hadoop/src/main/java/org/apache/iotdb/hadoop/tsfile/record/HDFSTSRecord.java b/connectors/hadoop/src/main/java/org/apache/iotdb/hadoop/tsfile/record/HDFSTSRecord.java index cdf97967..ffa49c42 100644 --- a/connectors/hadoop/src/main/java/org/apache/iotdb/hadoop/tsfile/record/HDFSTSRecord.java +++ b/connectors/hadoop/src/main/java/org/apache/iotdb/hadoop/tsfile/record/HDFSTSRecord.java @@ -43,8 +43,10 @@ public class HDFSTSRecord implements Writable { /** timestamp of this TSRecord. */ private long time; + /** deviceId of this TSRecord. */ private String deviceId; + /** all value of this TSRecord. */ private List dataPointList = new ArrayList<>(); diff --git a/connectors/hive-connector/src/main/java/org/apache/iotdb/hive/TSFHiveRecordReader.java b/connectors/hive-connector/src/main/java/org/apache/iotdb/hive/TSFHiveRecordReader.java index b99869bc..9603318e 100644 --- a/connectors/hive-connector/src/main/java/org/apache/iotdb/hive/TSFHiveRecordReader.java +++ b/connectors/hive-connector/src/main/java/org/apache/iotdb/hive/TSFHiveRecordReader.java @@ -47,11 +47,13 @@ public class TSFHiveRecordReader implements RecordReader dataSetList = new ArrayList<>(); + /** * List for name of devices. The order corresponds to the order of dataSetList. Means that * deviceIdList[i] is the name of device for dataSetList[i]. */ private List deviceIdList = new ArrayList<>(); + /** The index of QueryDataSet that is currently processed */ private int currentIndex = 0; diff --git a/examples/iotdb-spring-boot-start/pom.xml b/examples/iotdb-spring-boot-start/pom.xml index 8090af8a..71efaf02 100644 --- a/examples/iotdb-spring-boot-start/pom.xml +++ b/examples/iotdb-spring-boot-start/pom.xml @@ -37,6 +37,8 @@ 17 3.4.5 6.2.6 + 1.22.0 + 2.43.0 @@ -60,6 +62,33 @@ org.springframework.boot spring-boot-maven-plugin + + com.diffplug.spotless + spotless-maven-plugin + ${spotless.version} + + + + ${google.java.format.version} + + + + org.apache.iotdb,,javax,java,\# + + + + UNIX + + + + spotless-check + + check + + validate + + + diff --git a/examples/iotdb-spring-boot-start/src/main/java/org/apache/iotdb/iotdbspringbootstartexample/IoTDBSpringBootStartApplication.java b/examples/iotdb-spring-boot-start/src/main/java/org/apache/iotdb/iotdbspringbootstartexample/IoTDBSpringBootStartApplication.java index 367fe3a4..1df0b0bd 100644 --- a/examples/iotdb-spring-boot-start/src/main/java/org/apache/iotdb/iotdbspringbootstartexample/IoTDBSpringBootStartApplication.java +++ b/examples/iotdb-spring-boot-start/src/main/java/org/apache/iotdb/iotdbspringbootstartexample/IoTDBSpringBootStartApplication.java @@ -23,8 +23,7 @@ @SpringBootApplication public class IoTDBSpringBootStartApplication { - public static void main(String[] args) { - SpringApplication.run(IoTDBSpringBootStartApplication.class, args); - } - + public static void main(String[] args) { + SpringApplication.run(IoTDBSpringBootStartApplication.class, args); + } } diff --git a/examples/iotdb-spring-boot-start/src/main/java/org/apache/iotdb/iotdbspringbootstartexample/service/IoTDBService.java b/examples/iotdb-spring-boot-start/src/main/java/org/apache/iotdb/iotdbspringbootstartexample/service/IoTDBService.java index 1fe51abc..f749e885 100644 --- a/examples/iotdb-spring-boot-start/src/main/java/org/apache/iotdb/iotdbspringbootstartexample/service/IoTDBService.java +++ b/examples/iotdb-spring-boot-start/src/main/java/org/apache/iotdb/iotdbspringbootstartexample/service/IoTDBService.java @@ -24,7 +24,7 @@ import org.apache.iotdb.isession.pool.SessionDataSetWrapper; import org.apache.iotdb.rpc.IoTDBConnectionException; import org.apache.iotdb.rpc.StatementExecutionException; -import org.apache.iotdb.session.pool.SessionPool; + import org.apache.tsfile.read.common.Field; import org.apache.tsfile.read.common.RowRecord; import org.springframework.beans.factory.annotation.Autowired; @@ -35,38 +35,37 @@ @Service public class IoTDBService { - @Autowired - private ITableSessionPool ioTDBSessionPool; - - @Autowired - private ISessionPool sessionPool; + @Autowired private ITableSessionPool ioTDBSessionPool; + @Autowired private ISessionPool sessionPool; - public void queryTableSessionPool() throws IoTDBConnectionException, StatementExecutionException { - ITableSession tableSession = ioTDBSessionPool.getSession(); - final SessionDataSet sessionDataSet = tableSession.executeQueryStatement("select * from power_data_set limit 10"); - while (sessionDataSet.hasNext()) { - final RowRecord rowRecord = sessionDataSet.next(); - final List fields = rowRecord.getFields(); - for (Field field : fields) { - System.out.print(field.getStringValue()); - } - System.out.println(); - } - sessionDataSet.close(); - tableSession.close(); + public void queryTableSessionPool() throws IoTDBConnectionException, StatementExecutionException { + ITableSession tableSession = ioTDBSessionPool.getSession(); + final SessionDataSet sessionDataSet = + tableSession.executeQueryStatement("select * from power_data_set limit 10"); + while (sessionDataSet.hasNext()) { + final RowRecord rowRecord = sessionDataSet.next(); + final List fields = rowRecord.getFields(); + for (Field field : fields) { + System.out.print(field.getStringValue()); + } + System.out.println(); } + sessionDataSet.close(); + tableSession.close(); + } - public void querySessionPool() throws IoTDBConnectionException, StatementExecutionException { - final SessionDataSetWrapper sessionDataSetWrapper = sessionPool.executeQueryStatement("show databases"); - while (sessionDataSetWrapper.hasNext()) { - final RowRecord rowRecord = sessionDataSetWrapper.next(); - final List fields = rowRecord.getFields(); - for (Field field : fields) { - System.out.print(field.getStringValue()); - } - System.out.println(); - } - sessionDataSetWrapper.close(); + public void querySessionPool() throws IoTDBConnectionException, StatementExecutionException { + final SessionDataSetWrapper sessionDataSetWrapper = + sessionPool.executeQueryStatement("show databases"); + while (sessionDataSetWrapper.hasNext()) { + final RowRecord rowRecord = sessionDataSetWrapper.next(); + final List fields = rowRecord.getFields(); + for (Field field : fields) { + System.out.print(field.getStringValue()); + } + System.out.println(); } + sessionDataSetWrapper.close(); + } } diff --git a/examples/iotdb-spring-boot-start/src/test/java/org/apache/iotdb/iotdbspringbootstartexample/SpringBootIoTDBApplicationTests.java b/examples/iotdb-spring-boot-start/src/test/java/org/apache/iotdb/iotdbspringbootstartexample/SpringBootIoTDBApplicationTests.java index d5ec0d99..d0048548 100644 --- a/examples/iotdb-spring-boot-start/src/test/java/org/apache/iotdb/iotdbspringbootstartexample/SpringBootIoTDBApplicationTests.java +++ b/examples/iotdb-spring-boot-start/src/test/java/org/apache/iotdb/iotdbspringbootstartexample/SpringBootIoTDBApplicationTests.java @@ -20,20 +20,18 @@ import org.apache.iotdb.iotdbspringbootstartexample.service.IoTDBService; import org.apache.iotdb.rpc.IoTDBConnectionException; import org.apache.iotdb.rpc.StatementExecutionException; -import org.junit.jupiter.api.Test; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; @SpringBootTest public class SpringBootIoTDBApplicationTests { - @Autowired - private IoTDBService iotdbService; - - // @Test - void contextLoads() throws IoTDBConnectionException, StatementExecutionException { - iotdbService.querySessionPool(); - iotdbService.queryTableSessionPool(); - } + @Autowired private IoTDBService iotdbService; -} \ No newline at end of file + // @Test + void contextLoads() throws IoTDBConnectionException, StatementExecutionException { + iotdbService.querySessionPool(); + iotdbService.queryTableSessionPool(); + } +} diff --git a/examples/pulsar/src/main/java/org/apache/iotdb/pulsar/PulsarConsumerThread.java b/examples/pulsar/src/main/java/org/apache/iotdb/pulsar/PulsarConsumerThread.java index fce2baa9..a504654b 100644 --- a/examples/pulsar/src/main/java/org/apache/iotdb/pulsar/PulsarConsumerThread.java +++ b/examples/pulsar/src/main/java/org/apache/iotdb/pulsar/PulsarConsumerThread.java @@ -47,6 +47,7 @@ public PulsarConsumerThread(Consumer consumer) throws ClassNotFoundException this.consumer = consumer; Class.forName("org.apache.iotdb.jdbc.IoTDBDriver"); } + /** insert data to IoTDB */ private void insert(String data) throws IoTDBConnectionException, StatementExecutionException { String[] dataArray = data.split(","); diff --git a/pom.xml b/pom.xml index 60c940a8..06acb417 100644 --- a/pom.xml +++ b/pom.xml @@ -78,8 +78,7 @@ 3.8.1-17.0 1.17.1 1.16 - - 1.7 + 1.22.0 2.10.1 32.1.2-jre 3.3.6 @@ -165,8 +164,7 @@ 3.5.0 false - - 2.27.1 + 2.43.0 2.7.18 @@ -2025,18 +2023,17 @@ 8 - + - .java-11-and-above + .java-11-below - [11,) + (,11] - - 1.7 + + 2.27.1 + + true - - .java-21-and-above - - [21,) - - - true - - with-springboot