Interface ShardingKey


  • public interface ShardingKey
    Interface used to indicate that this object represents a sharding key. A ShardingKey instance is only guaranteed to be compatible with the data source instance that it was derived from. A ShardingKey is created using ShardingKey.Builder.

    The following example illustrates the use of ShardingKey.Builder to create a ShardingKey:

     
    
         DataSource ds = new MyDataSource();
         ShardingKey shardingKey = ds.createShardingKeyBuilder()
                               .subkey("abc", JDBCType.VARCHAR)
                               .subkey(94002, JDBCType.INTEGER)
                               .build();
     
     

    A ShardingKey is used for specifying a AdbaSessionProperty.SHARDING_KEY or a AdbaSessionProperty.SHARDING_GROUP_KEY. Databases that support composite sharding may use a * to specify a additional level of partitioning within to specify a additional level of partitioning within the shard.

    The following example illustrates the use of ShardingKey.Builder to create a AdbaSessionProperty.SHARDING_GROUP_KEY for an eastern region with a AdbaSessionProperty.SHARDING_KEY specified for the Pittsburgh branch office:

     
    
         DataSource ds = new MyDataSource();
         ShardingKey superShardingKey = ds.shardingKeyBuilder()
                               .subkey("EASTERN_REGION", AdbaType.VARCHAR)
                               .build();
         ShardingKey shardingKey = ds.shardingKeyBuilder()
                               .subkey("PITTSBURGH_BRANCH", AdbaType.VARCHAR)
                               .build();
         Session con = ds.builder()
                               .property(SHARDING_GROUP_KEY, superShardingKey)
                               .property(SHARDING_KEY, shardingKey)
                               .build();
     
     
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Interface Description
      static interface  ShardingKey.Builder
      A builder created from a DataSource or object, used to create a ShardingKey with sub-keys of supported data types.