wangjing112 opened a new issue #5710:
URL: https://github.com/apache/shardingsphere/issues/5710


   in most time table's sharding rule is same like:
   `
     defaultTableStrategy:
       standard:
         shardingColumn: id
         shardingAlgorithm: 
           type: INLINE
           props:
             algorithm.expression: ${LogicTableName}${id % 2}
   `
   
   so if algorithm.expression include LogicTableName ,most of table can use 
defaultTableStrategy 
   
   just add code in InlineShardingAlgorithm like this:
   `
   
       @Override
       public String doSharding(final Collection<String> availableTargetNames, 
final PreciseShardingValue<Comparable<?>> shardingValue) {
           Preconditions.checkNotNull(properties.get(ALGORITHM_EXPRESSION), 
"Inline sharding algorithm expression cannot be null.");
           String algorithmExpression = 
InlineExpressionParser.handlePlaceHolder(properties.get(ALGORITHM_EXPRESSION).toString().trim());
           Closure<?> closure = new 
InlineExpressionParser(algorithmExpression).evaluateClosure();
           Closure<?> result = closure.rehydrate(new Expando(), null, null);
           result.setResolveStrategy(Closure.DELEGATE_ONLY);
           result.setProperty(shardingValue.getColumnName(), 
shardingValue.getValue());
           result.setProperty("LogicTableName", 
shardingValue.getLogicTableName());
           return result.call().toString();
       }
   `
   


----------------------------------------------------------------
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:
us...@infra.apache.org


Reply via email to