xiongmaodeguxiang commented on issue #20679:
URL: 
https://github.com/apache/shardingsphere/issues/20679#issuecomment-1232665605

   Configuration is as follows:
   
   `ShardingRuleConfiguration ruleConfiguration = new 
ShardingRuleConfiguration();
           
ruleConfiguration.getBindingTableGroups().add("t_order,t_order_item");
           ShardingTableRuleConfiguration tableRuleConfiguration = new 
ShardingTableRuleConfiguration("t_user","ds$->{0..1}.t_user_$->{0..3}");
           tableRuleConfiguration.setDatabaseShardingStrategy(new 
StandardShardingStrategyConfiguration("user_id","db_mode_algorithm"));
           tableRuleConfiguration.setTableShardingStrategy(new 
StandardShardingStrategyConfiguration("user_id","tab_mode_algorithm"));
           ShardingTableRuleConfiguration orderTableRuleConfiguration = new 
ShardingTableRuleConfiguration("t_order","ds$->{0..1}.t_order_$->{0..3}");
           orderTableRuleConfiguration.setDatabaseShardingStrategy(new 
StandardShardingStrategyConfiguration("order_id","db_mode_algorithm"));
           orderTableRuleConfiguration.setTableShardingStrategy(new 
StandardShardingStrategyConfiguration("order_id","tab_mode_algorithm"));
           orderTableRuleConfiguration.setKeyGenerateStrategy(new 
KeyGenerateStrategyConfiguration("order_id","snowflake"));
           ShardingTableRuleConfiguration orderItemTableRuleConfiguration = new 
ShardingTableRuleConfiguration("t_order_item","ds$->{0..1}.t_order_item_$->{0..3}");
           orderItemTableRuleConfiguration.setDatabaseShardingStrategy(new 
StandardShardingStrategyConfiguration("order_id","db_mode_algorithm"));
           orderItemTableRuleConfiguration.setTableShardingStrategy(new 
StandardShardingStrategyConfiguration("order_id","tab_mode_algorithm"));
   
           ruleConfiguration.getTables().add(orderItemTableRuleConfiguration);
           ruleConfiguration.getTables().add(orderTableRuleConfiguration);
           ruleConfiguration.getTables().add(tableRuleConfiguration);
           Properties dbProps = new Properties();
           dbProps.setProperty("sharding-count","2");
           Properties tabProps = new Properties();
           tabProps.setProperty("sharding-count","4");
           ruleConfiguration.getShardingAlgorithms().put("db_mode_algorithm", 
new ShardingSphereAlgorithmConfiguration("HASH_MOD",dbProps));
           
ruleConfiguration.getShardingAlgorithms().put("tab_mode_algorithm",new 
ShardingSphereAlgorithmConfiguration("HASH_MOD",tabProps));
   
           Properties keyGenerProps = new Properties();
           keyGenerProps.setProperty("worker-id","123");
           ruleConfiguration.getKeyGenerators().put("snowflake",new 
ShardingSphereAlgorithmConfiguration("SNOWFLAKE",keyGenerProps));`


-- 
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]

Reply via email to