diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d5e319d1..3a6fa6db 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,7 +5,7 @@ name: CI on: # Triggers the workflow on push or pull request events but only for the main branch pull_request: - branches: [ main, dev ] + branches: [main, dev] # Allows you to run this workflow manually from the Actions tab workflow_dispatch: @@ -36,17 +36,18 @@ jobs: - name: set up maven and java uses: actions/setup-java@v3 with: - java-version: '8' + java-version: "8" cache: maven - distribution: 'adopt' + distribution: "adopt" + - name: check format convention + run: | + mvn spotless:check - name: init mysql schema run: mvn test exec:java -f test/embedded-mysql/pom.xml -# - name: init hbase data -# run: + # - name: init hbase data + # run: # Runs a set of commands using the runners shell - name: build and test with maven run: | mvn clean test - - diff --git a/.mvn/.gitkeep b/.mvn/.gitkeep new file mode 100644 index 00000000..6537bc45 --- /dev/null +++ b/.mvn/.gitkeep @@ -0,0 +1 @@ +# Keep it here for tell mvn which one is root folder so ${maven.multiModuleProjectDirectory} can be used in pom. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2e5ae949..8a969c45 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -36,13 +36,30 @@ You can install [Checkstyle] plugin to check the START-DB code. ### Formatting 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 -your IDE. Or import it as IntelliJ code style setting. - -1. Open **File > Settings/Preferences > Code Style > Java** -2. Gear icon > Import Scheme > Eclipse XML Profile -3. Navigate to the file `conventions/eclipse-formatter.xml` +your IDE. + +**Java Code Style** + +1. Open **File > Settings/Preferences > Plugins** +2. Install **Adapter for Eclipse Code Formatter** from marketplace +3. Open **File > Settings/Preferences > Adapter for Eclipse Code Formatter** +4. Click "Use the Eclipse Code Formatter" +5. Use default "Boundled Eclipse" +6. Under "Eclipse formatter config", select "Eclipse workspace/project + folder or config file" +7. Click "Browse", and navigate to the file `conventions/eclipse-formatter.xml` +8. **IMPORTANT** - make sure "Optimize Imports" is **NOT** selected. +9. Click "OK" + +**Scala Code Style** + +1. Open **File > Settings/Preferences > Code Style > Scala** +2. Change **Formatter** to `scalafmt` +3. Set **Configguration** to file `conventions/scalafmt.conf` 4. Click "OK" +Formatting will be triggered when running command `mvn package`. Or you can do format only with command `mvn spotless:apply`. + [checkstyle]: https://plugins.jetbrains.com/plugin/1065-checkstyle-idea [spotless]: https://github.com/diffplug/spotless [eclipse code formatter]: https://plugins.jetbrains.com/plugin/6546-eclipse-code-formatter diff --git a/conventions/license-header b/conventions/license-header index c9f3e205..423baa36 100644 --- a/conventions/license-header +++ b/conventions/license-header @@ -1,13 +1,11 @@ /* * Copyright 2022 ST-Lab - - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * version 2 as published by the Free Software Foundation. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. */ diff --git a/conventions/scalafmt.conf b/conventions/scalafmt.conf new file mode 100644 index 00000000..3e362e2c --- /dev/null +++ b/conventions/scalafmt.conf @@ -0,0 +1,6 @@ +# ref https://scalameta.org/scalafmt/docs/configuration.html +version=2.0.1 +maxColumn = 100 +optIn.configStyleArguments = false +runner.dialect = scala212 +onTestFailure = "To fix this, run `mvn spotless:apply` from the project root directory" diff --git a/core/src/main/java/org/urbcomp/start/db/constant/ConfigFileConstant.java b/core/src/main/java/org/urbcomp/start/db/constant/ConfigFileConstant.java index 751ca17c..1151c716 100644 --- a/core/src/main/java/org/urbcomp/start/db/constant/ConfigFileConstant.java +++ b/core/src/main/java/org/urbcomp/start/db/constant/ConfigFileConstant.java @@ -1,3 +1,14 @@ +/* + * Copyright 2022 ST-Lab + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + */ + package org.urbcomp.start.db.constant; /** diff --git a/core/src/main/java/org/urbcomp/start/db/core/geomesa/model/GeomesaQuery.java b/core/src/main/java/org/urbcomp/start/db/core/geomesa/model/GeomesaQuery.java index b90e4831..18d880c5 100644 --- a/core/src/main/java/org/urbcomp/start/db/core/geomesa/model/GeomesaQuery.java +++ b/core/src/main/java/org/urbcomp/start/db/core/geomesa/model/GeomesaQuery.java @@ -1,3 +1,14 @@ +/* + * Copyright 2022 ST-Lab + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + */ + package org.urbcomp.start.db.core.geomesa.model; import org.apache.calcite.linq4j.tree.ConstantExpression; @@ -8,14 +19,15 @@ import java.lang.reflect.Type; /** - * This class is different from the native implementation of geotools, because the - * native implementation of GeoTools does not java basic data types, so it cannot - * be recognized in the expression parsing of linq4j. + * This class is different from the native implementation of geotools, because the native + * implementation of GeoTools does not java basic data types, so it cannot be recognized in the + * expression parsing of linq4j. + * * @see ConstantExpression#ConstantExpression(Type, Object) * @see Primitive * - * Therefore, we need to re encapsulate the query object of geotools. When we need - * this information, we need to present it in the form of basic data types. + * Therefore, we need to re encapsulate the query object of geotools. When we need this + * information, we need to present it in the form of basic data types. * * @author zaiyuan * @date 2022-05-01 15:17:07 @@ -86,4 +98,4 @@ public String getTableName() { public void setTableName(String tableName) { this.tableName = tableName; } -} \ No newline at end of file +} diff --git a/core/src/main/java/org/urbcomp/start/db/core/geomesa/rules/GeomesaFilterRule.java b/core/src/main/java/org/urbcomp/start/db/core/geomesa/rules/GeomesaFilterRule.java index 1b4f86ba..5b97846d 100644 --- a/core/src/main/java/org/urbcomp/start/db/core/geomesa/rules/GeomesaFilterRule.java +++ b/core/src/main/java/org/urbcomp/start/db/core/geomesa/rules/GeomesaFilterRule.java @@ -1,3 +1,14 @@ +/* + * Copyright 2022 ST-Lab + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + */ + package org.urbcomp.start.db.core.geomesa.rules; import org.apache.calcite.plan.Convention; @@ -10,8 +21,8 @@ import org.urbcomp.start.db.geomesa.rel.GeomesaTableScan; /** - * This class is used to match the specified filter rules, convert the original - * query criteria into the filter object of geotools, and push down. + * This class is used to match the specified filter rules, convert the original query criteria into + * the filter object of geotools, and push down. * * @author zaiyuan * @date 2022-05-01 15:17:07 @@ -30,11 +41,9 @@ protected GeomesaFilterRule(Config config) { */ public interface Config extends RelRule.Config { Config DEFAULT = EMPTY - .withOperandSupplier(b0 -> - b0.operand(LogicalFilter.class) - .oneInput(b1 -> b1.operand(GeomesaTableScan.class) - .noInputs())) - .as(Config.class); + .withOperandSupplier(b0 -> b0.operand(LogicalFilter.class).oneInput( + b1 -> b1.operand(GeomesaTableScan.class).noInputs())) + .as(Config.class); /** * Creates a rule that uses this configuration. @@ -48,8 +57,10 @@ default GeomesaFilterRule toRule() { } /** - *

Typically a rule would check that the nodes are registered and convert - * calcite RexNode to Filter, creates a new expression.

+ *

+ * Typically a rule would check that the nodes are registered and convert calcite RexNode to + * Filter, creates a new expression. + *

* * @param call Rule call * @see #matches(RelOptRuleCall) @@ -59,10 +70,9 @@ public void onMatch(RelOptRuleCall call) { LogicalFilter filter = call.rel(0); if (filter.getTraitSet().contains(Convention.NONE)) { RelTraitSet traits = filter.getTraitSet().replace(GeomesaConstant.CONVENTION()); - call.transformTo(new GeomesaFilter(filter.getCluster(), - traits, convert(filter.getInput(), GeomesaConstant.CONVENTION()), - filter.getRowType(), - filter.getCondition())); + call.transformTo(new GeomesaFilter(filter.getCluster(), traits, + convert(filter.getInput(), GeomesaConstant.CONVENTION()), + filter.getRowType(), filter.getCondition())); } } } diff --git a/core/src/main/java/org/urbcomp/start/db/core/geomesa/rules/GeomesaToEnumerableConverterRule.java b/core/src/main/java/org/urbcomp/start/db/core/geomesa/rules/GeomesaToEnumerableConverterRule.java index f0e64cb7..492ae656 100644 --- a/core/src/main/java/org/urbcomp/start/db/core/geomesa/rules/GeomesaToEnumerableConverterRule.java +++ b/core/src/main/java/org/urbcomp/start/db/core/geomesa/rules/GeomesaToEnumerableConverterRule.java @@ -1,3 +1,14 @@ +/* + * Copyright 2022 ST-Lab + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + */ + package org.urbcomp.start.db.core.geomesa.rules; import org.apache.calcite.adapter.enumerable.EnumerableConvention; @@ -23,7 +34,7 @@ public class GeomesaToEnumerableConverterRule extends ConverterRule { * ConverterRule Instance */ public static final ConverterRule INSTANCE = - new GeomesaToEnumerableConverterRule(RelFactories.LOGICAL_BUILDER); + new GeomesaToEnumerableConverterRule(RelFactories.LOGICAL_BUILDER); /** * Construct Function with only One Parameter @@ -31,20 +42,20 @@ public class GeomesaToEnumerableConverterRule extends ConverterRule { * @param relBuilderFactory RelNoade Factory */ public GeomesaToEnumerableConverterRule(RelBuilderFactory relBuilderFactory) { - super(RelNode.class, (Predicate) relNode -> true, GeomesaConstant.CONVENTION(), - EnumerableConvention.INSTANCE, relBuilderFactory, - "GeomesaToEnumerableConverterRule"); + super(RelNode.class, (Predicate) relNode -> true, + GeomesaConstant.CONVENTION(), EnumerableConvention.INSTANCE, + relBuilderFactory, "GeomesaToEnumerableConverterRule"); } /** * Convert RelNode to GeomesaToEnumeratorConverter * * @param rel RelNode - * @return GeomesaToEnumeratorConverter + * @return GeomesaToEnumeratorConverter */ @Override public RelNode convert(RelNode rel) { RelTraitSet newTraitSet = rel.getTraitSet().replace(getOutConvention()); return new GeomesaToEnumeratorConverter(rel.getCluster(), newTraitSet, rel); } -} \ No newline at end of file +} diff --git a/core/src/main/java/org/urbcomp/start/db/frame/InnerFunction.java b/core/src/main/java/org/urbcomp/start/db/frame/InnerFunction.java index d33777f3..f2ae7d3c 100644 --- a/core/src/main/java/org/urbcomp/start/db/frame/InnerFunction.java +++ b/core/src/main/java/org/urbcomp/start/db/frame/InnerFunction.java @@ -1,3 +1,14 @@ +/* + * Copyright 2022 ST-Lab + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + */ + package org.urbcomp.start.db.frame; import java.lang.annotation.*; diff --git a/core/src/main/java/org/urbcomp/start/db/metadata/AccessorFactory.java b/core/src/main/java/org/urbcomp/start/db/metadata/AccessorFactory.java index 5da2bb0e..9b268eda 100644 --- a/core/src/main/java/org/urbcomp/start/db/metadata/AccessorFactory.java +++ b/core/src/main/java/org/urbcomp/start/db/metadata/AccessorFactory.java @@ -1,3 +1,14 @@ +/* + * Copyright 2022 ST-Lab + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + */ + package org.urbcomp.start.db.metadata; import org.urbcomp.start.db.metadata.accessor.UserAccessor; @@ -12,7 +23,8 @@ public class AccessorFactory { /** * get UserAccessor - * @return UserAccessor + * + * @return UserAccessor */ public static UserAccessor getUserAccessor() { return new UserAccessor(); diff --git a/core/src/main/java/org/urbcomp/start/db/metadata/SqlSessionUtil.java b/core/src/main/java/org/urbcomp/start/db/metadata/SqlSessionUtil.java index 7ac9496b..db0b08d0 100644 --- a/core/src/main/java/org/urbcomp/start/db/metadata/SqlSessionUtil.java +++ b/core/src/main/java/org/urbcomp/start/db/metadata/SqlSessionUtil.java @@ -1,3 +1,14 @@ +/* + * Copyright 2022 ST-Lab + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + */ + package org.urbcomp.start.db.metadata; import lombok.extern.slf4j.Slf4j; @@ -15,8 +26,8 @@ * In order to reduce the overhead of frequent opening and closing of this object, we use the * singleton mode to maintain only one corresponding instance in memory. *

- * In order to avoid the destruction of singleton pattern by serialization and deserialization, - * we use static inner classes to maintain singleton objects. + * In order to avoid the destruction of singleton pattern by serialization and deserialization, we + * use static inner classes to maintain singleton objects. * * @author zaiyuan * @date 2022-05-01 15:17:07 @@ -30,10 +41,9 @@ public class SqlSessionUtil { private final SqlSession sqlSession; /** - * Nonparametric construction method - * We use the method of reading the configuration file to construct the sqlsession singleton. - * TODO: Maybe we should support reading configuration in other ways, such as Mysql, full pathname, - * Zookeeper, Apollo configuration center, etc. + * Nonparametric construction method We use the method of reading the configuration file to + * construct the sqlsession singleton. TODO: Maybe we should support reading configuration in + * other ways, such as Mysql, full pathname, Zookeeper, Apollo configuration center, etc. */ private SqlSessionUtil() { InputStream inputStream = ResourceUtil.readResource(ConfigFileConstant.MYBATIS_CONFIG_PATH); @@ -42,7 +52,8 @@ private SqlSessionUtil() { } /** - * Private static internal classes to maintain singletons to avoid obtaining singletons through constructors. + * Private static internal classes to maintain singletons to avoid obtaining singletons through + * constructors. */ private static class SqlSessionUtilHolder { private static final SqlSessionUtil INSTANCE = new SqlSessionUtil(); diff --git a/core/src/main/java/org/urbcomp/start/db/metadata/accessor/IAccessor.java b/core/src/main/java/org/urbcomp/start/db/metadata/accessor/IAccessor.java index 0f47bffc..b4422562 100644 --- a/core/src/main/java/org/urbcomp/start/db/metadata/accessor/IAccessor.java +++ b/core/src/main/java/org/urbcomp/start/db/metadata/accessor/IAccessor.java @@ -1,3 +1,14 @@ +/* + * Copyright 2022 ST-Lab + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + */ + package org.urbcomp.start.db.metadata.accessor; import org.urbcomp.start.db.metadata.entity.AbstractEntity; @@ -14,42 +25,48 @@ public interface IAccessor extends AutoCloseable { /** * select all entity in table - * @return list of entity instance + * + * @return list of entity instance */ List selectAll(); /** * select one entity from table by id - * @param id id - * @return entity instance + * + * @param id id + * @return entity instance */ T selectById(long id); /** * select one entity from table by name - * @param name name - * @return entity instance + * + * @param name name + * @return entity instance */ T selectByName(String name); /** * insert one entity instance into table - * @param entity entity instance - * @return number of affected rows + * + * @param entity entity instance + * @return number of affected rows */ long insert(T entity); /** * update one entity instance in table - * @param entity entity instance - * @return number of affected rows + * + * @param entity entity instance + * @return number of affected rows */ long update(T entity); /** * delete one entity instance in table - * @param id id - * @return number of affected rows + * + * @param id id + * @return number of affected rows */ long deleteById(long id); @@ -65,7 +82,8 @@ public interface IAccessor extends AutoCloseable { /** * get mapper instance - * @return IMapper + * + * @return IMapper */ IMapper getMapper(); } diff --git a/core/src/main/java/org/urbcomp/start/db/metadata/accessor/UserAccessor.java b/core/src/main/java/org/urbcomp/start/db/metadata/accessor/UserAccessor.java index ffb28ce9..2036442f 100644 --- a/core/src/main/java/org/urbcomp/start/db/metadata/accessor/UserAccessor.java +++ b/core/src/main/java/org/urbcomp/start/db/metadata/accessor/UserAccessor.java @@ -1,3 +1,14 @@ +/* + * Copyright 2022 ST-Lab + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + */ + package org.urbcomp.start.db.metadata.accessor; import org.urbcomp.start.db.metadata.SqlSessionUtil; @@ -16,7 +27,8 @@ public class UserAccessor implements IAccessor { /** * select all users - * @return list of user instance + * + * @return list of user instance */ @Override public List selectAll() { @@ -25,8 +37,9 @@ public List selectAll() { /** * select one user in table - * @param id id - * @return user instance + * + * @param id id + * @return user instance */ @Override public User selectById(long id) { @@ -35,8 +48,9 @@ public User selectById(long id) { /** * select one user by name - * @param name name - * @return user instance + * + * @param name name + * @return user instance */ @Override public User selectByName(String name) { @@ -45,8 +59,9 @@ public User selectByName(String name) { /** * insert one user into table - * @param user user instance - * @return number of affected rows + * + * @param user user instance + * @return number of affected rows */ @Override public long insert(User user) { @@ -55,8 +70,9 @@ public long insert(User user) { /** * update one user in table - * @param user user instance - * @return number of affected rows + * + * @param user user instance + * @return number of affected rows */ @Override public long update(User user) { @@ -65,8 +81,9 @@ public long update(User user) { /** * delete one user in table by id - * @param id id - * @return number of affected rows + * + * @param id id + * @return number of affected rows */ @Override public long deleteById(long id) { @@ -99,7 +116,8 @@ public void close() { /** * get mapper instance of user - * @return IMapper + * + * @return IMapper */ @Override public IMapper getMapper() { diff --git a/core/src/main/java/org/urbcomp/start/db/metadata/entity/AbstractEntity.java b/core/src/main/java/org/urbcomp/start/db/metadata/entity/AbstractEntity.java index 374f1d7c..6239a533 100644 --- a/core/src/main/java/org/urbcomp/start/db/metadata/entity/AbstractEntity.java +++ b/core/src/main/java/org/urbcomp/start/db/metadata/entity/AbstractEntity.java @@ -1,3 +1,14 @@ +/* + * Copyright 2022 ST-Lab + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + */ + package org.urbcomp.start.db.metadata.entity; /** @@ -18,8 +29,7 @@ public abstract class AbstractEntity { */ protected String name; - public AbstractEntity() { - } + public AbstractEntity() {} public AbstractEntity(long id, String name) { this.id = id; @@ -44,9 +54,6 @@ public void setName(String name) { @Override public String toString() { - return "IEntity{" + - "id=" + id + - ", userName='" + name + '\'' + - '}'; + return "IEntity{" + "id=" + id + ", userName='" + name + '\'' + '}'; } } diff --git a/core/src/main/java/org/urbcomp/start/db/metadata/entity/User.java b/core/src/main/java/org/urbcomp/start/db/metadata/entity/User.java index 20f3f7dd..76b2a727 100644 --- a/core/src/main/java/org/urbcomp/start/db/metadata/entity/User.java +++ b/core/src/main/java/org/urbcomp/start/db/metadata/entity/User.java @@ -1,3 +1,14 @@ +/* + * Copyright 2022 ST-Lab + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + */ + package org.urbcomp.start.db.metadata.entity; /** @@ -28,10 +39,7 @@ public void setPassword(String password) { @Override public String toString() { - return "User{" + - "id=" + id + - ", name='" + name + '\'' + - ", password='" + password + '\'' + - '}'; + return "User{" + "id=" + id + ", name='" + name + '\'' + ", password='" + password + '\'' + + '}'; } } diff --git a/core/src/main/java/org/urbcomp/start/db/metadata/mapper/IMapper.java b/core/src/main/java/org/urbcomp/start/db/metadata/mapper/IMapper.java index 0495e957..611cab66 100644 --- a/core/src/main/java/org/urbcomp/start/db/metadata/mapper/IMapper.java +++ b/core/src/main/java/org/urbcomp/start/db/metadata/mapper/IMapper.java @@ -1,3 +1,14 @@ +/* + * Copyright 2022 ST-Lab + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + */ + package org.urbcomp.start.db.metadata.mapper; import org.apache.ibatis.annotations.Param; @@ -15,42 +26,48 @@ public interface IMapper { /** * select all entity in table - * @return list of entity instance + * + * @return list of entity instance */ List selectAll(); /** * select one entity in table based on id - * @param id id - * @return entity instance + * + * @param id id + * @return entity instance */ T selectById(@Param("id") long id); /** * select one entity in table based on name - * @param name name - * @return entity instance + * + * @param name name + * @return entity instance */ T selectByName(@Param("name") String name); /** * insert one entity into table - * @param entity entity - * @return number of affected rows + * + * @param entity entity + * @return number of affected rows */ long insert(T entity); /** * update one entity in a table - * @param entity entity - * @return number of affected rows + * + * @param entity entity + * @return number of affected rows */ long update(T entity); /** * delete on entity in a table by id - * @param id id - * @return number of affected rows + * + * @param id id + * @return number of affected rows */ long deleteById(@Param("id") long id); } diff --git a/core/src/main/java/org/urbcomp/start/db/metadata/mapper/UserMapper.java b/core/src/main/java/org/urbcomp/start/db/metadata/mapper/UserMapper.java index 2ab71269..835023fa 100644 --- a/core/src/main/java/org/urbcomp/start/db/metadata/mapper/UserMapper.java +++ b/core/src/main/java/org/urbcomp/start/db/metadata/mapper/UserMapper.java @@ -1,3 +1,14 @@ +/* + * Copyright 2022 ST-Lab + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + */ + package org.urbcomp.start.db.metadata.mapper; import org.apache.ibatis.annotations.Param; @@ -12,16 +23,18 @@ public interface UserMapper extends IMapper { /** * insert one user instance into user table - * @param user user instance - * @return number of affected rows + * + * @param user user instance + * @return number of affected rows */ @Override long insert(@Param("user") User user); /** * update one user instance in user table - * @param user user instance - * @return number of affected rows + * + * @param user user instance + * @return number of affected rows */ @Override long update(@Param("user") User user); diff --git a/core/src/main/java/org/urbcomp/start/db/util/ResourceUtil.java b/core/src/main/java/org/urbcomp/start/db/util/ResourceUtil.java index 45e27448..fab54333 100644 --- a/core/src/main/java/org/urbcomp/start/db/util/ResourceUtil.java +++ b/core/src/main/java/org/urbcomp/start/db/util/ResourceUtil.java @@ -1,3 +1,14 @@ +/* + * Copyright 2022 ST-Lab + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + */ + package org.urbcomp.start.db.util; import java.io.File; @@ -14,8 +25,7 @@ public class ResourceUtil { /** - * read file in classpath or absolute path - * **stream should be closed by caller** + * read file in classpath or absolute path **stream should be closed by caller** * * @param path classpath or absolute path * @return input stream or throws IllegalArgumentException if not found diff --git a/core/src/main/scala/org/urbcomp/start/db/common/ConfigProvider.scala b/core/src/main/scala/org/urbcomp/start/db/common/ConfigProvider.scala index 22a3443c..b71a9019 100644 --- a/core/src/main/scala/org/urbcomp/start/db/common/ConfigProvider.scala +++ b/core/src/main/scala/org/urbcomp/start/db/common/ConfigProvider.scala @@ -1,18 +1,32 @@ +/* + * Copyright 2022 ST-Lab + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + */ + package org.urbcomp.start.db.common /** - * Config Provider - * - * @author zaiyuan - * @date 2022/05/01 - * @since 0.1.0 - */ + * Config Provider + * + * @author zaiyuan + * @date 2022/05/01 + * @since 0.1.0 + */ object ConfigProvider { def getGeomesaHbaseParam(catalog: String): Map[String, String] = - Map(ConfigurationConstants.GEOMESA_HBASE_CATALOG -> catalog, + Map( + ConfigurationConstants.GEOMESA_HBASE_CATALOG -> catalog, ConfigurationConstants.GEOMESA_HBASE_ZOOKEEPERS -> ConfigurationFactory.getInstance.getProperty( - ConfigurationConstants.GEOMESA_HBASE_ZOOKEEPERS)) + ConfigurationConstants.GEOMESA_HBASE_ZOOKEEPERS + ) + ) } diff --git a/core/src/main/scala/org/urbcomp/start/db/common/ConfigurationConstants.scala b/core/src/main/scala/org/urbcomp/start/db/common/ConfigurationConstants.scala index 8a5db9b4..8ff742fb 100644 --- a/core/src/main/scala/org/urbcomp/start/db/common/ConfigurationConstants.scala +++ b/core/src/main/scala/org/urbcomp/start/db/common/ConfigurationConstants.scala @@ -1,12 +1,23 @@ +/* + * Copyright 2022 ST-Lab + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + */ + package org.urbcomp.start.db.common /** - * Configuration Constants - * - * @author zaiyuan - * @date 2022/05/01 - * @since 0.1.0 - */ + * Configuration Constants + * + * @author zaiyuan + * @date 2022/05/01 + * @since 0.1.0 + */ object ConfigurationConstants { val GEOMESA_HBASE_CATALOG = "hbase.catalog" diff --git a/core/src/main/scala/org/urbcomp/start/db/common/ConfigurationFactory.scala b/core/src/main/scala/org/urbcomp/start/db/common/ConfigurationFactory.scala index 13c3fa2f..d735d176 100644 --- a/core/src/main/scala/org/urbcomp/start/db/common/ConfigurationFactory.scala +++ b/core/src/main/scala/org/urbcomp/start/db/common/ConfigurationFactory.scala @@ -1,14 +1,25 @@ +/* + * Copyright 2022 ST-Lab + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + */ + package org.urbcomp.start.db.common import java.util.Properties /** - * Configuration Factory - * - * @author zaiyuan - * @date 2022/05/01 - * @since 0.1.0 - */ + * Configuration Factory + * + * @author zaiyuan + * @date 2022/05/01 + * @since 0.1.0 + */ object ConfigurationFactory { private lazy val properties: Properties = { diff --git a/core/src/main/scala/org/urbcomp/start/db/function/SpatialFunction.scala b/core/src/main/scala/org/urbcomp/start/db/function/SpatialFunction.scala index 59c858a9..b579dc7f 100644 --- a/core/src/main/scala/org/urbcomp/start/db/function/SpatialFunction.scala +++ b/core/src/main/scala/org/urbcomp/start/db/function/SpatialFunction.scala @@ -1,102 +1,113 @@ +/* + * Copyright 2022 ST-Lab + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + */ + package org.urbcomp.start.db.function import org.locationtech.jts.geom._ import org.locationtech.jts.geom.prep._ /** - * This class is used to register spatial functions. - * Although compute natively supports spatial functions, it uses the ESRI geometry Java library, - * which has not been maintained for a long time. Therefore, it switches the spatial data model - * to a more active Java topology suite library. - * - * @see - * @see - * - * @author zaiyuan - * @date 2022-05-01 09:12:07 - * @since 0.1.0 - */ + * This class is used to register spatial functions. + * Although compute natively supports spatial functions, it uses the ESRI geometry Java library, + * which has not been maintained for a long time. Therefore, it switches the spatial data model + * to a more active Java topology suite library. + * + * @see + * @see + * + * @author zaiyuan + * @date 2022-05-01 09:12:07 + * @since 0.1.0 + */ class SpatialFunction { def intersects(geom1: Geometry, geom2: Geometry): Boolean = { prepareGeometry(geom1) match { - case None => geom1.intersects(geom2) + case None => geom1.intersects(geom2) case g: Option[PreparedGeometry] => g.get.intersects(geom2) } } def within(geom1: Geometry, geom2: Geometry): Boolean = { prepareGeometry(geom1) match { - case None => geom1.within(geom2) + case None => geom1.within(geom2) case g: Option[PreparedGeometry] => g.get.within(geom2) } } def touches(geom1: Geometry, geom2: Geometry): Boolean = { prepareGeometry(geom1) match { - case None => geom1.touches(geom2) + case None => geom1.touches(geom2) case g: Option[PreparedGeometry] => g.get.touches(geom2) } } - def overlaps(geom1: Geometry, geom2: Geometry): Boolean ={ + def overlaps(geom1: Geometry, geom2: Geometry): Boolean = { prepareGeometry(geom1) match { - case None => geom1.overlaps(geom2) + case None => geom1.overlaps(geom2) case g: Option[PreparedGeometry] => g.get.overlaps(geom2) } } def equals(geom1: Geometry, geom2: Geometry): Boolean = { prepareGeometry(geom1) match { - case None => geom1.equals(geom2) + case None => geom1.equals(geom2) case g: Option[PreparedGeometry] => g.get.equals(geom2) } } def disjoint(geom1: Geometry, geom2: Geometry): Boolean = { prepareGeometry(geom1) match { - case None => geom1.disjoint(geom2) + case None => geom1.disjoint(geom2) case g: Option[PreparedGeometry] => g.get.disjoint(geom2) } } def covers(geom1: Geometry, geom2: Geometry): Boolean = { prepareGeometry(geom1) match { - case None => geom1.covers(geom2) + case None => geom1.covers(geom2) case g: Option[PreparedGeometry] => g.get.covers(geom2) } } def crosses(geom1: Geometry, geom2: Geometry): Boolean = { prepareGeometry(geom1) match { - case None => geom1.crosses(geom2) + case None => geom1.crosses(geom2) case g: Option[PreparedGeometry] => g.get.crosses(geom2) } } def contains(geom1: Geometry, geom2: Geometry): Boolean = { prepareGeometry(geom1) match { - case None => geom1.contains(geom2) + case None => geom1.contains(geom2) case g: Option[PreparedGeometry] => g.get.contains(geom2) } } /** - * Prepareometry is an advanced scheme of spatial object processing provided by JTS. - * In the original JTS spatial objects, some spatial relationships are judged by very - * complex algorithms, which greatly increases the execution time of the algorithm. - * Some spatial data and some spatial relationships are optimized in prepareometry, - * which greatly improves the execution efficiency of the algorithm. - * - * @param geom Geometry - * @return Option[PreparedGeometry] - */ + * Prepareometry is an advanced scheme of spatial object processing provided by JTS. + * In the original JTS spatial objects, some spatial relationships are judged by very + * complex algorithms, which greatly increases the execution time of the algorithm. + * Some spatial data and some spatial relationships are optimized in prepareometry, + * which greatly improves the execution efficiency of the algorithm. + * + * @param geom Geometry + * @return Option[PreparedGeometry] + */ def prepareGeometry(geom: Geometry): Option[PreparedGeometry] = geom match { - case g: Point => Option(new PreparedPoint(g)) + case g: Point => Option(new PreparedPoint(g)) case g: MultiPoint => Option(new PreparedPoint(g)) case g: LineString => Option(new PreparedLineString(g)) - case g: Polygon => Option(new PreparedPolygon(g)) - case _ => None + case g: Polygon => Option(new PreparedPolygon(g)) + case _ => None } } diff --git a/core/src/main/scala/org/urbcomp/start/db/geomesa/GeomesaConstant.scala b/core/src/main/scala/org/urbcomp/start/db/geomesa/GeomesaConstant.scala index 079e7071..6ef55b66 100644 --- a/core/src/main/scala/org/urbcomp/start/db/geomesa/GeomesaConstant.scala +++ b/core/src/main/scala/org/urbcomp/start/db/geomesa/GeomesaConstant.scala @@ -1,3 +1,14 @@ +/* + * Copyright 2022 ST-Lab + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + */ + package org.urbcomp.start.db.geomesa import org.apache.calcite.plan.Convention diff --git a/core/src/main/scala/org/urbcomp/start/db/geomesa/GeomesaEnumerator.scala b/core/src/main/scala/org/urbcomp/start/db/geomesa/GeomesaEnumerator.scala index 3ce99edf..876b34ea 100644 --- a/core/src/main/scala/org/urbcomp/start/db/geomesa/GeomesaEnumerator.scala +++ b/core/src/main/scala/org/urbcomp/start/db/geomesa/GeomesaEnumerator.scala @@ -1,3 +1,14 @@ +/* + * Copyright 2022 ST-Lab + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + */ + package org.urbcomp.start.db.geomesa import org.apache.calcite.linq4j.Enumerator @@ -9,14 +20,15 @@ import org.urbcomp.start.db.common.ConfigProvider import scala.collection.JavaConverters._ /** - * Enumerator for Geomesa - * - * @param reader FeatureReader - * - * @author zaiyuan - * @since 0.1.0 - */ -class GeomesaEnumerator(reader: FeatureReader[SimpleFeatureType, SimpleFeature]) extends Enumerator[Object] { + * Enumerator for Geomesa + * + * @param reader FeatureReader + * + * @author zaiyuan + * @since 0.1.0 + */ +class GeomesaEnumerator(reader: FeatureReader[SimpleFeatureType, SimpleFeature]) + extends Enumerator[Object] { var curr: Array[AnyRef] = _ diff --git a/core/src/main/scala/org/urbcomp/start/db/geomesa/GeomesaQueryable.scala b/core/src/main/scala/org/urbcomp/start/db/geomesa/GeomesaQueryable.scala index 158a4999..4268467b 100644 --- a/core/src/main/scala/org/urbcomp/start/db/geomesa/GeomesaQueryable.scala +++ b/core/src/main/scala/org/urbcomp/start/db/geomesa/GeomesaQueryable.scala @@ -1,3 +1,14 @@ +/* + * Copyright 2022 ST-Lab + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + */ + package org.urbcomp.start.db.geomesa import org.apache.calcite.linq4j.{AbstractEnumerable, Enumerable, Enumerator, QueryProvider} @@ -5,21 +16,23 @@ import org.apache.calcite.schema.SchemaPlus import org.apache.calcite.schema.impl.AbstractTableQueryable /** - * Queryable for Geomesa - * - * @param provider QueryProvider - * @param schema SchemaPlus - * @param table geomesa table - * @param tableName table name - * @tparam T type - * - * @author zaiyuan - * @since 0.1.0 - */ -class GeomesaQueryable[T](provider: QueryProvider, - schema: SchemaPlus, - table: GeomesaTable, - tableName: String) extends AbstractTableQueryable[T](provider, schema, table, tableName){ + * Queryable for Geomesa + * + * @param provider QueryProvider + * @param schema SchemaPlus + * @param table geomesa table + * @param tableName table name + * @tparam T type + * + * @author zaiyuan + * @since 0.1.0 + */ +class GeomesaQueryable[T]( + provider: QueryProvider, + schema: SchemaPlus, + table: GeomesaTable, + tableName: String +) extends AbstractTableQueryable[T](provider, schema, table, tableName) { override def enumerator(): Enumerator[T] = query(null, null, null).asInstanceOf[Enumerable[T]].enumerator() diff --git a/core/src/main/scala/org/urbcomp/start/db/geomesa/GeomesaSchema.scala b/core/src/main/scala/org/urbcomp/start/db/geomesa/GeomesaSchema.scala index 3b39b1a6..f98d80fc 100644 --- a/core/src/main/scala/org/urbcomp/start/db/geomesa/GeomesaSchema.scala +++ b/core/src/main/scala/org/urbcomp/start/db/geomesa/GeomesaSchema.scala @@ -1,3 +1,14 @@ +/* + * Copyright 2022 ST-Lab + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + */ + package org.urbcomp.start.db.geomesa import org.apache.calcite.schema.Table @@ -7,16 +18,16 @@ import java.util import java.util.Collections /** - * Schema of Geomesa - * - * @param userName user name - * @param dbName db name - * @param tableName table name - * - * @author zaiyuan - * @since 0.1.0 - */ -class GeomesaSchema(userName: String, dbName: String, tableName: String) extends AbstractSchema{ + * Schema of Geomesa + * + * @param userName user name + * @param dbName db name + * @param tableName table name + * + * @author zaiyuan + * @since 0.1.0 + */ +class GeomesaSchema(userName: String, dbName: String, tableName: String) extends AbstractSchema { override def getTableMap: util.Map[String, Table] = Collections.singletonMap(tableName, GeomesaTable(userName, dbName, tableName)) } diff --git a/core/src/main/scala/org/urbcomp/start/db/geomesa/GeomesaSchemaFactory.scala b/core/src/main/scala/org/urbcomp/start/db/geomesa/GeomesaSchemaFactory.scala index 3747bf64..2a3b43da 100644 --- a/core/src/main/scala/org/urbcomp/start/db/geomesa/GeomesaSchemaFactory.scala +++ b/core/src/main/scala/org/urbcomp/start/db/geomesa/GeomesaSchemaFactory.scala @@ -1,3 +1,14 @@ +/* + * Copyright 2022 ST-Lab + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + */ + package org.urbcomp.start.db.geomesa import org.apache.calcite.schema.{Schema, SchemaFactory, SchemaPlus} @@ -5,16 +16,20 @@ import org.apache.calcite.schema.{Schema, SchemaFactory, SchemaPlus} import java.util /** - * Schema Factory of Geomesa - * - * @author zaiyuan - * @since 0.1.0 - */ + * Schema Factory of Geomesa + * + * @author zaiyuan + * @since 0.1.0 + */ class GeomesaSchemaFactory extends SchemaFactory { - override def create(schemaPlus: SchemaPlus, - schemaName: String, - operands: util.Map[String, AnyRef]): Schema = - new GeomesaSchema(String.valueOf(operands.get("userName")), + override def create( + schemaPlus: SchemaPlus, + schemaName: String, + operands: util.Map[String, AnyRef] + ): Schema = + new GeomesaSchema( + String.valueOf(operands.get("userName")), String.valueOf(operands.get("dbName")), - String.valueOf(operands.get("tableName"))) + String.valueOf(operands.get("tableName")) + ) } diff --git a/core/src/main/scala/org/urbcomp/start/db/geomesa/GeomesaTable.scala b/core/src/main/scala/org/urbcomp/start/db/geomesa/GeomesaTable.scala index 38af5d39..3ce5dccf 100644 --- a/core/src/main/scala/org/urbcomp/start/db/geomesa/GeomesaTable.scala +++ b/core/src/main/scala/org/urbcomp/start/db/geomesa/GeomesaTable.scala @@ -1,3 +1,14 @@ +/* + * Copyright 2022 ST-Lab + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + */ + package org.urbcomp.start.db.geomesa import org.apache.calcite.adapter.java.AbstractQueryableTable @@ -14,35 +25,44 @@ import java.lang.reflect.Type import scala.collection.JavaConverters._ /** - * Table of Geomesa - * - * @author zaiyuan - * @since 0.1.0 - * @param dataStore Geotools DataStore - * @param query Geotools Query - */ + * Table of Geomesa + * + * @author zaiyuan + * @since 0.1.0 + * @param dataStore Geotools DataStore + * @param query Geotools Query + */ case class GeomesaTable(userName: String, dbName: String, tableName: String) - extends AbstractQueryableTable(classOf[Type]) with TranslatableTable { + extends AbstractQueryableTable(classOf[Type]) + with TranslatableTable { /** - * convert table instance to table scan instance - */ + * convert table instance to table scan instance + */ override def toRel(toRelContext: RelOptTable.ToRelContext, relOptTable: RelOptTable): RelNode = - new GeomesaTableScan(toRelContext.getCluster, - toRelContext.getCluster.traitSetOf(GeomesaConstant.CONVENTION), relOptTable, this) + new GeomesaTableScan( + toRelContext.getCluster, + toRelContext.getCluster.traitSetOf(GeomesaConstant.CONVENTION), + relOptTable, + this + ) /** - * convert to queryable instance - */ - override def asQueryable[T](queryProvider: QueryProvider, schemaPlus: SchemaPlus, s: String): Queryable[T] = + * convert to queryable instance + */ + override def asQueryable[T]( + queryProvider: QueryProvider, + schemaPlus: SchemaPlus, + s: String + ): Queryable[T] = new GeomesaQueryable[T](queryProvider, schemaPlus, this, s) /** - * get Schema of the table - * - * @param relDataTypeFactory RelDataTypeFactory - * @return RelDataType - */ + * get Schema of the table + * + * @param relDataTypeFactory RelDataTypeFactory + * @return RelDataType + */ override def getRowType(relDataTypeFactory: RelDataTypeFactory): RelDataType = { val dataStore = DataStoreFinder.getDataStore(ConfigProvider.getGeomesaHbaseParam(dbName).asJava) val query = new Query(tableName) diff --git a/core/src/main/scala/org/urbcomp/start/db/geomesa/GeomesaToEnumeratorConverter.scala b/core/src/main/scala/org/urbcomp/start/db/geomesa/GeomesaToEnumeratorConverter.scala index 4f22b9e0..397f663c 100644 --- a/core/src/main/scala/org/urbcomp/start/db/geomesa/GeomesaToEnumeratorConverter.scala +++ b/core/src/main/scala/org/urbcomp/start/db/geomesa/GeomesaToEnumeratorConverter.scala @@ -1,6 +1,22 @@ +/* + * Copyright 2022 ST-Lab + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + */ + package org.urbcomp.start.db.geomesa -import org.apache.calcite.adapter.enumerable.{EnumerableRel, EnumerableRelImplementor, JavaRowFormat, PhysTypeImpl} +import org.apache.calcite.adapter.enumerable.{ + EnumerableRel, + EnumerableRelImplementor, + JavaRowFormat, + PhysTypeImpl +} import org.apache.calcite.linq4j.tree.{BlockBuilder, Expressions, Types} import org.apache.calcite.plan.{ConventionTraitDef, RelOptCluster, RelTraitSet} import org.apache.calcite.rel.AbstractRelNode.sole @@ -15,35 +31,46 @@ import java.util import scala.collection.JavaConverters._ /** - * convert geomesa to enumerator - * - * @param cluster RelOptCluster - * @param traits RelTraitSet - * @param input RelNode - * @author zaiyuan - * @since 0.1.0 - */ -class GeomesaToEnumeratorConverter(cluster: RelOptCluster, - traits: RelTraitSet, - input: RelNode) - extends ConverterImpl(cluster, ConventionTraitDef.INSTANCE, traits, input) with EnumerableRel { + * convert geomesa to enumerator + * + * @param cluster RelOptCluster + * @param traits RelTraitSet + * @param input RelNode + * @author zaiyuan + * @since 0.1.0 + */ +class GeomesaToEnumeratorConverter(cluster: RelOptCluster, traits: RelTraitSet, input: RelNode) + extends ConverterImpl(cluster, ConventionTraitDef.INSTANCE, traits, input) + with EnumerableRel { val method: Method = - Types.lookupMethod(classOf[GeomesaQueryable[_]], "query", classOf[String], classOf[String], classOf[String]) + Types.lookupMethod( + classOf[GeomesaQueryable[_]], + "query", + classOf[String], + classOf[String], + classOf[String] + ) - override def implement(enumerableRelImplementor: EnumerableRelImplementor, - prefer: EnumerableRel.Prefer): EnumerableRel.Result = { + override def implement( + enumerableRelImplementor: EnumerableRelImplementor, + prefer: EnumerableRel.Prefer + ): EnumerableRel.Result = { val builder = new BlockBuilder val rowType = getRowType - val physType = PhysTypeImpl.of(enumerableRelImplementor.getTypeFactory, rowType, JavaRowFormat.ARRAY) + val physType = + PhysTypeImpl.of(enumerableRelImplementor.getTypeFactory, rowType, JavaRowFormat.ARRAY) val query = new GeomesaQuery recursiveWrap(getInput, query) - val tableInstance = builder.append("TABLE", query.getRelOptTable.getExpression(classOf[GeomesaQueryable[_]])) + val tableInstance = + builder.append("TABLE", query.getRelOptTable.getExpression(classOf[GeomesaQueryable[_]])) val dbNameInstance = builder.append("DBNAME", Expressions.constant(query.getDbName)) val tableNameInstance = builder.append("TABLENAME", Expressions.constant(query.getTableName)) val filterInstance = builder.append("FILTER", Expressions.constant(ECQL.toCQL(query.getFilter))) - val enumeration = builder.append("ENUMERATOR", - Expressions.call(tableInstance, method, filterInstance, tableNameInstance, dbNameInstance)) + val enumeration = builder.append( + "ENUMERATOR", + Expressions.call(tableInstance, method, filterInstance, tableNameInstance, dbNameInstance) + ) builder.add(Expressions.return_(null, enumeration)) enumerableRelImplementor.result(physType, builder.toBlock) } @@ -55,7 +82,7 @@ class GeomesaToEnumeratorConverter(cluster: RelOptCluster, def wrap(input: RelNode, query: GeomesaQuery): Unit = input match { case i: IGeomesaRelNode => i.wrap(query) - case _ => + case _ => } override def copy(traitSet: RelTraitSet, inputs: util.List[RelNode]): RelNode = diff --git a/core/src/main/scala/org/urbcomp/start/db/geomesa/package.scala b/core/src/main/scala/org/urbcomp/start/db/geomesa/package.scala index bbb30c06..6abc18f9 100644 --- a/core/src/main/scala/org/urbcomp/start/db/geomesa/package.scala +++ b/core/src/main/scala/org/urbcomp/start/db/geomesa/package.scala @@ -1,3 +1,14 @@ +/* + * Copyright 2022 ST-Lab + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + */ + package org.urbcomp.start.db import org.geotools.filter.FilterFactoryImpl diff --git a/core/src/main/scala/org/urbcomp/start/db/geomesa/rel/GeomesaFilter.scala b/core/src/main/scala/org/urbcomp/start/db/geomesa/rel/GeomesaFilter.scala index 63c00461..af386d02 100644 --- a/core/src/main/scala/org/urbcomp/start/db/geomesa/rel/GeomesaFilter.scala +++ b/core/src/main/scala/org/urbcomp/start/db/geomesa/rel/GeomesaFilter.scala @@ -1,3 +1,14 @@ +/* + * Copyright 2022 ST-Lab + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + */ + package org.urbcomp.start.db.geomesa.rel import org.apache.calcite.plan.{RelOptCluster, RelTraitSet} @@ -17,85 +28,103 @@ import java.util import scala.collection.JavaConverters._ /** - * This class is specially used to convert the original filter conditions into the table - * filter expressions required by geomesa - * - * @param cluster RelOptCluster - * @param traits RelTraitSet - * @param child RelNode - * @param condition RexNode - * - * @author zaiyuan - * @date 2022/05/21 - */ -class GeomesaFilter(cluster: RelOptCluster, - traits: RelTraitSet, - child: RelNode, - rowType: RelDataType, - condition: RexNode) extends CalciteFilter(cluster, traits, child, condition) with IGeomesaRelNode { + * This class is specially used to convert the original filter conditions into the table + * filter expressions required by geomesa + * + * @param cluster RelOptCluster + * @param traits RelTraitSet + * @param child RelNode + * @param condition RexNode + * + * @author zaiyuan + * @date 2022/05/21 + */ +class GeomesaFilter( + cluster: RelOptCluster, + traits: RelTraitSet, + child: RelNode, + rowType: RelDataType, + condition: RexNode +) extends CalciteFilter(cluster, traits, child, condition) + with IGeomesaRelNode { - val fieldList: util.List[String] = SqlValidatorUtil.uniquify(rowType.getFieldNames, SqlValidatorUtil.EXPR_SUGGESTER, true) + val fieldList: util.List[String] = + SqlValidatorUtil.uniquify(rowType.getFieldNames, SqlValidatorUtil.EXPR_SUGGESTER, true) /** - * Convert RexNode to GeoTools Filter - * - * @param node RexNode - * @return GeoTools Filter - */ + * Convert RexNode to GeoTools Filter + * + * @param node RexNode + * @return GeoTools Filter + */ def convertFilter(node: RexNode): GeoToolsFilter = { val call = node.asInstanceOf[RexCall] node.getKind match { // Unary Logic Converter - case EQUALS => ff.equals(convertExpr(call.operands.get(0)), convertExpr(call.operands.get(1))) - case NOT_EQUALS => ff.notEqual(convertExpr(call.operands.get(0)), convertExpr(call.operands.get(1))) - case LESS_THAN => ff.less(convertExpr(call.operands.get(0)), convertExpr(call.operands.get(1))) - case LESS_THAN_OR_EQUAL => ff.lessOrEqual(convertExpr(call.operands.get(0)), convertExpr(call.operands.get(1))) - case GREATER_THAN => ff.greater(convertExpr(call.operands.get(0)), convertExpr(call.operands.get(1))) - case GREATER_THAN_OR_EQUAL => ff.greaterOrEqual(convertExpr(call.operands.get(0)), convertExpr(call.operands.get(1))) - case LIKE => ff.like(convertExpr(call.operands.get(0)), call.operands.get(1).toString) - case IS_NULL => ff.isNull(convertExpr(call.operands.get(0))) + case EQUALS => ff.equals(convertExpr(call.operands.get(0)), convertExpr(call.operands.get(1))) + case NOT_EQUALS => + ff.notEqual(convertExpr(call.operands.get(0)), convertExpr(call.operands.get(1))) + case LESS_THAN => + ff.less(convertExpr(call.operands.get(0)), convertExpr(call.operands.get(1))) + case LESS_THAN_OR_EQUAL => + ff.lessOrEqual(convertExpr(call.operands.get(0)), convertExpr(call.operands.get(1))) + case GREATER_THAN => + ff.greater(convertExpr(call.operands.get(0)), convertExpr(call.operands.get(1))) + case GREATER_THAN_OR_EQUAL => + ff.greaterOrEqual(convertExpr(call.operands.get(0)), convertExpr(call.operands.get(1))) + case LIKE => ff.like(convertExpr(call.operands.get(0)), call.operands.get(1).toString) + case IS_NULL => ff.isNull(convertExpr(call.operands.get(0))) // Binary Logic Converter - case AND => ff.and(convertFilter(call.operands.get(0)), convertFilter(call.operands.get(1))) - case OR => ff.or(convertFilter(call.operands.get(0)), convertFilter(call.operands.get(1))) - case NOT => ff.not(convertFilter(call.operands.get(0))) + case AND => ff.and(convertFilter(call.operands.get(0)), convertFilter(call.operands.get(1))) + case OR => ff.or(convertFilter(call.operands.get(0)), convertFilter(call.operands.get(1))) + case NOT => ff.not(convertFilter(call.operands.get(0))) // GeoTools Spatial Function Converter case OTHER_FUNCTION => call.op.toString match { - case GeomesaConstant.ST_CONTAINS => ff.contains(convertExpr(call.operands.get(0)), convertExpr(call.operands.get(1))) - case GeomesaConstant.ST_CROSSES => ff.crosses(convertExpr(call.operands.get(0)), convertExpr(call.operands.get(1))) - case GeomesaConstant.ST_DISJOINT => ff.disjoint(convertExpr(call.operands.get(0)), convertExpr(call.operands.get(1))) - case GeomesaConstant.ST_EQUALS => ff.equals(convertExpr(call.operands.get(0)), convertExpr(call.operands.get(1))) - case GeomesaConstant.ST_INTERSECTS => ff.intersects(convertExpr(call.operands.get(0)), convertExpr(call.operands.get(1))) - case GeomesaConstant.ST_OVERLAPS => ff.overlaps(convertExpr(call.operands.get(0)), convertExpr(call.operands.get(1))) - case GeomesaConstant.ST_TOUCHES => ff.touches(convertExpr(call.operands.get(0)), convertExpr(call.operands.get(1))) - case GeomesaConstant.ST_WITHIN => ff.within(convertExpr(call.operands.get(0)), convertExpr(call.operands.get(1))) + case GeomesaConstant.ST_CONTAINS => + ff.contains(convertExpr(call.operands.get(0)), convertExpr(call.operands.get(1))) + case GeomesaConstant.ST_CROSSES => + ff.crosses(convertExpr(call.operands.get(0)), convertExpr(call.operands.get(1))) + case GeomesaConstant.ST_DISJOINT => + ff.disjoint(convertExpr(call.operands.get(0)), convertExpr(call.operands.get(1))) + case GeomesaConstant.ST_EQUALS => + ff.equals(convertExpr(call.operands.get(0)), convertExpr(call.operands.get(1))) + case GeomesaConstant.ST_INTERSECTS => + ff.intersects(convertExpr(call.operands.get(0)), convertExpr(call.operands.get(1))) + case GeomesaConstant.ST_OVERLAPS => + ff.overlaps(convertExpr(call.operands.get(0)), convertExpr(call.operands.get(1))) + case GeomesaConstant.ST_TOUCHES => + ff.touches(convertExpr(call.operands.get(0)), convertExpr(call.operands.get(1))) + case GeomesaConstant.ST_WITHIN => + ff.within(convertExpr(call.operands.get(0)), convertExpr(call.operands.get(1))) } } } /** - * Convert RexNode to GeoTools Expression - * - * @param rex RexNode - * @return Expression - */ + * Convert RexNode to GeoTools Expression + * + * @param rex RexNode + * @return Expression + */ private def convertExpr(rex: RexNode): Expression = rex match { case r: RexCall => r.getKind match { - case OTHER_FUNCTION => ff.function(r.op.toString, r.operands.asScala.map(convertExpr).toArray) - case PLUS => ff.add(convertExpr(r.operands.get(0)), convertExpr(r.operands.get(1))) - case MINUS => ff.subtract(convertExpr(r.operands.get(0)), convertExpr(r.operands.get(1))) - case TIMES => ff.multiply(convertExpr(r.operands.get(0)), convertExpr(r.operands.get(1))) - case DIVIDE => ff.divide(convertExpr(r.operands.get(0)), convertExpr(r.operands.get(1))) + case OTHER_FUNCTION => + ff.function(r.op.toString, r.operands.asScala.map(convertExpr).toArray) + case PLUS => ff.add(convertExpr(r.operands.get(0)), convertExpr(r.operands.get(1))) + case MINUS => ff.subtract(convertExpr(r.operands.get(0)), convertExpr(r.operands.get(1))) + case TIMES => ff.multiply(convertExpr(r.operands.get(0)), convertExpr(r.operands.get(1))) + case DIVIDE => ff.divide(convertExpr(r.operands.get(0)), convertExpr(r.operands.get(1))) // TODO // Cast is a basic operation of SQL, which contains many situations. However, OpenGIS itself does not support // cast, so some complex operations have not been implemented. Now only relatively simple logic (simple fields // and values) are implemented. The nested operations contained in it will be implemented later. - case CAST => convertExpr(r.operands.get(0)) - case _ => throw new Exception("Unsupported operator") + case CAST => convertExpr(r.operands.get(0)) + case _ => throw new Exception("Unsupported operator") } - case r: RexInputRef => ff.property(fieldList.get(r.getIndex)) - case r: RexLiteral => ff.literal(RexLiteral.value(r)) + case r: RexInputRef => ff.property(fieldList.get(r.getIndex)) + case r: RexLiteral => ff.literal(RexLiteral.value(r)) } override def copy(traitSet: RelTraitSet, input: RelNode, condition: RexNode): CalciteFilter = diff --git a/core/src/main/scala/org/urbcomp/start/db/geomesa/rel/GeomesaTableScan.scala b/core/src/main/scala/org/urbcomp/start/db/geomesa/rel/GeomesaTableScan.scala index 395ec4dc..df4b9d69 100644 --- a/core/src/main/scala/org/urbcomp/start/db/geomesa/rel/GeomesaTableScan.scala +++ b/core/src/main/scala/org/urbcomp/start/db/geomesa/rel/GeomesaTableScan.scala @@ -1,3 +1,14 @@ +/* + * Copyright 2022 ST-Lab + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + */ + package org.urbcomp.start.db.geomesa.rel import com.google.common.collect.ImmutableList @@ -10,34 +21,37 @@ import org.urbcomp.start.db.core.geomesa.rules.{GeomesaFilterRule, GeomesaToEnum import org.urbcomp.start.db.geomesa.GeomesaTable /** - * This class is used to encapsulate the geomesa table scanning logic. - * - * @param cluster RelOptCluster - * @param traitSet RelTraitSet - * @param table RelOptTable - * @param geomesaTable GeomesaTable - * - * @author zaiyuan - * @date 2022/05/02 - */ -class GeomesaTableScan(cluster: RelOptCluster, - traitSet: RelTraitSet, - table: RelOptTable, - val geomesaTable: GeomesaTable) extends TableScan(cluster, traitSet, ImmutableList.of[RelHint], table) with IGeomesaRelNode { + * This class is used to encapsulate the geomesa table scanning logic. + * + * @param cluster RelOptCluster + * @param traitSet RelTraitSet + * @param table RelOptTable + * @param geomesaTable GeomesaTable + * + * @author zaiyuan + * @date 2022/05/02 + */ +class GeomesaTableScan( + cluster: RelOptCluster, + traitSet: RelTraitSet, + table: RelOptTable, + val geomesaTable: GeomesaTable +) extends TableScan(cluster, traitSet, ImmutableList.of[RelHint], table) + with IGeomesaRelNode { /** - * Regist Rule into planner - * @param planner Query Plannner - */ + * Regist Rule into planner + * @param planner Query Plannner + */ override def register(planner: RelOptPlanner): Unit = { planner.addRule(GeomesaToEnumerableConverterRule.INSTANCE) planner.addRule(GeomesaFilterRule.Config.DEFAULT.toRule) } /** - * wrap message into query - * @param query GeomesaQuery - */ + * wrap message into query + * @param query GeomesaQuery + */ override def wrap(query: GeomesaQuery): Unit = { query.setUserName(geomesaTable.userName) query.setDbName(geomesaTable.dbName) diff --git a/core/src/main/scala/org/urbcomp/start/db/geomesa/rel/IGeomesaRelNode.scala b/core/src/main/scala/org/urbcomp/start/db/geomesa/rel/IGeomesaRelNode.scala index 1d4eefa7..222d3877 100644 --- a/core/src/main/scala/org/urbcomp/start/db/geomesa/rel/IGeomesaRelNode.scala +++ b/core/src/main/scala/org/urbcomp/start/db/geomesa/rel/IGeomesaRelNode.scala @@ -1,14 +1,25 @@ +/* + * Copyright 2022 ST-Lab + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + */ + package org.urbcomp.start.db.geomesa.rel import org.apache.calcite.rel.RelNode import org.urbcomp.start.db.core.geomesa.model.GeomesaQuery /** - * RelNode Trait for Geomesa. - * - * @author zaiyuan - * @date 2022/05/01 - */ + * RelNode Trait for Geomesa. + * + * @author zaiyuan + * @date 2022/05/01 + */ trait IGeomesaRelNode extends RelNode { def wrap(query: GeomesaQuery): Unit } diff --git a/core/src/test/java/org/urbancomp/start/db/MiniHBaseCluster.java b/core/src/test/java/org/urbancomp/start/db/MiniHBaseCluster.java index fcccbf26..9ce7f04e 100644 --- a/core/src/test/java/org/urbancomp/start/db/MiniHBaseCluster.java +++ b/core/src/test/java/org/urbancomp/start/db/MiniHBaseCluster.java @@ -1,3 +1,14 @@ +/* + * Copyright 2022 ST-Lab + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + */ + package org.urbancomp.start.db; import org.apache.hadoop.hbase.HBaseTestingUtility; @@ -8,9 +19,7 @@ import org.slf4j.LoggerFactory; /** - * start an embedded hbase cluster for unit test - * bind ZK to 0.0.0.0/2181 - * need HADOOP_HOME on windows + * start an embedded hbase cluster for unit test bind ZK to 0.0.0.0/2181 need HADOOP_HOME on windows * * @author jimo */ @@ -28,8 +37,9 @@ public static void start() throws Exception { logger.info("Starting embedded hbase"); cluster.getConfiguration().set("hbase.superuser", "admin"); // bind geomesa coprocessor - cluster.getConfiguration().set(CoprocessorHost.USER_REGION_COPROCESSOR_CONF_KEY, HBaseIndexAdapter.CoprocessorClass()); - // cluster.startMiniCluster(sys.props.get("geomesa.hbase.test.region.servers").map(_.toInt).getOrElse(2)) + cluster.getConfiguration().set(CoprocessorHost.USER_REGION_COPROCESSOR_CONF_KEY, + HBaseIndexAdapter.CoprocessorClass()); + // cluster.startMiniCluster(sys.props.get("geomesa.hbase.test.region.servers").map(_.toInt).getOrElse(2)) cluster.startMiniHBaseCluster(); logger.info("Started embedded hbase"); } diff --git a/core/src/test/java/org/urbancomp/start/db/UserAccessorTest.java b/core/src/test/java/org/urbancomp/start/db/UserAccessorTest.java index 28b12ad6..ab7aa4fa 100644 --- a/core/src/test/java/org/urbancomp/start/db/UserAccessorTest.java +++ b/core/src/test/java/org/urbancomp/start/db/UserAccessorTest.java @@ -1,3 +1,14 @@ +/* + * Copyright 2022 ST-Lab + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + */ + package org.urbancomp.start.db; import org.junit.Test; diff --git a/core/src/test/scala/org/urbcomp/start/db/CalciteGeomesaTest.scala b/core/src/test/scala/org/urbcomp/start/db/CalciteGeomesaTest.scala index 7dbd90e4..dead011e 100644 --- a/core/src/test/scala/org/urbcomp/start/db/CalciteGeomesaTest.scala +++ b/core/src/test/scala/org/urbcomp/start/db/CalciteGeomesaTest.scala @@ -1,3 +1,14 @@ +/* + * Copyright 2022 ST-Lab + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + */ + package org.urbcomp.start.db import org.junit.Assert.assertNotNull @@ -9,11 +20,11 @@ import java.sql.DriverManager import java.util.Properties /** - * Test for Calcite and Geomesa - * - * @author zaiyuan - * @since 0.1.0 - */ + * Test for Calcite and Geomesa + * + * @author zaiyuan + * @since 0.1.0 + */ class CalciteGeomesaTest extends FunSuite with BeforeAndAfterAll { var config: Properties = _ diff --git a/pom.xml b/pom.xml index 60e0a3ee..fd674081 100644 --- a/pom.xml +++ b/pom.xml @@ -1,7 +1,6 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.urbcomp @@ -261,12 +260,21 @@ - conventions/eclipse-formatter.xml + ${maven.multiModuleProjectDirectory}/conventions/eclipse-formatter.xml - conventions/license-header + ${maven.multiModuleProjectDirectory}/conventions/license-header + + + 2.0.1 + ${maven.multiModuleProjectDirectory}/conventions/scalafmt.conf + + + ${maven.multiModuleProjectDirectory}/conventions/license-header + + @@ -279,4 +287,4 @@ - \ No newline at end of file + diff --git a/test/embedded-mysql/src/main/java/org/urbcomp/start/db/test/MySQLServerInit.java b/test/embedded-mysql/src/main/java/org/urbcomp/start/db/test/MySQLServerInit.java index 66b6c924..fdbb624d 100644 --- a/test/embedded-mysql/src/main/java/org/urbcomp/start/db/test/MySQLServerInit.java +++ b/test/embedded-mysql/src/main/java/org/urbcomp/start/db/test/MySQLServerInit.java @@ -1,3 +1,14 @@ +/* + * Copyright 2022 ST-Lab + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + */ + package org.urbcomp.start.db.test; import java.nio.file.Files; @@ -24,8 +35,12 @@ public static void init() throws Exception { String user = "start_db"; String password = "start_db"; Class.forName("com.mysql.cj.jdbc.Driver"); - final String sqlTxt = Files.readAllLines(Paths.get("core/src/main/resources/metadata/ddl.sql")) - .stream().filter(line -> !line.trim().startsWith("#") && !line.trim().startsWith("--")).collect(Collectors.joining()); + final String sqlTxt = + Files.readAllLines(Paths.get("core/src/main/resources/metadata/ddl.sql")) + .stream() + .filter(line -> !line.trim().startsWith("#") + && !line.trim().startsWith("--")) + .collect(Collectors.joining()); final String[] sqlList = sqlTxt.split(";"); try (Connection conn = DriverManager.getConnection(jdbcUrl, user, password)) { for (String sql : sqlList) { diff --git a/test/mini-hbase/pom.xml b/test/mini-hbase/pom.xml index 2a948148..a807ef1d 100644 --- a/test/mini-hbase/pom.xml +++ b/test/mini-hbase/pom.xml @@ -1,12 +1,12 @@ - + + --> 4.0.0 org.urbcomp @@ -72,8 +72,7 @@ - + org.urbcomp.start.db.test.MiniHBaseCluster diff --git a/test/mini-hbase/src/main/java/org/urbcomp/start/db/test/MiniHBaseCluster.java b/test/mini-hbase/src/main/java/org/urbcomp/start/db/test/MiniHBaseCluster.java index e26c12da..2813234c 100644 --- a/test/mini-hbase/src/main/java/org/urbcomp/start/db/test/MiniHBaseCluster.java +++ b/test/mini-hbase/src/main/java/org/urbcomp/start/db/test/MiniHBaseCluster.java @@ -1,3 +1,16 @@ +/* + * Copyright 2022 ST-Lab + + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + package org.urbcomp.start.db.test; import org.apache.hadoop.hbase.HBaseTestingUtility; @@ -8,9 +21,7 @@ import org.slf4j.LoggerFactory; /** - * start a embedded hbase cluster for unit test - * bind ZK to 0.0.0.0/2181 - * need HADOOP_HOME + * start a embedded hbase cluster for unit test bind ZK to 0.0.0.0/2181 need HADOOP_HOME * * @author jimo */ @@ -26,8 +37,9 @@ public static void main(String[] args) throws Exception { logger.info("Starting embedded hbase"); cluster.getConfiguration().set("hbase.superuser", "admin"); // bind geomesa coprocessor - cluster.getConfiguration().set(CoprocessorHost.USER_REGION_COPROCESSOR_CONF_KEY, HBaseIndexAdapter.CoprocessorClass()); - // cluster.startMiniCluster(sys.props.get("geomesa.hbase.test.region.servers").map(_.toInt).getOrElse(2)) + cluster.getConfiguration().set(CoprocessorHost.USER_REGION_COPROCESSOR_CONF_KEY, + HBaseIndexAdapter.CoprocessorClass()); + // cluster.startMiniCluster(sys.props.get("geomesa.hbase.test.region.servers").map(_.toInt).getOrElse(2)) cluster.startMiniHBaseCluster(); logger.info("Started embedded hbase"); } diff --git a/test/pom.xml b/test/pom.xml index b536edb0..95100e99 100644 --- a/test/pom.xml +++ b/test/pom.xml @@ -18,7 +18,6 @@ - mini-hbase embedded-mysql \ No newline at end of file