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 2020/10/26 03:33:33 UTC

[GitHub] [shardingsphere] bx189303 opened a new issue #7913: RangeShardingAlgorithm config error

bx189303 opened a new issue #7913:
URL: https://github.com/apache/shardingsphere/issues/7913


   maven:
           <dependency>
               <groupId>org.apache.shardingsphere</groupId>
               <artifactId>sharding-jdbc-spring-boot-starter</artifactId>
               <version>4.1.1</version>
           </dependency>
   
   yml:
       sharding:
         tables:
           emp:
             actual-data-nodes : d1.emp_$->{2018..2020},d2.emp_2017
             database-strategy.standard.sharding-column : user_id
             database-strategy.standard.precise-algorithm-class-name : com.example.sharding.config.MyPreciseDBShardingAlgorithm
             table-strategy.standard.sharding-column : user_id
             table-strategy.standard.precise-algorithm-class-name : com.example.sharding.config.MyPreciseShardingAlgorithm
             table-strategy.standard.range-algorithm-class-name : com.example.sharding.config.MyPreciseShardingAlgorithm
   
   public class MyPreciseShardingAlgorithm implements PreciseShardingAlgorithm<Integer>, RangeShardingAlgorithm<Integer> {
   
       @Override
       public Collection<String> doSharding(Collection<String> collection, RangeShardingValue<Integer> rangeShardingValue) {
           System.out.println("--------"+JSON.toJSONString(collection));
           System.out.println("--------"+JSON.toJSONString(rangeShardingValue));
           return collection;
       }
   
       @Override
       public String doSharding(Collection<String> availableTargetNames, PreciseShardingValue<Integer> shardingValue) {
           System.out.println("-----table----"+JSON.toJSONString(availableTargetNames));
           System.out.println("-----table----"+JSON.toJSONString(shardingValue));
       }
   }
   
   sql: 
   select * from emp where user_id = 20
   
   success: console print log:
   -----db----["d1","d2"]
   -----db----{"columnName":"user_id","logicTableName":"emp","value":2}
   -----table----["emp_2017"]
   -----table----{"columnName":"user_id","logicTableName":"emp","value":2}
   
   sql:
   select * from emp where user_id between 0 and 20
   
   error: Exception:
   java.lang.UnsupportedOperationException: Cannot find range sharding strategy in sharding rule.] with root cause
   console not print log:
   Not executed "System.out.println("--------"+JSON.toJSONString(collection))" in MyPreciseShardingAlgorithm


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



[GitHub] [shardingsphere] menghaoranss closed issue #7913: RangeShardingAlgorithm config error

Posted by GitBox <gi...@apache.org>.
menghaoranss closed issue #7913:
URL: https://github.com/apache/shardingsphere/issues/7913


   


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



[GitHub] [shardingsphere] Lucas-307 commented on issue #7913: RangeShardingAlgorithm config error

Posted by GitBox <gi...@apache.org>.
Lucas-307 commented on issue #7913:
URL: https://github.com/apache/shardingsphere/issues/7913#issuecomment-716397758


   @bx189303 I guess you should add `database-strategy.standard.range-algorithm-class-name` config, if you use range sql.


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



[GitHub] [shardingsphere] bx189303 commented on issue #7913: RangeShardingAlgorithm config error

Posted by GitBox <gi...@apache.org>.
bx189303 commented on issue #7913:
URL: https://github.com/apache/shardingsphere/issues/7913#issuecomment-717015814


   > @bx189303 I guess you should add `database-strategy.standard.range-algorithm-class-name` config, if you use range sql.
   
   you are right , I used to think only config table-strategy.standard.range-algorithm-class-name 


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



[GitHub] [shardingsphere] menghaoranss commented on issue #7913: RangeShardingAlgorithm config error

Posted by GitBox <gi...@apache.org>.
menghaoranss commented on issue #7913:
URL: https://github.com/apache/shardingsphere/issues/7913#issuecomment-716376599


   @bx189303 Could you provide the demo so that we can reproduce this problem
   


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