strongduanmu commented on issue #12535:
URL:
https://github.com/apache/shardingsphere/issues/12535#issuecomment-978889771
sharding config file:
```yaml
rules:
- !SHARDING
tables:
act_re_procdef:
actualDataNodes: ds_${0..1}.act_re_procdef
defaultDatabaseStrategy:
hint:
shardingAlgorithmName: database_inline
defaultTableStrategy:
none:
shardingAlgorithms:
database_inline:
type: CLASS_BASED
props:
strategy: hint
algorithmClassName:
org.apache.shardingsphere.proxy.ClassBasedHintShardingAlgorithmFixture
```
hint algorithm:
```java
public final class ClassBasedHintShardingAlgorithmFixture implements
HintShardingAlgorithm<String> {
@Override
public void init() {
}
@Override
public Collection<String> doSharding(final Collection<String>
availableTargetNames, final HintShardingValue<String> shardingValue) {
Collection<String> result = new LinkedList<>();
for (String targetName : availableTargetNames) {
for (String value : shardingValue.getValues()) {
if (targetName.endsWith(value)) {
result.add(targetName);
}
}
}
return result;
}
@Override
public String getType() {
return null;
}
}
```
I tested the above configuration, but no exception occur. Hint doesn't seem
to work, and the query SQL is executed by the federation execution engine
rather than kernel.
```
mysql> set sharding hint database_value = 1;
Query OK, 0 rows affected (0.31 sec)
mysql> select * from act_re_procdef where KEY_ = '44' and TENANT_ID_ = '33'
and VERSION_ = (select max(VERSION_) from act_re_procdef where KEY_ ='44' and
TENANT_ID_= '33');
+------+------+----------+-------+------+----------+----------------+----------------+---------------------+--------------+---------------------+-------------------------+-------------------+------------+
| ID_ | REV_ | CATEGORY | NAME_ | KEY_ | VERSION_ | DEPLOYMENT_ID_ |
RESOURCE_NAME_ | DGRM_RESOURCE_NAME_ | DESCRIPTION_ | HAS_START_FORM_KEY_ |
HAS_GRAPHICAL_NOTATION_ | SUSPENSION_STATE_ | TENANT_ID_ |
+------+------+----------+-------+------+----------+----------------+----------------+---------------------+--------------+---------------------+-------------------------+-------------------+------------+
| 11 | 22 | NULL | NULL | 44 | 11 | NULL | NULL
| NULL | NULL | NULL |
NULL | NULL | 33 |
+------+------+----------+-------+------+----------+----------------+----------------+---------------------+--------------+---------------------+-------------------------+-------------------+------------+
1 row in set (5.30 sec)
```
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]