jmbkeyes edited a comment on issue #12512:
URL: 
https://github.com/apache/shardingsphere/issues/12512#issuecomment-921634599


   @zjcnb thanks for your help!
   ```
   package com.forzadata.bodytrack.shardingstrategy.database;
   
   import com.forzadata.bodytrack.consts.Consts;
   import 
org.apache.shardingsphere.sharding.api.sharding.standard.PreciseShardingValue;
   import 
org.apache.shardingsphere.sharding.api.sharding.standard.RangeShardingValue;
   import 
org.apache.shardingsphere.sharding.api.sharding.standard.StandardShardingAlgorithm;
   
   import java.util.Collection;
   import java.util.Properties;
   
   public class CenterIdPrecisionShardingAlgorithm implements 
StandardShardingAlgorithm<Long>{
       @Override
       public String doSharding(Collection<String> availableTargetNames, 
PreciseShardingValue<Long> shardingValue) {
           String value = Consts.CENTERID_MAPPING.get(shardingValue.getValue());
           if(null == value){
               throw new UnsupportedOperationException();
           }
           return value;
       }
   
       @Override
       public Collection<String> doSharding(Collection<String> 
availableTargetNames, RangeShardingValue<Long> shardingValue) {
           return null;
       }
       @Override
       public void init() {
           System.out.println('a');
       }
   
       @Override
       public String getType() {
           return "centerid";
       }
   
       @Override
       public Properties getProps() {
           return null;
       }
   
       @Override
       public void setProps(Properties props) {
   
       }
   }
   
   ```


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