You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2020/07/06 04:00:18 UTC
[GitHub] [shardingsphere] Roronoa-Zoro commented on issue #6256: query all tables where sql contains a sharding column and non sharding column
Roronoa-Zoro commented on issue #6256:
URL: https://github.com/apache/shardingsphere/issues/6256#issuecomment-654002460
> show you complete config,please
spring.shardingsphere.datasource.names=ds
spring.shardingsphere.sharding.tables.t_demo.logicTable=t_demo
spring.shardingsphere.sharding.tables.t_demo.actual-data-nodes=ds.t_demo$->{0..31}
spring.shardingsphere.sharding.tables.t_demo.table-strategy.standard.sharding-column=demo_key
spring.shardingsphere.sharding.tables.t_demo.table-strategy.standard.preciseAlgorithmClassName=xx.DemoTableShardingAlgorithm
DemoTableShardingAlgorithm {
private static final ConcurrentMap<String, List<String>> tables = Maps.newConcurrentMap();
private static final String TABLE_NAME = "demo";
@Override
public String doSharding(Collection<String> availableTargetNames, PreciseShardingValue<String> shardingValue) {
String shortKey = shardingValue.getValue();
int hashCode = Math.abs(shortKey.hashCode());
int mode = hashCode % availableTargetNames.size();
List<String> tableList = tables.computeIfAbsent(TABLE_NAME, k -> Lists.newArrayList(availableTargetNames));
return tableList.get(mode);
}
}
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org