This is an automated email from the ASF dual-hosted git repository.
menghaoran pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 55de153 Rename ExecuteGroupEngine.group() (#8262)
55de153 is described below
commit 55de153adc6f47bf73d717073bed80c65981e3b7
Author: Liang Zhang <[email protected]>
AuthorDate: Sat Nov 21 13:34:26 2020 +0800
Rename ExecuteGroupEngine.group() (#8262)
* Rename ExecuteGroupEngine.group()
* Rename AbstractExecuteGroupEngine.group()
---
.../infra/executor/sql/group/AbstractExecuteGroupEngine.java | 8 ++++----
.../infra/executor/sql/group/ExecuteGroupEngine.java | 4 ++--
.../infra/executor/sql/raw/group/RawExecuteGroupEngine.java | 2 +-
.../sql/resourced/group/ResourceManagedExecuteGroupEngine.java | 2 +-
.../jdbc/group/PreparedStatementExecuteGroupEngineTest.java | 6 +++---
.../sql/execute/jdbc/group/StatementExecuteGroupEngineTest.java | 6 +++---
.../jdbc/core/statement/ShardingSpherePreparedStatement.java | 6 +++---
.../driver/jdbc/core/statement/ShardingSphereStatement.java | 4 ++--
.../communication/jdbc/execute/engine/jdbc/JDBCExecuteEngine.java | 4 ++--
9 files changed, 21 insertions(+), 21 deletions(-)
diff --git
a/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/group/AbstractExecuteGroupEngine.java
b/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/group/AbstractExecuteGroupEngine.java
index a1509e0..c8a5436 100644
---
a/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/group/AbstractExecuteGroupEngine.java
+++
b/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/group/AbstractExecuteGroupEngine.java
@@ -52,14 +52,16 @@ public abstract class AbstractExecuteGroupEngine<T>
implements ExecuteGroupEngin
}
@Override
- public final Collection<InputGroup<T>> generate(final RouteContext
routeContext, final Collection<ExecutionUnit> executionUnits) throws
SQLException {
+ public final Collection<InputGroup<T>> group(final RouteContext
routeContext, final Collection<ExecutionUnit> executionUnits) throws
SQLException {
Collection<InputGroup<T>> result = new LinkedList<>();
for (Entry<String, List<SQLUnit>> entry :
aggregateSQLUnitGroups(executionUnits).entrySet()) {
- result.addAll(generateSQLExecuteGroups(entry.getKey(),
entry.getValue()));
+ result.addAll(group(entry.getKey(), entry.getValue()));
}
return decorate(routeContext, result);
}
+ protected abstract List<InputGroup<T>> group(String dataSourceName,
List<SQLUnit> sqlUnits) throws SQLException;
+
private Map<String, List<SQLUnit>> aggregateSQLUnitGroups(final
Collection<ExecutionUnit> executionUnits) {
Map<String, List<SQLUnit>> result = new
LinkedHashMap<>(executionUnits.size(), 1);
for (ExecutionUnit each : executionUnits) {
@@ -71,8 +73,6 @@ public abstract class AbstractExecuteGroupEngine<T>
implements ExecuteGroupEngin
return result;
}
- protected abstract List<InputGroup<T>> generateSQLExecuteGroups(String
dataSourceName, List<SQLUnit> sqlUnits) throws SQLException;
-
@SuppressWarnings({"unchecked", "rawtypes"})
private Collection<InputGroup<T>> decorate(final RouteContext
routeContext, final Collection<InputGroup<T>> inputGroups) {
Collection<InputGroup<T>> result = inputGroups;
diff --git
a/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/group/ExecuteGroupEngine.java
b/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/group/ExecuteGroupEngine.java
index 7641194..ad387d6 100644
---
a/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/group/ExecuteGroupEngine.java
+++
b/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/group/ExecuteGroupEngine.java
@@ -32,12 +32,12 @@ import java.util.Collection;
public interface ExecuteGroupEngine<T> {
/**
- * Generate execution input groups.
+ * Group execution units.
*
* @param routeContext route context
* @param executionUnits execution units
* @return execution input groups
* @throws SQLException SQL exception
*/
- Collection<InputGroup<T>> generate(RouteContext routeContext,
Collection<ExecutionUnit> executionUnits) throws SQLException;
+ Collection<InputGroup<T>> group(RouteContext routeContext,
Collection<ExecutionUnit> executionUnits) throws SQLException;
}
diff --git
a/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/raw/group/RawExecuteGroupEngine.java
b/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/raw/group/RawExecuteGroupEngine.java
index 9efb329..3908ed7 100644
---
a/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/raw/group/RawExecuteGroupEngine.java
+++
b/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/raw/group/RawExecuteGroupEngine.java
@@ -43,7 +43,7 @@ public final class RawExecuteGroupEngine extends
AbstractExecuteGroupEngine<RawS
}
@Override
- protected List<InputGroup<RawSQLExecuteUnit>>
generateSQLExecuteGroups(final String dataSourceName, final List<SQLUnit>
sqlUnits) {
+ protected List<InputGroup<RawSQLExecuteUnit>> group(final String
dataSourceName, final List<SQLUnit> sqlUnits) {
List<InputGroup<RawSQLExecuteUnit>> result = new LinkedList<>();
int desiredPartitionSize = Math.max(0 == sqlUnits.size() %
maxConnectionsSizePerQuery ? sqlUnits.size() / maxConnectionsSizePerQuery :
sqlUnits.size() / maxConnectionsSizePerQuery + 1, 1);
List<List<SQLUnit>> sqlUnitPartitions = Lists.partition(sqlUnits,
desiredPartitionSize);
diff --git
a/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/resourced/group/ResourceManagedExecuteGroupEngine.java
b/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/resourced/group/ResourceManagedExecuteGroupEngine.java
index 164b7b9..565c9ca 100644
---
a/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/resourced/group/ResourceManagedExecuteGroupEngine.java
+++
b/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/resourced/group/ResourceManagedExecuteGroupEngine.java
@@ -58,7 +58,7 @@ public abstract class ResourceManagedExecuteGroupEngine
}
@Override
- protected final List<InputGroup<U>> generateSQLExecuteGroups(final String
dataSourceName, final List<SQLUnit> sqlUnits) throws SQLException {
+ protected final List<InputGroup<U>> group(final String dataSourceName,
final List<SQLUnit> sqlUnits) throws SQLException {
List<InputGroup<U>> result = new LinkedList<>();
int desiredPartitionSize = Math.max(0 == sqlUnits.size() %
maxConnectionsSizePerQuery ? sqlUnits.size() / maxConnectionsSizePerQuery :
sqlUnits.size() / maxConnectionsSizePerQuery + 1, 1);
List<List<SQLUnit>> sqlUnitPartitions = Lists.partition(sqlUnits,
desiredPartitionSize);
diff --git
a/shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/execute/jdbc/group/PreparedStatementExecuteGroupEngineTest.java
b/shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/execute/jdbc/group/PreparedStatementExecuteGroupEngineTest.java
index 2321c8d..94d5700 100644
---
a/shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/execute/jdbc/group/PreparedStatementExecuteGroupEngineTest.java
+++
b/shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/execute/jdbc/group/PreparedStatementExecuteGroupEngineTest.java
@@ -54,7 +54,7 @@ public final class PreparedStatementExecuteGroupEngineTest {
public void assertGetExecuteUnitGroupForOneShardMemoryStrictly() throws
SQLException {
preparedStatementExecuteGroupEngine = new
PreparedStatementExecuteGroupEngine(
2, mockExecutionConnection(1, ConnectionMode.MEMORY_STRICTLY),
new StatementOption(true),
Collections.singletonList(mock(ShardingSphereRule.class)));
- Collection<InputGroup<StatementExecuteUnit>> actual =
preparedStatementExecuteGroupEngine.generate(mock(RouteContext.class),
mockShardRouteUnit(1, 1));
+ Collection<InputGroup<StatementExecuteUnit>> actual =
preparedStatementExecuteGroupEngine.group(mock(RouteContext.class),
mockShardRouteUnit(1, 1));
assertThat(actual.size(), is(1));
for (InputGroup<StatementExecuteUnit> each : actual) {
assertThat(each.getInputs().size(), is(1));
@@ -65,7 +65,7 @@ public final class PreparedStatementExecuteGroupEngineTest {
public void assertGetExecuteUnitGroupForMultiShardConnectionStrictly()
throws SQLException {
preparedStatementExecuteGroupEngine = new
PreparedStatementExecuteGroupEngine(
1, mockExecutionConnection(1,
ConnectionMode.CONNECTION_STRICTLY), new StatementOption(true),
Collections.singletonList(mock(ShardingSphereRule.class)));
- Collection<InputGroup<StatementExecuteUnit>> actual =
preparedStatementExecuteGroupEngine.generate(mock(RouteContext.class),
mockShardRouteUnit(10, 2));
+ Collection<InputGroup<StatementExecuteUnit>> actual =
preparedStatementExecuteGroupEngine.group(mock(RouteContext.class),
mockShardRouteUnit(10, 2));
assertThat(actual.size(), is(10));
for (InputGroup<StatementExecuteUnit> each : actual) {
assertThat(each.getInputs().size(), is(2));
@@ -85,7 +85,7 @@ public final class PreparedStatementExecuteGroupEngineTest {
private Collection<ExecutionUnit> mockShardRouteUnit(final int shardCount,
final int sizePerShard) {
Collection<ExecutionUnit> result = new ArrayList<>(shardCount *
sizePerShard);
for (int i = 0; i < shardCount; i++) {
- result.addAll(mockOneShard("ds_" + i, sizePerShard));
+ result.addAll(mockOneShard(String.format("ds_%s", i),
sizePerShard));
}
return result;
}
diff --git
a/shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/execute/jdbc/group/StatementExecuteGroupEngineTest.java
b/shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/execute/jdbc/group/StatementExecuteGroupEngineTest.java
index 43ca5a3..18ddddd 100644
---
a/shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/execute/jdbc/group/StatementExecuteGroupEngineTest.java
+++
b/shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/execute/jdbc/group/StatementExecuteGroupEngineTest.java
@@ -54,7 +54,7 @@ public final class StatementExecuteGroupEngineTest {
public void assertGetExecuteUnitGroupForOneShardMemoryStrictly() throws
SQLException {
executeGroupEngine = new StatementExecuteGroupEngine(
2, mockExecutionConnection(1, ConnectionMode.MEMORY_STRICTLY),
new StatementOption(true),
Collections.singletonList(mock(ShardingSphereRule.class)));
- Collection<InputGroup<StatementExecuteUnit>> actual =
executeGroupEngine.generate(mock(RouteContext.class), mockShardRouteUnit(1, 1));
+ Collection<InputGroup<StatementExecuteUnit>> actual =
executeGroupEngine.group(mock(RouteContext.class), mockShardRouteUnit(1, 1));
assertThat(actual.size(), is(1));
for (InputGroup<StatementExecuteUnit> each : actual) {
assertThat(each.getInputs().size(), is(1));
@@ -65,7 +65,7 @@ public final class StatementExecuteGroupEngineTest {
public void assertGetExecuteUnitGroupForMultiShardConnectionStrictly()
throws SQLException {
executeGroupEngine = new StatementExecuteGroupEngine(
1, mockExecutionConnection(1,
ConnectionMode.CONNECTION_STRICTLY), new StatementOption(true),
Collections.singletonList(mock(ShardingSphereRule.class)));
- Collection<InputGroup<StatementExecuteUnit>> actual =
executeGroupEngine.generate(mock(RouteContext.class), mockShardRouteUnit(10,
2));
+ Collection<InputGroup<StatementExecuteUnit>> actual =
executeGroupEngine.group(mock(RouteContext.class), mockShardRouteUnit(10, 2));
assertThat(actual.size(), is(10));
for (InputGroup<StatementExecuteUnit> each : actual) {
assertThat(each.getInputs().size(), is(2));
@@ -85,7 +85,7 @@ public final class StatementExecuteGroupEngineTest {
private Collection<ExecutionUnit> mockShardRouteUnit(final int shardCount,
final int sizePerShard) {
Collection<ExecutionUnit> result = new ArrayList<>(shardCount *
sizePerShard);
for (int i = 0; i < shardCount; i++) {
- result.addAll(mockOneShard("ds_" + i, sizePerShard));
+ result.addAll(mockOneShard(String.format("ds_%s", i),
sizePerShard));
}
return result;
}
diff --git
a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSpherePreparedStatement.java
b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSpherePreparedStatement.java
index 804b2f1..b3f487f 100644
---
a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSpherePreparedStatement.java
+++
b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSpherePreparedStatement.java
@@ -213,13 +213,13 @@ public final class ShardingSpherePreparedStatement
extends AbstractPreparedState
private Collection<InputGroup<StatementExecuteUnit>> getInputGroups()
throws SQLException {
int maxConnectionsSizePerQuery =
metaDataContexts.getProps().<Integer>getValue(ConfigurationPropertyKey.MAX_CONNECTIONS_SIZE_PER_QUERY);
return new
PreparedStatementExecuteGroupEngine(maxConnectionsSizePerQuery, connection,
statementOption,
-
metaDataContexts.getDefaultMetaData().getRuleMetaData().getRules()).generate(executionContext.getRouteContext(),
executionContext.getExecutionUnits());
+
metaDataContexts.getDefaultMetaData().getRuleMetaData().getRules()).group(executionContext.getRouteContext(),
executionContext.getExecutionUnits());
}
private Collection<InputGroup<RawSQLExecuteUnit>> getRawInputGroups()
throws SQLException {
int maxConnectionsSizePerQuery =
metaDataContexts.getProps().<Integer>getValue(ConfigurationPropertyKey.MAX_CONNECTIONS_SIZE_PER_QUERY);
return new RawExecuteGroupEngine(maxConnectionsSizePerQuery,
metaDataContexts.getDefaultMetaData().getRuleMetaData().getRules())
- .generate(executionContext.getRouteContext(),
executionContext.getExecutionUnits());
+ .group(executionContext.getRouteContext(),
executionContext.getExecutionUnits());
}
@Override
@@ -358,7 +358,7 @@ public final class ShardingSpherePreparedStatement extends
AbstractPreparedState
PreparedStatementExecuteGroupEngine executeGroupEngine = new
PreparedStatementExecuteGroupEngine(
metaDataContexts.getProps().<Integer>getValue(ConfigurationPropertyKey.MAX_CONNECTIONS_SIZE_PER_QUERY),
connection, statementOption,
metaDataContexts.getDefaultMetaData().getRuleMetaData().getRules());
-
batchPreparedStatementExecutor.init(executeGroupEngine.generate(executionContext.getRouteContext(),
+
batchPreparedStatementExecutor.init(executeGroupEngine.group(executionContext.getRouteContext(),
new
ArrayList<>(batchPreparedStatementExecutor.getBatchExecutionUnits()).stream().map(BatchExecutionUnit::getExecutionUnit).collect(Collectors.toList())));
setBatchParametersForStatements();
}
diff --git
a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSphereStatement.java
b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSphereStatement.java
index 1421ea0..6a3af00 100644
---
a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSphereStatement.java
+++
b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSphereStatement.java
@@ -315,13 +315,13 @@ public final class ShardingSphereStatement extends
AbstractStatementAdapter {
private Collection<InputGroup<StatementExecuteUnit>> getInputGroups()
throws SQLException {
int maxConnectionsSizePerQuery =
metaDataContexts.getProps().<Integer>getValue(ConfigurationPropertyKey.MAX_CONNECTIONS_SIZE_PER_QUERY);
return new StatementExecuteGroupEngine(maxConnectionsSizePerQuery,
connection, statementOption,
-
metaDataContexts.getDefaultMetaData().getRuleMetaData().getRules()).generate(executionContext.getRouteContext(),
executionContext.getExecutionUnits());
+
metaDataContexts.getDefaultMetaData().getRuleMetaData().getRules()).group(executionContext.getRouteContext(),
executionContext.getExecutionUnits());
}
private Collection<InputGroup<RawSQLExecuteUnit>> getRawInputGroups()
throws SQLException {
int maxConnectionsSizePerQuery =
metaDataContexts.getProps().<Integer>getValue(ConfigurationPropertyKey.MAX_CONNECTIONS_SIZE_PER_QUERY);
return new RawExecuteGroupEngine(maxConnectionsSizePerQuery,
metaDataContexts.getDefaultMetaData().getRuleMetaData().getRules())
- .generate(executionContext.getRouteContext(),
executionContext.getExecutionUnits());
+ .group(executionContext.getRouteContext(),
executionContext.getExecutionUnits());
}
private void cacheStatements(final
Collection<InputGroup<StatementExecuteUnit>> inputGroups) {
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/execute/engine/jdbc/JDBCExecuteEngine.java
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/execute/engine/jdbc/JDBCExecuteEngine.java
index 559f465..1aa3d12 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/execute/engine/jdbc/JDBCExecuteEngine.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/execute/engine/jdbc/JDBCExecuteEngine.java
@@ -137,12 +137,12 @@ public final class JDBCExecuteEngine implements
SQLExecuteEngine {
final RouteContext routeContext) throws SQLException {
Collection<ShardingSphereRule> rules =
ProxyContext.getInstance().getMetaData(backendConnection.getSchemaName()).getRuleMetaData().getRules();
ExecuteGroupEngine executeGroupEngine =
accessor.getExecuteGroupEngine(backendConnection, maxConnectionsSizePerQuery,
new StatementOption(isReturnGeneratedKeys), rules);
- return (Collection<InputGroup<StatementExecuteUnit>>)
executeGroupEngine.generate(routeContext, executionUnits);
+ return (Collection<InputGroup<StatementExecuteUnit>>)
executeGroupEngine.group(routeContext, executionUnits);
}
private Collection<ExecuteResult> executeWithUnmanagedResource(final
ExecutionContext executionContext, final int maxConnectionsSizePerQuery) throws
SQLException {
Collection<ShardingSphereRule> rules =
ProxyContext.getInstance().getMetaData(backendConnection.getSchemaName()).getRuleMetaData().getRules();
- Collection<InputGroup<RawSQLExecuteUnit>> inputGroups = new
RawExecuteGroupEngine(maxConnectionsSizePerQuery,
rules).generate(executionContext.getRouteContext(),
+ Collection<InputGroup<RawSQLExecuteUnit>> inputGroups = new
RawExecuteGroupEngine(maxConnectionsSizePerQuery,
rules).group(executionContext.getRouteContext(),
executionContext.getExecutionUnits());
// TODO handle query header
return rawExecutor.execute(inputGroups, new RawSQLExecutorCallback());