Skip to content

Commit 5e2673a

Browse files
authored
style: improve style setting (#29)
style: improve style setting 1. add style setting for scala 2. check style with github ci
1 parent d813b78 commit 5e2673a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+831
-353
lines changed

.github/workflows/ci.yml

+8-7
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ name: CI
55
on:
66
# Triggers the workflow on push or pull request events but only for the main branch
77
pull_request:
8-
branches: [ main, dev ]
8+
branches: [main, dev]
99

1010
# Allows you to run this workflow manually from the Actions tab
1111
workflow_dispatch:
@@ -36,17 +36,18 @@ jobs:
3636
- name: set up maven and java
3737
uses: actions/setup-java@v3
3838
with:
39-
java-version: '8'
39+
java-version: "8"
4040
cache: maven
41-
distribution: 'adopt'
41+
distribution: "adopt"
42+
- name: check format convention
43+
run: |
44+
mvn spotless:check
4245
- name: init mysql schema
4346
run: mvn test exec:java -f test/embedded-mysql/pom.xml
44-
# - name: init hbase data
45-
# run:
47+
# - name: init hbase data
48+
# run:
4649

4750
# Runs a set of commands using the runners shell
4851
- name: build and test with maven
4952
run: |
5053
mvn clean test
51-
52-

.mvn/.gitkeep

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Keep it here for tell mvn which one is root folder so ${maven.multiModuleProjectDirectory} can be used in pom.

CONTRIBUTING.md

+22-5
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,30 @@ You can install [Checkstyle] plugin to check the START-DB code.
3636
### Formatting
3737

3838
START-DB code is automatically formatted with [spotless], backed by the Eclipse formatter. You can do the same in IntelliJ with the [Eclipse Code Formatter] so that you can apply the correct formatting directly in
39-
your IDE. Or import it as IntelliJ code style setting.
40-
41-
1. Open **File > Settings/Preferences > Code Style > Java**
42-
2. Gear icon > Import Scheme > Eclipse XML Profile
43-
3. Navigate to the file `conventions/eclipse-formatter.xml`
39+
your IDE.
40+
41+
**Java Code Style**
42+
43+
1. Open **File > Settings/Preferences > Plugins**
44+
2. Install **Adapter for Eclipse Code Formatter** from marketplace
45+
3. Open **File > Settings/Preferences > Adapter for Eclipse Code Formatter**
46+
4. Click "Use the Eclipse Code Formatter"
47+
5. Use default "Boundled Eclipse"
48+
6. Under "Eclipse formatter config", select "Eclipse workspace/project
49+
folder or config file"
50+
7. Click "Browse", and navigate to the file `conventions/eclipse-formatter.xml`
51+
8. **IMPORTANT** - make sure "Optimize Imports" is **NOT** selected.
52+
9. Click "OK"
53+
54+
**Scala Code Style**
55+
56+
1. Open **File > Settings/Preferences > Code Style > Scala**
57+
2. Change **Formatter** to `scalafmt`
58+
3. Set **Configguration** to file `conventions/scalafmt.conf`
4459
4. Click "OK"
4560

61+
Formatting will be triggered when running command `mvn package`. Or you can do format only with command `mvn spotless:apply`.
62+
4663
[checkstyle]: https://plugins.jetbrains.com/plugin/1065-checkstyle-idea
4764
[spotless]: https://github.com/diffplug/spotless
4865
[eclipse code formatter]: https://plugins.jetbrains.com/plugin/6546-eclipse-code-formatter

conventions/license-header

+7-9
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
/*
22
* Copyright 2022 ST-Lab
3-
4-
* This program is free software; you can redistribute it and/or
5-
* modify it under the terms of the GNU General Public License
6-
* version 2 as published by the Free Software Foundation.
7-
8-
* This program is distributed in the hope that it will be useful,
9-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11-
* GNU General Public License for more details.
3+
*
4+
* This program is free software; you can redistribute it and/or modify it under the terms of the
5+
* GNU General Public License version 2 as published by the Free Software Foundation.
6+
*
7+
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
8+
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
9+
* General Public License for more details.
1210
*/
1311

conventions/scalafmt.conf

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# ref https://scalameta.org/scalafmt/docs/configuration.html
2+
version=2.0.1
3+
maxColumn = 100
4+
optIn.configStyleArguments = false
5+
runner.dialect = scala212
6+
onTestFailure = "To fix this, run `mvn spotless:apply` from the project root directory"

core/src/main/java/org/urbcomp/start/db/constant/ConfigFileConstant.java

+11
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
/*
2+
* Copyright 2022 ST-Lab
3+
*
4+
* This program is free software; you can redistribute it and/or modify it under the terms of the
5+
* GNU General Public License version 2 as published by the Free Software Foundation.
6+
*
7+
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
8+
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
9+
* General Public License for more details.
10+
*/
11+
112
package org.urbcomp.start.db.constant;
213

314
/**

core/src/main/java/org/urbcomp/start/db/core/geomesa/model/GeomesaQuery.java

+18-6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
/*
2+
* Copyright 2022 ST-Lab
3+
*
4+
* This program is free software; you can redistribute it and/or modify it under the terms of the
5+
* GNU General Public License version 2 as published by the Free Software Foundation.
6+
*
7+
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
8+
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
9+
* General Public License for more details.
10+
*/
11+
112
package org.urbcomp.start.db.core.geomesa.model;
213

314
import org.apache.calcite.linq4j.tree.ConstantExpression;
@@ -8,14 +19,15 @@
819
import java.lang.reflect.Type;
920

1021
/**
11-
* This class is different from the native implementation of geotools, because the
12-
* native implementation of GeoTools does not java basic data types, so it cannot
13-
* be recognized in the expression parsing of linq4j.
22+
* This class is different from the native implementation of geotools, because the native
23+
* implementation of GeoTools does not java basic data types, so it cannot be recognized in the
24+
* expression parsing of linq4j.
25+
*
1426
* @see ConstantExpression#ConstantExpression(Type, Object)
1527
* @see Primitive
1628
*
17-
* Therefore, we need to re encapsulate the query object of geotools. When we need
18-
* this information, we need to present it in the form of basic data types.
29+
* Therefore, we need to re encapsulate the query object of geotools. When we need this
30+
* information, we need to present it in the form of basic data types.
1931
*
2032
* @author zaiyuan
2133
* @date 2022-05-01 15:17:07
@@ -86,4 +98,4 @@ public String getTableName() {
8698
public void setTableName(String tableName) {
8799
this.tableName = tableName;
88100
}
89-
}
101+
}

core/src/main/java/org/urbcomp/start/db/core/geomesa/rules/GeomesaFilterRule.java

+23-13
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
/*
2+
* Copyright 2022 ST-Lab
3+
*
4+
* This program is free software; you can redistribute it and/or modify it under the terms of the
5+
* GNU General Public License version 2 as published by the Free Software Foundation.
6+
*
7+
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
8+
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
9+
* General Public License for more details.
10+
*/
11+
112
package org.urbcomp.start.db.core.geomesa.rules;
213

314
import org.apache.calcite.plan.Convention;
@@ -10,8 +21,8 @@
1021
import org.urbcomp.start.db.geomesa.rel.GeomesaTableScan;
1122

1223
/**
13-
* This class is used to match the specified filter rules, convert the original
14-
* query criteria into the filter object of geotools, and push down.
24+
* This class is used to match the specified filter rules, convert the original query criteria into
25+
* the filter object of geotools, and push down.
1526
*
1627
* @author zaiyuan
1728
* @date 2022-05-01 15:17:07
@@ -30,11 +41,9 @@ protected GeomesaFilterRule(Config config) {
3041
*/
3142
public interface Config extends RelRule.Config {
3243
Config DEFAULT = EMPTY
33-
.withOperandSupplier(b0 ->
34-
b0.operand(LogicalFilter.class)
35-
.oneInput(b1 -> b1.operand(GeomesaTableScan.class)
36-
.noInputs()))
37-
.as(Config.class);
44+
.withOperandSupplier(b0 -> b0.operand(LogicalFilter.class).oneInput(
45+
b1 -> b1.operand(GeomesaTableScan.class).noInputs()))
46+
.as(Config.class);
3847

3948
/**
4049
* Creates a rule that uses this configuration.
@@ -48,8 +57,10 @@ default GeomesaFilterRule toRule() {
4857
}
4958

5059
/**
51-
* <p>Typically a rule would check that the nodes are registered and convert
52-
* calcite RexNode to Filter, creates a new expression.</p>
60+
* <p>
61+
* Typically a rule would check that the nodes are registered and convert calcite RexNode to
62+
* Filter, creates a new expression.
63+
* </p>
5364
*
5465
* @param call Rule call
5566
* @see #matches(RelOptRuleCall)
@@ -59,10 +70,9 @@ public void onMatch(RelOptRuleCall call) {
5970
LogicalFilter filter = call.rel(0);
6071
if (filter.getTraitSet().contains(Convention.NONE)) {
6172
RelTraitSet traits = filter.getTraitSet().replace(GeomesaConstant.CONVENTION());
62-
call.transformTo(new GeomesaFilter(filter.getCluster(),
63-
traits, convert(filter.getInput(), GeomesaConstant.CONVENTION()),
64-
filter.getRowType(),
65-
filter.getCondition()));
73+
call.transformTo(new GeomesaFilter(filter.getCluster(), traits,
74+
convert(filter.getInput(), GeomesaConstant.CONVENTION()),
75+
filter.getRowType(), filter.getCondition()));
6676
}
6777
}
6878
}

core/src/main/java/org/urbcomp/start/db/core/geomesa/rules/GeomesaToEnumerableConverterRule.java

+17-6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
/*
2+
* Copyright 2022 ST-Lab
3+
*
4+
* This program is free software; you can redistribute it and/or modify it under the terms of the
5+
* GNU General Public License version 2 as published by the Free Software Foundation.
6+
*
7+
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
8+
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
9+
* General Public License for more details.
10+
*/
11+
112
package org.urbcomp.start.db.core.geomesa.rules;
213

314
import org.apache.calcite.adapter.enumerable.EnumerableConvention;
@@ -23,28 +34,28 @@ public class GeomesaToEnumerableConverterRule extends ConverterRule {
2334
* ConverterRule Instance
2435
*/
2536
public static final ConverterRule INSTANCE =
26-
new GeomesaToEnumerableConverterRule(RelFactories.LOGICAL_BUILDER);
37+
new GeomesaToEnumerableConverterRule(RelFactories.LOGICAL_BUILDER);
2738

2839
/**
2940
* Construct Function with only One Parameter
3041
*
3142
* @param relBuilderFactory RelNoade Factory
3243
*/
3344
public GeomesaToEnumerableConverterRule(RelBuilderFactory relBuilderFactory) {
34-
super(RelNode.class, (Predicate<? super RelNode>) relNode -> true, GeomesaConstant.CONVENTION(),
35-
EnumerableConvention.INSTANCE, relBuilderFactory,
36-
"GeomesaToEnumerableConverterRule");
45+
super(RelNode.class, (Predicate<? super RelNode>) relNode -> true,
46+
GeomesaConstant.CONVENTION(), EnumerableConvention.INSTANCE,
47+
relBuilderFactory, "GeomesaToEnumerableConverterRule");
3748
}
3849

3950
/**
4051
* Convert RelNode to GeomesaToEnumeratorConverter
4152
*
4253
* @param rel RelNode
43-
* @return GeomesaToEnumeratorConverter
54+
* @return GeomesaToEnumeratorConverter
4455
*/
4556
@Override
4657
public RelNode convert(RelNode rel) {
4758
RelTraitSet newTraitSet = rel.getTraitSet().replace(getOutConvention());
4859
return new GeomesaToEnumeratorConverter(rel.getCluster(), newTraitSet, rel);
4960
}
50-
}
61+
}

core/src/main/java/org/urbcomp/start/db/frame/InnerFunction.java

+11
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
/*
2+
* Copyright 2022 ST-Lab
3+
*
4+
* This program is free software; you can redistribute it and/or modify it under the terms of the
5+
* GNU General Public License version 2 as published by the Free Software Foundation.
6+
*
7+
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
8+
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
9+
* General Public License for more details.
10+
*/
11+
112
package org.urbcomp.start.db.frame;
213

314
import java.lang.annotation.*;

core/src/main/java/org/urbcomp/start/db/metadata/AccessorFactory.java

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
/*
2+
* Copyright 2022 ST-Lab
3+
*
4+
* This program is free software; you can redistribute it and/or modify it under the terms of the
5+
* GNU General Public License version 2 as published by the Free Software Foundation.
6+
*
7+
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
8+
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
9+
* General Public License for more details.
10+
*/
11+
112
package org.urbcomp.start.db.metadata;
213

314
import org.urbcomp.start.db.metadata.accessor.UserAccessor;
@@ -12,7 +23,8 @@ public class AccessorFactory {
1223

1324
/**
1425
* get UserAccessor
15-
* @return UserAccessor
26+
*
27+
* @return UserAccessor
1628
*/
1729
public static UserAccessor getUserAccessor() {
1830
return new UserAccessor();

core/src/main/java/org/urbcomp/start/db/metadata/SqlSessionUtil.java

+18-7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
/*
2+
* Copyright 2022 ST-Lab
3+
*
4+
* This program is free software; you can redistribute it and/or modify it under the terms of the
5+
* GNU General Public License version 2 as published by the Free Software Foundation.
6+
*
7+
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
8+
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
9+
* General Public License for more details.
10+
*/
11+
112
package org.urbcomp.start.db.metadata;
213

314
import lombok.extern.slf4j.Slf4j;
@@ -15,8 +26,8 @@
1526
* In order to reduce the overhead of frequent opening and closing of this object, we use the
1627
* singleton mode to maintain only one corresponding instance in memory.
1728
* <p>
18-
* In order to avoid the destruction of singleton pattern by serialization and deserialization,
19-
* we use static inner classes to maintain singleton objects.
29+
* In order to avoid the destruction of singleton pattern by serialization and deserialization, we
30+
* use static inner classes to maintain singleton objects.
2031
*
2132
* @author zaiyuan
2233
* @date 2022-05-01 15:17:07
@@ -30,10 +41,9 @@ public class SqlSessionUtil {
3041
private final SqlSession sqlSession;
3142

3243
/**
33-
* Nonparametric construction method
34-
* We use the method of reading the configuration file to construct the sqlsession singleton.
35-
* TODO: Maybe we should support reading configuration in other ways, such as Mysql, full pathname,
36-
* Zookeeper, Apollo configuration center, etc.
44+
* Nonparametric construction method We use the method of reading the configuration file to
45+
* construct the sqlsession singleton. TODO: Maybe we should support reading configuration in
46+
* other ways, such as Mysql, full pathname, Zookeeper, Apollo configuration center, etc.
3747
*/
3848
private SqlSessionUtil() {
3949
InputStream inputStream = ResourceUtil.readResource(ConfigFileConstant.MYBATIS_CONFIG_PATH);
@@ -42,7 +52,8 @@ private SqlSessionUtil() {
4252
}
4353

4454
/**
45-
* Private static internal classes to maintain singletons to avoid obtaining singletons through constructors.
55+
* Private static internal classes to maintain singletons to avoid obtaining singletons through
56+
* constructors.
4657
*/
4758
private static class SqlSessionUtilHolder {
4859
private static final SqlSessionUtil INSTANCE = new SqlSessionUtil();

0 commit comments

Comments
 (0)