You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2024/12/11 04:09:41 UTC
(shardingsphere) branch master updated: Add @HighFrequencyInvocation on Broadcast router (#34004)
This is an automated email from the ASF dual-hosted git repository.
zhangliang 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 7e3c47d9759 Add @HighFrequencyInvocation on Broadcast router (#34004)
7e3c47d9759 is described below
commit 7e3c47d97594ee79b8fd1c045ec302e8e24fe6d7
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Wed Dec 11 12:09:35 2024 +0800
Add @HighFrequencyInvocation on Broadcast router (#34004)
---
.../apache/shardingsphere/broadcast/route/BroadcastSQLRouter.java | 5 +----
.../broadcast/route/engine/type/BroadcastRouteEngine.java | 4 ++--
.../route/engine/type/unicast/BroadcastUnicastRouteEngine.java | 7 ++++---
3 files changed, 7 insertions(+), 9 deletions(-)
diff --git a/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/route/BroadcastSQLRouter.java b/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/route/BroadcastSQLRouter.java
index e9926f0b89b..0e2925625b9 100644
--- a/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/route/BroadcastSQLRouter.java
+++ b/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/route/BroadcastSQLRouter.java
@@ -41,10 +41,7 @@ public final class BroadcastSQLRouter implements EntranceSQLRouter<BroadcastRule
public RouteContext createRouteContext(final QueryContext queryContext, final RuleMetaData globalRuleMetaData, final ShardingSphereDatabase database,
final BroadcastRule rule, final Collection<String> tableNames, final ConfigurationProperties props) {
Collection<String> broadcastTableNames = rule.getBroadcastTableNames(tableNames);
- if (broadcastTableNames.isEmpty()) {
- return new RouteContext();
- }
- return BroadcastRouteEngineFactory.newInstance(queryContext, broadcastTableNames).route(rule);
+ return broadcastTableNames.isEmpty() ? new RouteContext() : BroadcastRouteEngineFactory.newInstance(queryContext, broadcastTableNames).route(rule);
}
@Override
diff --git a/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/route/engine/type/BroadcastRouteEngine.java b/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/route/engine/type/BroadcastRouteEngine.java
index 0825f9ffceb..87cd32c0fa0 100644
--- a/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/route/engine/type/BroadcastRouteEngine.java
+++ b/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/route/engine/type/BroadcastRouteEngine.java
@@ -28,8 +28,8 @@ public interface BroadcastRouteEngine {
/**
* Route.
*
- * @param broadcastRule broadcast rule
+ * @param rule broadcast rule
* @return route context
*/
- RouteContext route(BroadcastRule broadcastRule);
+ RouteContext route(BroadcastRule rule);
}
diff --git a/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/route/engine/type/unicast/BroadcastUnicastRouteEngine.java b/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/route/engine/type/unicast/BroadcastUnicastRouteEngine.java
index aa4472cc34f..c028c86608a 100644
--- a/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/route/engine/type/unicast/BroadcastUnicastRouteEngine.java
+++ b/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/route/engine/type/unicast/BroadcastUnicastRouteEngine.java
@@ -20,6 +20,7 @@ package org.apache.shardingsphere.broadcast.route.engine.type.unicast;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.broadcast.route.engine.type.BroadcastRouteEngine;
import org.apache.shardingsphere.broadcast.rule.BroadcastRule;
+import org.apache.shardingsphere.infra.annotation.HighFrequencyInvocation;
import org.apache.shardingsphere.infra.binder.context.statement.SQLStatementContext;
import org.apache.shardingsphere.infra.binder.context.statement.ddl.AlterViewStatementContext;
import org.apache.shardingsphere.infra.binder.context.statement.ddl.CreateViewStatementContext;
@@ -39,6 +40,7 @@ import java.util.concurrent.ThreadLocalRandom;
/**
* Broadcast unicast route engine.
*/
+@HighFrequencyInvocation
@RequiredArgsConstructor
public final class BroadcastUnicastRouteEngine implements BroadcastRouteEngine {
@@ -51,12 +53,11 @@ public final class BroadcastUnicastRouteEngine implements BroadcastRouteEngine {
@Override
public RouteContext route(final BroadcastRule rule) {
RouteContext result = new RouteContext();
- RouteMapper dataSourceMapper = getDataSourceRouteMapper(rule.getDataSourceNames());
- result.getRouteUnits().add(new RouteUnit(dataSourceMapper, createTableRouteMappers()));
+ result.getRouteUnits().add(new RouteUnit(createDataSourceRouteMapper(rule.getDataSourceNames()), createTableRouteMappers()));
return result;
}
- private RouteMapper getDataSourceRouteMapper(final Collection<String> dataSourceNames) {
+ private RouteMapper createDataSourceRouteMapper(final Collection<String> dataSourceNames) {
String dataSourceName = getDataSourceName(dataSourceNames);
return new RouteMapper(dataSourceName, dataSourceName);
}