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 2021/10/21 11:38:19 UTC

[GitHub] [shardingsphere] sandynz commented on pull request #13196: support bit_xor function.

sandynz commented on pull request #13196:
URL: https://github.com/apache/shardingsphere/pull/13196#issuecomment-948525241


   Verify on MySQL backend proxy.
   
   Part of sharding configuration:
   ```
     shardingAlgorithms:
       database_inline:
         props:
           algorithm-expression: ds_${user_id % 3}
         type: INLINE
       t_order_inline:
         props:
           algorithm-expression: t_order_${order_id % 2}
         type: INLINE
   ```
   
   proxy result:
   ```
   mysql> select bit_xor(cast(crc32(order_id) as unsigned)) from t_order;
   +--------------------------------------------+
   | bit_xor(cast(crc32(order_id) as unsigned)) |
   +--------------------------------------------+
   |                                 2160963500 |
   +--------------------------------------------+
   1 row in set (0.05 sec)
   ```
   
   On sharding tables result:
   ```
   mysql> use scaling_ds_10
   Reading table information for completion of table and column names
   You can turn off this feature to get a quicker startup with -A
   
   mysql> select bit_xor(cast(crc32(order_id) as unsigned)) from t_order_0;
   +--------------------------------------------+
   | bit_xor(cast(crc32(order_id) as unsigned)) |
   +--------------------------------------------+
   |                                 2469506043 |
   +--------------------------------------------+
   1 row in set (0.00 sec)
   
   mysql> select bit_xor(cast(crc32(order_id) as unsigned)) from t_order_1;
   +--------------------------------------------+
   | bit_xor(cast(crc32(order_id) as unsigned)) |
   +--------------------------------------------+
   |                                 2411173863 |
   +--------------------------------------------+
   1 row in set (0.00 sec)
   
   mysql> use scaling_ds_11
   Reading table information for completion of table and column names
   You can turn off this feature to get a quicker startup with -A
   
   Database changed
   mysql> select bit_xor(cast(crc32(order_id) as unsigned)) from t_order_0;
   +--------------------------------------------+
   | bit_xor(cast(crc32(order_id) as unsigned)) |
   +--------------------------------------------+
   |                                 3741211375 |
   +--------------------------------------------+
   1 row in set (0.00 sec)
   
   mysql> select bit_xor(cast(crc32(order_id) as unsigned)) from t_order_1;
   +--------------------------------------------+
   | bit_xor(cast(crc32(order_id) as unsigned)) |
   +--------------------------------------------+
   |                                 3445281454 |
   +--------------------------------------------+
   1 row in set (0.00 sec)
   
   mysql> use scaling_ds_12
   Reading table information for completion of table and column names
   You can turn off this feature to get a quicker startup with -A
   
   Database changed
   mysql> select bit_xor(cast(crc32(order_id) as unsigned)) from t_order_0;
   +--------------------------------------------+
   | bit_xor(cast(crc32(order_id) as unsigned)) |
   +--------------------------------------------+
   |                                 2174719289 |
   +--------------------------------------------+
   1 row in set (0.00 sec)
   
   mysql> select bit_xor(cast(crc32(order_id) as unsigned)) from t_order_1;
   +--------------------------------------------+
   | bit_xor(cast(crc32(order_id) as unsigned)) |
   +--------------------------------------------+
   |                                  242257608 |
   +--------------------------------------------+
   1 row in set (0.00 sec)
   
   mysql> select 2469506043 ^ 2411173863 ^ 3741211375 ^ 3445281454 ^ 2174719289 ^ 242257608;
   +----------------------------------------------------------------------------+
   | 2469506043 ^ 2411173863 ^ 3741211375 ^ 3445281454 ^ 2174719289 ^ 242257608 |
   +----------------------------------------------------------------------------+
   |                                                                 2160963500 |
   +----------------------------------------------------------------------------+
   1 row in set (0.00 sec)
   ```
   
   Current sharding tables is migrated from another mysql database, with 2 dataSources and 2 t_order shards, test result:
   ```
   mysql> use scaling_ds_0
   Reading table information for completion of table and column names
   You can turn off this feature to get a quicker startup with -A
   
   mysql> select bit_xor(cast(crc32(order_id) as unsigned)) from t_order_0;
   +--------------------------------------------+
   | bit_xor(cast(crc32(order_id) as unsigned)) |
   +--------------------------------------------+
   |                                 1223574707 |
   +--------------------------------------------+
   1 row in set (0.01 sec)
   
   mysql> select bit_xor(cast(crc32(order_id) as unsigned)) from t_order_1;
   +--------------------------------------------+
   | bit_xor(cast(crc32(order_id) as unsigned)) |
   +--------------------------------------------+
   |                                 1866183491 |
   +--------------------------------------------+
   1 row in set (0.02 sec)
   
   mysql> use scaling_ds_1
   Reading table information for completion of table and column names
   You can turn off this feature to get a quicker startup with -A
   
   Database changed
   mysql> select bit_xor(cast(crc32(order_id) as unsigned)) from t_order_0;
   +--------------------------------------------+
   | bit_xor(cast(crc32(order_id) as unsigned)) |
   +--------------------------------------------+
   |                                 2227052702 |
   +--------------------------------------------+
   1 row in set (0.01 sec)
   
   mysql> select bit_xor(cast(crc32(order_id) as unsigned)) from t_order_1;
   +--------------------------------------------+
   | bit_xor(cast(crc32(order_id) as unsigned)) |
   +--------------------------------------------+
   |                                  598112450 |
   +--------------------------------------------+
   1 row in set (0.01 sec)
   
   mysql> select 1223574707 ^ 1866183491 ^ 2227052702 ^ 598112450;
   +--------------------------------------------------+
   | 1223574707 ^ 1866183491 ^ 2227052702 ^ 598112450 |
   +--------------------------------------------------+
   |                                       2160963500 |
   +--------------------------------------------------+
   1 row in set (0.00 sec)
   ```
   
   Each of final result is `2160963500`, matched.
   


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org