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 2021/09/13 11:13:20 UTC

[GitHub] [shardingsphere] tuichenchuxin commented on issue #12392: How can I configure the ComplexKeysShardingAlgorithm in version 5.0.0-alpha,In the form of Java API

tuichenchuxin commented on issue #12392:
URL: https://github.com/apache/shardingsphere/issues/12392#issuecomment-918089133


   @Lychengit You can try like this.
   ```
           // 配置分库策略
           orderTableRuleConfig.setDatabaseShardingStrategy(new ComplexShardingStrategyConfiguration("user_id,order_id", "dbShardingAlgorithm"));
           // 配置分库算法
           Properties dbShardingAlgorithmrProps = new Properties();
           dbShardingAlgorithmrProps.setProperty("algorithm-expression", "ds${(user_id % 2) + (order_id % 3)}");
           shardingRuleConfig.getShardingAlgorithms().put("dbShardingAlgorithm", new ShardingSphereAlgorithmConfiguration("COMPLEX_INLINE", dbShardingAlgorithmrProps));```


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org