Loading sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/jdbc/ShardingPreparedStatement.java +4 −4 Original line number Diff line number Diff line Loading @@ -23,7 +23,7 @@ import com.dangdang.ddframe.rdb.sharding.jdbc.adapter.AbstractPreparedStatementA import com.dangdang.ddframe.rdb.sharding.merger.ResultSetFactory; import com.dangdang.ddframe.rdb.sharding.parsing.parser.context.GeneratedKeyContext; import com.dangdang.ddframe.rdb.sharding.parsing.parser.context.InsertSQLContext; import com.dangdang.ddframe.rdb.sharding.routing.PreparedSQLRouter; import com.dangdang.ddframe.rdb.sharding.routing.PreparedStatementRoutingEngine; import com.dangdang.ddframe.rdb.sharding.routing.SQLExecutionUnit; import com.dangdang.ddframe.rdb.sharding.routing.SQLRouteResult; import com.google.common.base.Optional; Loading @@ -46,7 +46,7 @@ import java.util.Objects; */ public final class ShardingPreparedStatement extends AbstractPreparedStatementAdapter { private final PreparedSQLRouter preparedSQLRouteEngine; private final PreparedStatementRoutingEngine preparedStatementRoutingEngine; private final List<PreparedStatementExecutorWrapper> cachedPreparedStatementWrappers = new ArrayList<>(); Loading @@ -70,7 +70,7 @@ public final class ShardingPreparedStatement extends AbstractPreparedStatementAd ShardingPreparedStatement(final ShardingConnection shardingConnection, final String sql, final int resultSetType, final int resultSetConcurrency, final int resultSetHoldability) { super(shardingConnection, resultSetType, resultSetConcurrency, resultSetHoldability); preparedSQLRouteEngine = new PreparedSQLRouter(sql, shardingConnection.getShardingContext()); preparedStatementRoutingEngine = new PreparedStatementRoutingEngine(sql, shardingConnection.getShardingContext()); } ShardingPreparedStatement(final ShardingConnection shardingConnection, final String sql, final int autoGeneratedKeys) { Loading Loading @@ -160,7 +160,7 @@ public final class ShardingPreparedStatement extends AbstractPreparedStatementAd private List<PreparedStatementExecutorWrapper> routeSQL() throws SQLException { List<PreparedStatementExecutorWrapper> result = new ArrayList<>(); SQLRouteResult sqlRouteResult = preparedSQLRouteEngine.route(getParameters()); SQLRouteResult sqlRouteResult = preparedStatementRoutingEngine.route(getParameters()); setSqlContext(sqlRouteResult.getSqlContext()); if (sqlRouteResult.getSqlContext() instanceof InsertSQLContext) { setGeneratedKeyContext(((InsertSQLContext) sqlRouteResult.getSqlContext()).getGeneratedKeyContext()); Loading sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/jdbc/ShardingStatement.java +2 −2 Original line number Diff line number Diff line Loading @@ -25,7 +25,7 @@ import com.dangdang.ddframe.rdb.sharding.parsing.parser.context.GeneratedKeyCont import com.dangdang.ddframe.rdb.sharding.parsing.parser.context.InsertSQLContext; import com.dangdang.ddframe.rdb.sharding.parsing.parser.context.SQLContext; import com.dangdang.ddframe.rdb.sharding.routing.SQLExecutionUnit; import com.dangdang.ddframe.rdb.sharding.routing.SQLRouter; import com.dangdang.ddframe.rdb.sharding.routing.StatementRoutingEngine; import com.dangdang.ddframe.rdb.sharding.routing.SQLRouteResult; import com.google.common.base.Function; import com.google.common.collect.Iterators; Loading Loading @@ -275,7 +275,7 @@ public class ShardingStatement extends AbstractStatementAdapter { private StatementExecutor generateExecutor(final String sql) throws SQLException { StatementExecutor result = new StatementExecutor(shardingConnection.getShardingContext().getExecutorEngine()); SQLRouteResult sqlRouteResult = new SQLRouter(shardingConnection.getShardingContext()).route(sql); SQLRouteResult sqlRouteResult = new StatementRoutingEngine(shardingConnection.getShardingContext()).route(sql); if (sqlRouteResult.getSqlContext() instanceof InsertSQLContext) { generatedKeyContext = ((InsertSQLContext) sqlRouteResult.getSqlContext()).getGeneratedKeyContext(); } else { Loading sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/routing/PreparedSQLRouter.java→sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/routing/PreparedStatementRoutingEngine.java +8 −8 Original line number Diff line number Diff line Loading @@ -22,8 +22,8 @@ import com.dangdang.ddframe.rdb.sharding.jdbc.ShardingContext; import com.dangdang.ddframe.rdb.sharding.parsing.parser.context.InsertSQLContext; import com.dangdang.ddframe.rdb.sharding.parsing.parser.context.SQLContext; import com.dangdang.ddframe.rdb.sharding.rewrite.GenerateKeysUtils; import com.dangdang.ddframe.rdb.sharding.routing.engine.RouteEngine; import com.dangdang.ddframe.rdb.sharding.routing.engine.RouteEngineFactory; import com.dangdang.ddframe.rdb.sharding.routing.router.SQLRouter; import com.dangdang.ddframe.rdb.sharding.routing.router.SQLRouterFactory; import java.util.List; Loading @@ -32,19 +32,19 @@ import java.util.List; * * @author gaohongtao */ public final class PreparedSQLRouter { public final class PreparedStatementRoutingEngine { private final String logicSQL; private final RouteEngine routeEngine; private final SQLRouter sqlRouter; private final ShardingRule shardingRule; private SQLContext sqlContext; public PreparedSQLRouter(final String logicSQL, final ShardingContext shardingContext) { public PreparedStatementRoutingEngine(final String logicSQL, final ShardingContext shardingContext) { this.logicSQL = logicSQL; routeEngine = RouteEngineFactory.createRouteEngine(shardingContext); sqlRouter = SQLRouterFactory.createSQLRouter(shardingContext); shardingRule = shardingContext.getShardingRule(); } Loading @@ -57,10 +57,10 @@ public final class PreparedSQLRouter { */ public SQLRouteResult route(final List<Object> parameters) { if (null == sqlContext) { sqlContext = routeEngine.parse(logicSQL, parameters); sqlContext = sqlRouter.parse(logicSQL, parameters); } else if (sqlContext instanceof InsertSQLContext) { parameters.addAll(GenerateKeysUtils.generateKeys(shardingRule, (InsertSQLContext) sqlContext)); } return routeEngine.route(logicSQL, parameters, sqlContext); return sqlRouter.route(logicSQL, parameters, sqlContext); } } sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/routing/SQLRouter.java→sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/routing/StatementRoutingEngine.java +8 −8 Original line number Diff line number Diff line Loading @@ -19,8 +19,8 @@ package com.dangdang.ddframe.rdb.sharding.routing; import com.dangdang.ddframe.rdb.sharding.jdbc.ShardingContext; import com.dangdang.ddframe.rdb.sharding.parsing.parser.context.SQLContext; import com.dangdang.ddframe.rdb.sharding.routing.engine.RouteEngine; import com.dangdang.ddframe.rdb.sharding.routing.engine.RouteEngineFactory; import com.dangdang.ddframe.rdb.sharding.routing.router.SQLRouter; import com.dangdang.ddframe.rdb.sharding.routing.router.SQLRouterFactory; import java.util.Collections; Loading @@ -29,12 +29,12 @@ import java.util.Collections; * * @author zhangiang */ public final class SQLRouter { public final class StatementRoutingEngine { private final RouteEngine routeEngine; private final SQLRouter sqlRouter; public SQLRouter(final ShardingContext shardingContext) { routeEngine = RouteEngineFactory.createRouteEngine(shardingContext); public StatementRoutingEngine(final ShardingContext shardingContext) { sqlRouter = SQLRouterFactory.createSQLRouter(shardingContext); } /** Loading @@ -44,7 +44,7 @@ public final class SQLRouter { * @return 路由结果 */ public SQLRouteResult route(final String logicSQL) { SQLContext sqlContext = routeEngine.parse(logicSQL, Collections.emptyList()); return routeEngine.route(logicSQL, Collections.emptyList(), sqlContext); SQLContext sqlContext = sqlRouter.parse(logicSQL, Collections.emptyList()); return sqlRouter.route(logicSQL, Collections.emptyList(), sqlContext); } } sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/routing/engine/RouteWithParsingEngine.java→sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/routing/router/ParsingSQLRouter.java +4 −4 Original line number Diff line number Diff line Loading @@ -15,7 +15,7 @@ * </p> */ package com.dangdang.ddframe.rdb.sharding.routing.engine; package com.dangdang.ddframe.rdb.sharding.routing.router; import com.codahale.metrics.Timer.Context; import com.dangdang.ddframe.rdb.sharding.api.rule.ShardingRule; Loading Loading @@ -46,18 +46,18 @@ import java.util.List; import java.util.Set; /** * 需要解析的路由引擎. * 需要解析的SQL路由器. * * @author zhangiang */ @Slf4j public final class RouteWithParsingEngine implements RouteEngine { public final class ParsingSQLRouter implements SQLRouter { private final ShardingRule shardingRule; private final DatabaseType databaseType; public RouteWithParsingEngine(final ShardingContext shardingContext) { public ParsingSQLRouter(final ShardingContext shardingContext) { shardingRule = shardingContext.getShardingRule(); databaseType = shardingContext.getDatabaseType(); } Loading Loading
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/jdbc/ShardingPreparedStatement.java +4 −4 Original line number Diff line number Diff line Loading @@ -23,7 +23,7 @@ import com.dangdang.ddframe.rdb.sharding.jdbc.adapter.AbstractPreparedStatementA import com.dangdang.ddframe.rdb.sharding.merger.ResultSetFactory; import com.dangdang.ddframe.rdb.sharding.parsing.parser.context.GeneratedKeyContext; import com.dangdang.ddframe.rdb.sharding.parsing.parser.context.InsertSQLContext; import com.dangdang.ddframe.rdb.sharding.routing.PreparedSQLRouter; import com.dangdang.ddframe.rdb.sharding.routing.PreparedStatementRoutingEngine; import com.dangdang.ddframe.rdb.sharding.routing.SQLExecutionUnit; import com.dangdang.ddframe.rdb.sharding.routing.SQLRouteResult; import com.google.common.base.Optional; Loading @@ -46,7 +46,7 @@ import java.util.Objects; */ public final class ShardingPreparedStatement extends AbstractPreparedStatementAdapter { private final PreparedSQLRouter preparedSQLRouteEngine; private final PreparedStatementRoutingEngine preparedStatementRoutingEngine; private final List<PreparedStatementExecutorWrapper> cachedPreparedStatementWrappers = new ArrayList<>(); Loading @@ -70,7 +70,7 @@ public final class ShardingPreparedStatement extends AbstractPreparedStatementAd ShardingPreparedStatement(final ShardingConnection shardingConnection, final String sql, final int resultSetType, final int resultSetConcurrency, final int resultSetHoldability) { super(shardingConnection, resultSetType, resultSetConcurrency, resultSetHoldability); preparedSQLRouteEngine = new PreparedSQLRouter(sql, shardingConnection.getShardingContext()); preparedStatementRoutingEngine = new PreparedStatementRoutingEngine(sql, shardingConnection.getShardingContext()); } ShardingPreparedStatement(final ShardingConnection shardingConnection, final String sql, final int autoGeneratedKeys) { Loading Loading @@ -160,7 +160,7 @@ public final class ShardingPreparedStatement extends AbstractPreparedStatementAd private List<PreparedStatementExecutorWrapper> routeSQL() throws SQLException { List<PreparedStatementExecutorWrapper> result = new ArrayList<>(); SQLRouteResult sqlRouteResult = preparedSQLRouteEngine.route(getParameters()); SQLRouteResult sqlRouteResult = preparedStatementRoutingEngine.route(getParameters()); setSqlContext(sqlRouteResult.getSqlContext()); if (sqlRouteResult.getSqlContext() instanceof InsertSQLContext) { setGeneratedKeyContext(((InsertSQLContext) sqlRouteResult.getSqlContext()).getGeneratedKeyContext()); Loading
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/jdbc/ShardingStatement.java +2 −2 Original line number Diff line number Diff line Loading @@ -25,7 +25,7 @@ import com.dangdang.ddframe.rdb.sharding.parsing.parser.context.GeneratedKeyCont import com.dangdang.ddframe.rdb.sharding.parsing.parser.context.InsertSQLContext; import com.dangdang.ddframe.rdb.sharding.parsing.parser.context.SQLContext; import com.dangdang.ddframe.rdb.sharding.routing.SQLExecutionUnit; import com.dangdang.ddframe.rdb.sharding.routing.SQLRouter; import com.dangdang.ddframe.rdb.sharding.routing.StatementRoutingEngine; import com.dangdang.ddframe.rdb.sharding.routing.SQLRouteResult; import com.google.common.base.Function; import com.google.common.collect.Iterators; Loading Loading @@ -275,7 +275,7 @@ public class ShardingStatement extends AbstractStatementAdapter { private StatementExecutor generateExecutor(final String sql) throws SQLException { StatementExecutor result = new StatementExecutor(shardingConnection.getShardingContext().getExecutorEngine()); SQLRouteResult sqlRouteResult = new SQLRouter(shardingConnection.getShardingContext()).route(sql); SQLRouteResult sqlRouteResult = new StatementRoutingEngine(shardingConnection.getShardingContext()).route(sql); if (sqlRouteResult.getSqlContext() instanceof InsertSQLContext) { generatedKeyContext = ((InsertSQLContext) sqlRouteResult.getSqlContext()).getGeneratedKeyContext(); } else { Loading
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/routing/PreparedSQLRouter.java→sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/routing/PreparedStatementRoutingEngine.java +8 −8 Original line number Diff line number Diff line Loading @@ -22,8 +22,8 @@ import com.dangdang.ddframe.rdb.sharding.jdbc.ShardingContext; import com.dangdang.ddframe.rdb.sharding.parsing.parser.context.InsertSQLContext; import com.dangdang.ddframe.rdb.sharding.parsing.parser.context.SQLContext; import com.dangdang.ddframe.rdb.sharding.rewrite.GenerateKeysUtils; import com.dangdang.ddframe.rdb.sharding.routing.engine.RouteEngine; import com.dangdang.ddframe.rdb.sharding.routing.engine.RouteEngineFactory; import com.dangdang.ddframe.rdb.sharding.routing.router.SQLRouter; import com.dangdang.ddframe.rdb.sharding.routing.router.SQLRouterFactory; import java.util.List; Loading @@ -32,19 +32,19 @@ import java.util.List; * * @author gaohongtao */ public final class PreparedSQLRouter { public final class PreparedStatementRoutingEngine { private final String logicSQL; private final RouteEngine routeEngine; private final SQLRouter sqlRouter; private final ShardingRule shardingRule; private SQLContext sqlContext; public PreparedSQLRouter(final String logicSQL, final ShardingContext shardingContext) { public PreparedStatementRoutingEngine(final String logicSQL, final ShardingContext shardingContext) { this.logicSQL = logicSQL; routeEngine = RouteEngineFactory.createRouteEngine(shardingContext); sqlRouter = SQLRouterFactory.createSQLRouter(shardingContext); shardingRule = shardingContext.getShardingRule(); } Loading @@ -57,10 +57,10 @@ public final class PreparedSQLRouter { */ public SQLRouteResult route(final List<Object> parameters) { if (null == sqlContext) { sqlContext = routeEngine.parse(logicSQL, parameters); sqlContext = sqlRouter.parse(logicSQL, parameters); } else if (sqlContext instanceof InsertSQLContext) { parameters.addAll(GenerateKeysUtils.generateKeys(shardingRule, (InsertSQLContext) sqlContext)); } return routeEngine.route(logicSQL, parameters, sqlContext); return sqlRouter.route(logicSQL, parameters, sqlContext); } }
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/routing/SQLRouter.java→sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/routing/StatementRoutingEngine.java +8 −8 Original line number Diff line number Diff line Loading @@ -19,8 +19,8 @@ package com.dangdang.ddframe.rdb.sharding.routing; import com.dangdang.ddframe.rdb.sharding.jdbc.ShardingContext; import com.dangdang.ddframe.rdb.sharding.parsing.parser.context.SQLContext; import com.dangdang.ddframe.rdb.sharding.routing.engine.RouteEngine; import com.dangdang.ddframe.rdb.sharding.routing.engine.RouteEngineFactory; import com.dangdang.ddframe.rdb.sharding.routing.router.SQLRouter; import com.dangdang.ddframe.rdb.sharding.routing.router.SQLRouterFactory; import java.util.Collections; Loading @@ -29,12 +29,12 @@ import java.util.Collections; * * @author zhangiang */ public final class SQLRouter { public final class StatementRoutingEngine { private final RouteEngine routeEngine; private final SQLRouter sqlRouter; public SQLRouter(final ShardingContext shardingContext) { routeEngine = RouteEngineFactory.createRouteEngine(shardingContext); public StatementRoutingEngine(final ShardingContext shardingContext) { sqlRouter = SQLRouterFactory.createSQLRouter(shardingContext); } /** Loading @@ -44,7 +44,7 @@ public final class SQLRouter { * @return 路由结果 */ public SQLRouteResult route(final String logicSQL) { SQLContext sqlContext = routeEngine.parse(logicSQL, Collections.emptyList()); return routeEngine.route(logicSQL, Collections.emptyList(), sqlContext); SQLContext sqlContext = sqlRouter.parse(logicSQL, Collections.emptyList()); return sqlRouter.route(logicSQL, Collections.emptyList(), sqlContext); } }
sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/routing/engine/RouteWithParsingEngine.java→sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/routing/router/ParsingSQLRouter.java +4 −4 Original line number Diff line number Diff line Loading @@ -15,7 +15,7 @@ * </p> */ package com.dangdang.ddframe.rdb.sharding.routing.engine; package com.dangdang.ddframe.rdb.sharding.routing.router; import com.codahale.metrics.Timer.Context; import com.dangdang.ddframe.rdb.sharding.api.rule.ShardingRule; Loading Loading @@ -46,18 +46,18 @@ import java.util.List; import java.util.Set; /** * 需要解析的路由引擎. * 需要解析的SQL路由器. * * @author zhangiang */ @Slf4j public final class RouteWithParsingEngine implements RouteEngine { public final class ParsingSQLRouter implements SQLRouter { private final ShardingRule shardingRule; private final DatabaseType databaseType; public RouteWithParsingEngine(final ShardingContext shardingContext) { public ParsingSQLRouter(final ShardingContext shardingContext) { shardingRule = shardingContext.getShardingRule(); databaseType = shardingContext.getDatabaseType(); } Loading