Skip to content

Commit 3e48d26

Browse files
authored
style: change spotless like iotdb (#70)
1 parent 45cdf6c commit 3e48d26

File tree

10 files changed

+91
-66
lines changed

10 files changed

+91
-66
lines changed

connectors/hadoop/src/main/java/org/apache/iotdb/hadoop/tsfile/TSFInputFormat.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,22 @@ public class TSFInputFormat extends FileInputFormat<NullWritable, MapWritable> {
4747

4848
/** key to configure whether reading time enable */
4949
public static final String READ_TIME_ENABLE = "tsfile.read.time.enable";
50+
5051
/** key to configure whether reading deltaObjectId enable */
5152
public static final String READ_DELTAOBJECT_ENABLE = "tsfile.read.deltaObjectId.enable";
53+
5254
/** key to configure the type of filter */
5355
@Deprecated public static final String FILTER_TYPE = "tsfile.filter.type";
56+
5457
/** key to configure the filter */
5558
@Deprecated public static final String FILTER_EXPRESSION = "tsfile.filter.expression";
59+
5660
/** key to configure whether filtering is enable */
5761
public static final String FILTER_EXIST = "tsfile.filter.exist";
62+
5863
/** key to configure the reading deltaObjectIds */
5964
public static final String READ_DELTAOBJECTS = "tsfile.read.deltaobject";
65+
6066
/** key to configure the reading measurementIds */
6167
public static final String READ_MEASUREMENTID = "tsfile.read.measurement";
6268

connectors/hadoop/src/main/java/org/apache/iotdb/hadoop/tsfile/TSFRecordReader.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,15 @@ public class TSFRecordReader extends RecordReader<NullWritable, MapWritable> imp
5555

5656
/** all */
5757
private List<QueryDataSet> dataSetList = new ArrayList<>();
58+
5859
/**
5960
* List for name of devices. The order corresponds to the order of dataSetList. Means that
6061
* deviceIdList[i] is the name of device for dataSetList[i].
6162
*/
6263
private List<String> deviceIdList = new ArrayList<>();
6364

6465
private List<Field> fields = null;
66+
6567
/** The index of QueryDataSet that is currently processed */
6668
private int currentIndex = 0;
6769

connectors/hadoop/src/main/java/org/apache/iotdb/hadoop/tsfile/record/HDFSTSRecord.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,10 @@ public class HDFSTSRecord implements Writable {
4343

4444
/** timestamp of this TSRecord. */
4545
private long time;
46+
4647
/** deviceId of this TSRecord. */
4748
private String deviceId;
49+
4850
/** all value of this TSRecord. */
4951
private List<DataPoint> dataPointList = new ArrayList<>();
5052

connectors/hive-connector/src/main/java/org/apache/iotdb/hive/TSFHiveRecordReader.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,13 @@ public class TSFHiveRecordReader implements RecordReader<NullWritable, MapWritab
4747

4848
/** all datasets corresponding to one specific split */
4949
private List<QueryDataSet> dataSetList = new ArrayList<>();
50+
5051
/**
5152
* List for name of devices. The order corresponds to the order of dataSetList. Means that
5253
* deviceIdList[i] is the name of device for dataSetList[i].
5354
*/
5455
private List<String> deviceIdList = new ArrayList<>();
56+
5557
/** The index of QueryDataSet that is currently processed */
5658
private int currentIndex = 0;
5759

examples/iotdb-spring-boot-start/pom.xml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
<java.version>17</java.version>
3838
<spring-boot.version>3.4.5</spring-boot.version>
3939
<spring.version>6.2.6</spring.version>
40+
<google.java.format.version>1.22.0</google.java.format.version>
41+
<spotless.version>2.43.0</spotless.version>
4042
</properties>
4143
<dependencies>
4244
<dependency>
@@ -60,6 +62,33 @@
6062
<groupId>org.springframework.boot</groupId>
6163
<artifactId>spring-boot-maven-plugin</artifactId>
6264
</plugin>
65+
<plugin>
66+
<groupId>com.diffplug.spotless</groupId>
67+
<artifactId>spotless-maven-plugin</artifactId>
68+
<version>${spotless.version}</version>
69+
<configuration>
70+
<java>
71+
<googleJavaFormat>
72+
<version>${google.java.format.version}</version>
73+
<style>GOOGLE</style>
74+
</googleJavaFormat>
75+
<importOrder>
76+
<order>org.apache.iotdb,,javax,java,\#</order>
77+
</importOrder>
78+
<removeUnusedImports/>
79+
</java>
80+
<lineEndings>UNIX</lineEndings>
81+
</configuration>
82+
<executions>
83+
<execution>
84+
<id>spotless-check</id>
85+
<goals>
86+
<goal>check</goal>
87+
</goals>
88+
<phase>validate</phase>
89+
</execution>
90+
</executions>
91+
</plugin>
6392
</plugins>
6493
</build>
6594
</project>

examples/iotdb-spring-boot-start/src/main/java/org/apache/iotdb/iotdbspringbootstartexample/IoTDBSpringBootStartApplication.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@
2323
@SpringBootApplication
2424
public class IoTDBSpringBootStartApplication {
2525

26-
public static void main(String[] args) {
27-
SpringApplication.run(IoTDBSpringBootStartApplication.class, args);
28-
}
29-
26+
public static void main(String[] args) {
27+
SpringApplication.run(IoTDBSpringBootStartApplication.class, args);
28+
}
3029
}

examples/iotdb-spring-boot-start/src/main/java/org/apache/iotdb/iotdbspringbootstartexample/service/IoTDBService.java

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import org.apache.iotdb.isession.pool.SessionDataSetWrapper;
2525
import org.apache.iotdb.rpc.IoTDBConnectionException;
2626
import org.apache.iotdb.rpc.StatementExecutionException;
27-
import org.apache.iotdb.session.pool.SessionPool;
27+
2828
import org.apache.tsfile.read.common.Field;
2929
import org.apache.tsfile.read.common.RowRecord;
3030
import org.springframework.beans.factory.annotation.Autowired;
@@ -35,38 +35,37 @@
3535
@Service
3636
public class IoTDBService {
3737

38-
@Autowired
39-
private ITableSessionPool ioTDBSessionPool;
40-
41-
@Autowired
42-
private ISessionPool sessionPool;
38+
@Autowired private ITableSessionPool ioTDBSessionPool;
4339

40+
@Autowired private ISessionPool sessionPool;
4441

45-
public void queryTableSessionPool() throws IoTDBConnectionException, StatementExecutionException {
46-
ITableSession tableSession = ioTDBSessionPool.getSession();
47-
final SessionDataSet sessionDataSet = tableSession.executeQueryStatement("select * from power_data_set limit 10");
48-
while (sessionDataSet.hasNext()) {
49-
final RowRecord rowRecord = sessionDataSet.next();
50-
final List<Field> fields = rowRecord.getFields();
51-
for (Field field : fields) {
52-
System.out.print(field.getStringValue());
53-
}
54-
System.out.println();
55-
}
56-
sessionDataSet.close();
57-
tableSession.close();
42+
public void queryTableSessionPool() throws IoTDBConnectionException, StatementExecutionException {
43+
ITableSession tableSession = ioTDBSessionPool.getSession();
44+
final SessionDataSet sessionDataSet =
45+
tableSession.executeQueryStatement("select * from power_data_set limit 10");
46+
while (sessionDataSet.hasNext()) {
47+
final RowRecord rowRecord = sessionDataSet.next();
48+
final List<Field> fields = rowRecord.getFields();
49+
for (Field field : fields) {
50+
System.out.print(field.getStringValue());
51+
}
52+
System.out.println();
5853
}
54+
sessionDataSet.close();
55+
tableSession.close();
56+
}
5957

60-
public void querySessionPool() throws IoTDBConnectionException, StatementExecutionException {
61-
final SessionDataSetWrapper sessionDataSetWrapper = sessionPool.executeQueryStatement("show databases");
62-
while (sessionDataSetWrapper.hasNext()) {
63-
final RowRecord rowRecord = sessionDataSetWrapper.next();
64-
final List<Field> fields = rowRecord.getFields();
65-
for (Field field : fields) {
66-
System.out.print(field.getStringValue());
67-
}
68-
System.out.println();
69-
}
70-
sessionDataSetWrapper.close();
58+
public void querySessionPool() throws IoTDBConnectionException, StatementExecutionException {
59+
final SessionDataSetWrapper sessionDataSetWrapper =
60+
sessionPool.executeQueryStatement("show databases");
61+
while (sessionDataSetWrapper.hasNext()) {
62+
final RowRecord rowRecord = sessionDataSetWrapper.next();
63+
final List<Field> fields = rowRecord.getFields();
64+
for (Field field : fields) {
65+
System.out.print(field.getStringValue());
66+
}
67+
System.out.println();
7168
}
69+
sessionDataSetWrapper.close();
70+
}
7271
}

examples/iotdb-spring-boot-start/src/test/java/org/apache/iotdb/iotdbspringbootstartexample/SpringBootIoTDBApplicationTests.java

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,18 @@
2020
import org.apache.iotdb.iotdbspringbootstartexample.service.IoTDBService;
2121
import org.apache.iotdb.rpc.IoTDBConnectionException;
2222
import org.apache.iotdb.rpc.StatementExecutionException;
23-
import org.junit.jupiter.api.Test;
23+
2424
import org.springframework.beans.factory.annotation.Autowired;
2525
import org.springframework.boot.test.context.SpringBootTest;
2626

2727
@SpringBootTest
2828
public class SpringBootIoTDBApplicationTests {
2929

30-
@Autowired
31-
private IoTDBService iotdbService;
32-
33-
// @Test
34-
void contextLoads() throws IoTDBConnectionException, StatementExecutionException {
35-
iotdbService.querySessionPool();
36-
iotdbService.queryTableSessionPool();
37-
}
30+
@Autowired private IoTDBService iotdbService;
3831

39-
}
32+
// @Test
33+
void contextLoads() throws IoTDBConnectionException, StatementExecutionException {
34+
iotdbService.querySessionPool();
35+
iotdbService.queryTableSessionPool();
36+
}
37+
}

examples/pulsar/src/main/java/org/apache/iotdb/pulsar/PulsarConsumerThread.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public PulsarConsumerThread(Consumer<?> consumer) throws ClassNotFoundException
4747
this.consumer = consumer;
4848
Class.forName("org.apache.iotdb.jdbc.IoTDBDriver");
4949
}
50+
5051
/** insert data to IoTDB */
5152
private void insert(String data) throws IoTDBConnectionException, StatementExecutionException {
5253
String[] dataArray = data.split(",");

pom.xml

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,7 @@
7878
<flink-shaded-zookeeper-3.version>3.8.1-17.0</flink-shaded-zookeeper-3.version>
7979
<flink.version>1.17.1</flink.version>
8080
<fusesource-mqtt-client.version>1.16</fusesource-mqtt-client.version>
81-
<!-- JDK1.8 only support google java format 1.7-->
82-
<google.java.format.version>1.7</google.java.format.version>
81+
<google.java.format.version>1.22.0</google.java.format.version>
8382
<gson.version>2.10.1</gson.version>
8483
<guava.version>32.1.2-jre</guava.version>
8584
<hadoop.version>3.3.6</hadoop.version>
@@ -165,8 +164,7 @@
165164
<spark-scala.2.12.version>3.5.0</spark-scala.2.12.version>
166165
<!-- Override this to `true`, if you want to disable spotless -->
167166
<spotless.skip>false</spotless.skip>
168-
<!-- This was the last version to support Java 8 -->
169-
<spotless.version>2.27.1</spotless.version>
167+
<spotless.version>2.43.0</spotless.version>
170168
<!-- This is the matching version of spring-boot for spring 5.3.30 -->
171169
<spring-boot.version>2.7.18</spring-boot.version>
172170
<!-- This is the last version to support the javax namespace -->
@@ -2025,18 +2023,17 @@
20252023
<maven.compiler.release>8</maven.compiler.release>
20262024
</properties>
20272025
</profile>
2028-
<!-- Some APIs were removed in Java 11, so we need to add replacements -->
2026+
<!-- Current version of spotless cannot support JDK11 below -->
20292027
<profile>
2030-
<id>.java-11-and-above</id>
2028+
<id>.java-11-below</id>
20312029
<activation>
2032-
<jdk>[11,)</jdk>
2030+
<jdk>(,11]</jdk>
20332031
</activation>
20342032
<properties>
2035-
<!--
2036-
Change to 1.15.0 will modify many codes (all are javadocs), we change it to 1.15.0
2037-
until: iotdb decides to do not support jdk8.
2038-
-->
2039-
<google.java.format.version>1.7</google.java.format.version>
2033+
<!-- This was the last version to support Java 8, Just for run -->
2034+
<spotless.version>2.27.1</spotless.version>
2035+
<!-- To avoid format conflicts -->
2036+
<spotless.skip>true</spotless.skip>
20402037
</properties>
20412038
</profile>
20422039
<!--
@@ -2065,16 +2062,6 @@
20652062
<argLine>--add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.nio=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED</argLine>
20662063
</properties>
20672064
</profile>
2068-
<!-- Current version of spotless cannot support JDK21 -->
2069-
<profile>
2070-
<id>.java-21-and-above</id>
2071-
<activation>
2072-
<jdk>[21,)</jdk>
2073-
</activation>
2074-
<properties>
2075-
<spotless.skip>true</spotless.skip>
2076-
</properties>
2077-
</profile>
20782065
<profile>
20792066
<id>with-springboot</id>
20802067
<modules>

0 commit comments

Comments
 (0)