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 2019/08/23 07:14:03 UTC

[GitHub] [incubator-shardingsphere] wy-coder edited a comment on issue #2910: Use data source ID and table ID to force routing is required. There is no Value in some situation.

wy-coder edited a comment on issue #2910: Use data source ID and table ID to force routing is required. There is no Value in some situation. 
URL: https://github.com/apache/incubator-shardingsphere/issues/2910#issuecomment-524198221
 
 
   Forced routing has a function that needs to be implemented, that is, sending SQL to the sub-table specified by the specified data source for execution.
   
   And forced routing should not only take effect in the table that specifies the HintShardingStrategy.
   
   For example:
   ```
    SELECT
   	MIN(KEY_FIELD) START_KEY,
   	MAX(KEY_FIELD) END_KEY,
   	count(1) ROW_COUNT
   FROM
   	(
   		SELECT
   			KEY_FIELD ,@rownum:=@rownum + 1 AS rownum
   	
   FROM
   	(select client_key as KEY_FIELD from **cif_client** where 1=1) t1,
   	(SELECT @rownum := - 1) t
   ORDER BY
   	t1.key_field
   ) tt
   GROUP BY
   	floor(tt.rownum / 200000)
   
   ```
   This is a paging SQL. I need to first cut a table into 200,000 rows as a segment. Then distribute this segment to a batch executor for processing.
   
   ```
   
           HintManager hintManager = HintManager.getInstance();
           hintManager.addDatabaseShardingValue(tableName,value);  **//value?!!!Where did I get the value?!!**  I already have data source name (or ID) and table name (or ID)!!
           hintManager.addTableShardingValue(tableName,value);  **//value?!!!Where did I get the value?!!**
   
   ```
   
   ```
           TableRuleConfiguration result = new TableRuleConfiguration();
           result.setLogicTable(tableName);
           result.setActualDataNodes("ds_${0..2}."+tableName+"_${0..2}");
           result.setDatabaseShardingStrategyConfig(new StandardShardingStrategyConfiguration("client_no",new CifDatabaseShardingAlgorithm()));
   // I just want to execute paging statements in hint, but i must modify the Strategy of this table? what??!!!
           result.setTableShardingStrategyConfig(new StandardShardingStrategyConfiguration("client_no",new CifTableShardingAlgorithm()));
          
   ```
   
   
   
   
   

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


With regards,
Apache Git Services